Repository navigation
4.2.0: Support Rails 8.1 #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
6b85b5e
07db82e
352bd8c
87b0a33
266c072
d3e47c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| apiVersion: backstage.io/v1alpha1 | ||
| kind: Component | ||
| spec: | ||
| type: library | ||
| lifecycle: production | ||
| owner: ejinotti@mdsol.com | ||
| experience: enablement | ||
| metadata: | ||
| json_schema: https://github.com/mdsol/platform-standards/tree/main/schemas/v1alpha1.schema.json | ||
| name: the_policy_machine | ||
| title: The Policy Machine | ||
| description: A ruby implementation of the Policy Machine authorization formalism. | ||
| teams: | ||
| - number: 16 | ||
| people: | ||
| - role: technical owner | ||
| email: ejinotti@mdsol.com | ||
| annotations: | ||
| product: Platform Services - Authorization Service |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| class PolicyMachine | ||
| VERSION = "4.1.3" | ||
| VERSION = "4.2.0" | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,41 +40,12 @@ def self.load_db_adapter! | |
| def self.db_config | ||
| return @_db_config if @_db_config | ||
|
|
||
| ar_configs = PolicyElement.configurations | ||
|
|
||
| # ActiveRecord < 6.0 | ||
| unless ar_configs.respond_to?(:configs_for) | ||
| @_db_config = ar_configs[Rails.env].symbolize_keys | ||
| return @_db_config | ||
| end | ||
|
|
||
| config = begin | ||
| # ActiveRecord >= 6.1: | ||
| # there is a deprecation warning for using kwarg 'spec_name' | ||
| # so try the new 'name' kwarg first | ||
| ar_configs.configs_for(env_name: Rails.env, name: 'primary') | ||
| rescue ArgumentError | ||
| # ActiveRecord == 6.0: | ||
| # the kwarg is called 'spec_name' | ||
| ar_configs.configs_for(env_name: Rails.env, spec_name: 'primary') | ||
| end | ||
|
|
||
| @_db_config = | ||
| # AR 6.1 also emits a warning that `.config` is deprecated | ||
| # and `.configuration_hash` is The New Way | ||
| if config.respond_to?(:configuration_hash) | ||
| config.configuration_hash | ||
| else | ||
| config.config.symbolize_keys | ||
| end | ||
| config = PolicyElement.configurations.configs_for(env_name: Rails.env, name: 'primary') | ||
| @_db_config = config.configuration_hash | ||
| end | ||
|
|
||
| def self.connection_db_config | ||
| if ::ActiveRecord::Base.respond_to?(:connection_db_config) | ||
| ::ActiveRecord::Base.connection_db_config.configuration_hash | ||
| else | ||
|
Comment on lines
-73
to
-75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, why did this need to be changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ::ActiveRecord::Base.connection_config | ||
| end | ||
| ::ActiveRecord::Base.connection_db_config.configuration_hash | ||
| end | ||
|
|
||
| def self.buffering? | ||
|
|
@@ -286,7 +257,7 @@ def pluck_ancestor_tree(filters: {}, fields:) | |
|
|
||
| def self.serialize(store:, name:, serializer: nil) | ||
| # Use the passed serializer if present, otherwise use Rails' default serialization | ||
| active_record_serialize store, serializer if serializer | ||
| active_record_serialize store, coder: serializer if serializer | ||
|
|
||
| store_accessor store, name | ||
| end | ||
|
|
@@ -1363,6 +1334,6 @@ def transaction_without_mergejoin(&block) | |
| end | ||
|
|
||
| def self.postgres? | ||
| ::ActiveRecord::Base.connection.class.name == 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' | ||
| ::ActiveRecord::Base.connection_db_config.adapter == 'postgresql' | ||
| end | ||
| end unless active_record_unavailable | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ namespace :pm do | |
| `bundle exec rails generate the_policy_machine:update_policy_element_associations_table -f` | ||
| `bundle exec rails generate the_policy_machine:accessible_objects_for_operations_function -f` | ||
| `bundle exec rails generate the_policy_machine:update_accessible_objects_filter_performance -f` | ||
| FileUtils.cp('../add_test_columns_migration.rb', './db/migrate/99999999999999_add_test_columns.rb') | ||
| FileUtils.cp('../add_test_columns_migration.rb', './db/migrate/20260624162522_add_test_columns.rb') | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when setting up the test db to run specs |
||
|
|
||
| `bundle exec rake db:create db:migrate` | ||
| `RAILS_ENV=test bundle exec rake db:migrate` | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.