oracle-enhanced icon indicating copy to clipboard operation
oracle-enhanced copied to clipboard

Rails 8.1 support

Open andynu opened this issue 2 months ago • 0 comments

This PR brings full Rails 8.1 compatibility to the Oracle Enhanced adapter, building on excellent work by @akostadinov (Aleksandar N. Kostadinov) in PR #2471.

I've added only two additional fixes:

  • CLOB insertion with disabled prepared statements,
  • removal of the obsolete ExplainSubscriber reference that Rails 8.1 refactored away.

Credits

The vast majority of this work was done by Aleksandar N. Kostadinov (@akostadinov) and Daria Mayorova (@mayorova). Their comprehensive compatibility updates fixed nearly all Rails 8.1 issues.

Changes from @akostadinov's PR #2471

Core Rails 8.1 API Compatibility

  • Column constructor signature change (https://github.com/rails/rails/pull/54333)
    • Updated OracleEnhanced::Column.new to accept cast_type as second parameter
    • Modified schema_statements.rb and schema_creation.rb to call lookup_cast_type and pass cast types to column constructors
    • Updated tests to use new column constructor signature
  • Schema dumping method rename
    • Changed dump_schema_information → dump_schema_versions throughout codebase
    • Updated method calls and comments in schema_statements.rb and test specs
  • Native database types refactoring
    • Moved native_database_types to class method to support Rails 8.1's static type resolution
    • Instance method now delegates to class method
    • Maintains backward compatibility with emulate_booleans_from_strings setting
  • Distinct column API changes (by @mayorova)
    • Updated distinct_relation_for_primary_key to use Rails 7.1+ distinct column API
    • Changed internal method call from previous API to distinct(column_name)

Test Infrastructure & Coverage

  • Rails 7.1 composite primary key tests
    • Added comprehensive test suite for composite primary keys (composite_spec.rb)
    • Tests unique constraints, validations, and composite key behavior
    • 84 lines of new test coverage
  • Test reliability improvements
    • Fixed emulate_booleans test to properly clear type map and re-establish connections
    • Changed from instance variable @conn to leased connections for thread safety
    • Added proper connection cleanup in test teardown
  • Schema enhancement follow-up (#1544)
    • Updated create_sequence call to use proper keyword arguments
    • Modernized sequence creation syntax

My Contributions (this PR)

CLOB Insertion Fix

  • Fixed CLOB/BLOB insertion when prepared_statements: false (commit 0a4ad58c)
    • Added before_create and after_create callbacks to LOB module
    • Previously only had after_update callbacks, causing data loss on insert
    • When prepared_statements is disabled, SQL uses empty_clob()/empty_blob() literals
    • Now properly writes LOB data after record creation
    • Added 51 lines of test coverage in type/text_spec.rb
    • Fixes #2477
    • Uses ROWID for clob update statements to avoid issues with missing primary keys and/or composite primary keys. (e4b0156)

Rails 8.1 ExplainSubscriber Removal

  • Removed obsolete ActiveRecord::ExplainSubscriber reference (commit 85618afa)
    • Rails 8.1 removed ExplainSubscriber class (https://github.com/rails/rails/commit/f488878f1bc0aecc33485135efc0800f1388cfdb)
    • ExplainSubscriber functionality refactored into ExplainRegistry with lazy subscription
    • Rails 8.1 now subscribes only when .explain is first called
    • Removed manual subscription line from spec_helper.rb that was causing NameError

Testing

All tests pass against Rails 8.1 (8-1-stable branch).

andynu avatar Oct 23 '25 20:10 andynu