Skip to content

4.2.0: Support Rails 8.1#203

Merged
afeng-mdsol merged 6 commits into
developfrom
support_rails8
Jun 29, 2026
Merged

4.2.0: Support Rails 8.1#203
afeng-mdsol merged 6 commits into
developfrom
support_rails8

Conversation

@afeng-mdsol

@afeng-mdsol afeng-mdsol commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@mdsol/platform-scalability

policy_machine.gemspec:

Widened activerecord dependency from ~> 7.1 to ~> 8.1

Widened rails dev dependency from ~> 7.1 to ~> 8.1
Removed deprecated s.test_files accessor
active_record.rb:

db_config: Removed legacy code paths for ActiveRecord < 6.0 and == 6.0; now uses the standard configs_for(env_name:, name:) + configuration_hash API
connection_db_config: Removed connection_config fallback (removed in Rails 7.1)
serialize: Fixed to use coder: keyword argument (active_record_serialize store, coder: serializer) as required by Rails 8.0+ (positional serializer argument was removed)
postgres?: Changed from ::ActiveRecord::Base.connection.class.name check to ::ActiveRecord::Base.connection_db_config.adapter == 'postgresql' (avoids deprecated ActiveRecord::Base.connection call)
postgresql.rb:

Replaced 3 uses of deprecated sanitize_sql_for_conditions with sanitize_sql
mysql2.rb:

Removed attr_accessible (removed from Rails since 4.0)
Fixed remove_from_transitive_closure to use .rows.flatten instead of .to_a for connection.execute results (compatible with ActiveRecord::Result returned in Rails 8.1)
active_record_spec.rb:

Changed ActiveRecord::Base.connection.execute to avoid deprecated bare ActiveRecord::Base.connection call
version.rb: Bumped to 4.2.0

CHANGELOG.md: Documented all changes

Relates to: https://github.com/mdsol/dalton/pull/5755

Comment thread test/tasks/setup.rake
`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')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActiveRecord::InvalidMigrationTimestampError:  (ActiveRecord::InvalidMigrationTimestampError)

Invalid timestamp 99999999999999 for migration file: add_test_columns.
Timestamp must be in form YYYYMMDDHHMMSS, and less than 20260624162521.

when setting up the test db to run specs

@afeng-mdsol afeng-mdsol changed the title wip bump rails dependency to 8.1 4.2.0: Support Rails 8.1 Jun 23, 2026
@afeng-mdsol
afeng-mdsol marked this pull request as ready for review June 23, 2026 19:30
Copilot AI review requested due to automatic review settings June 23, 2026 19:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the gem to be compatible with Rails/ActiveRecord 8.1 by removing/avoiding deprecated APIs, updating adapter behavior for changed return types, and documenting the release.

Changes:

  • Updated ActiveRecord adapter internals (config lookup, serialization API usage, postgres detection) for Rails 8.1.
  • Updated SQL sanitization calls in the PostgreSQL adapter and transitive-closure maintenance in the MySQL2 adapter for Rails 8.1 behavior.
  • Bumped gem dependencies/version and added release notes + Backstage component metadata.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/tasks/setup.rake Updates test-app setup to copy a specific migration filename
spec/policy_machine_storage_adapters/active_record_spec.rb Avoids deprecated ActiveRecord::Base.connection usage in a spec
policy_machine.gemspec Bumps ActiveRecord/Rails dependency requirements
lib/policy_machine/version.rb Version bump for the release
lib/policy_machine_storage_adapters/active_record/postgresql.rb Replaces deprecated SQL sanitization helper usage
lib/policy_machine_storage_adapters/active_record/mysql2.rb Removes deprecated attr_accessible and adjusts execute-result handling
lib/policy_machine_storage_adapters/active_record.rb Removes legacy AR branches; updates serialization + postgres detection
factbook.yaml Adds Backstage component metadata
CHANGELOG.md Adds 4.2.0 release notes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread policy_machine.gemspec Outdated
Comment thread lib/policy_machine/version.rb

@etmilord-3ds etmilord-3ds left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Comment on lines -73 to -75
if ::ActiveRecord::Base.respond_to?(:connection_db_config)
::ActiveRecord::Base.connection_db_config.configuration_hash
else

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why did this need to be changed?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActiveRecord::Base.connection_config was deprecated sometime after Rails 6.1.
rails/rails#38005

Comment thread test/tasks/setup.rake
@@ -1,3 +1,3 @@
namespace :pm do
namespace :test do
desc 'setup necessary scaffoliding for running policy machine specs'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, just amused. 😄

@afeng-mdsol
afeng-mdsol merged commit 1cb1b65 into develop Jun 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants