rsim / oracle-enhanced

Oracle enhaced adapter for ActiveRecord
MIT License
546 stars 308 forks source link

Updates to run tests with activerecord 7.1 #2359

Closed davinlagerroos closed 6 months ago

davinlagerroos commented 7 months ago

When running the oracle enhanced tests with activerecord v7.1.0 or above I get:

==> Effective ActiveRecord version 7.1.3
rake aborted!
NoMethodError: undefined method `database_version' for nil:NilClass (NoMethodError)

        @raw_connection.database_version
                       ^^^^^^^^^^^^^^^^^
/app/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:699:in `get_database_version'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/schema_cache.rb:374:in `database_version'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/schema_cache.rb:70:in `database_version'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/schema_cache.rb:200:in `database_version'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:871:in `database_version'
/app/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:307:in `supports_fetch_first_n_rows_and_offset?'
/app/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:271:in `arel_visitor'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:159:in `initialize'
/app/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:250:in `initialize'
/app/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:76:in `new'
/app/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:76:in `oracle_enhanced_connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:676:in `public_send'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:676:in `new_connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:723:in `checkout_new_connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:702:in `try_to_checkout_new_connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:654:in `acquire_connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in `checkout'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:182:in `connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb:246:in `retrieve_connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_handling.rb:287:in `retrieve_connection'
/usr/local/bundle/bundler/gems/rails-9c50861250dd/activerecord/lib/active_record/connection_handling.rb:254:in `connection'
/app/rakefile:24:in `block in <top (required)>'
/usr/local/bundle/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Tasks: TOP => spec => clear
(See full trace by running task with --trace)

Line 24 in the rakefile that is causing the problem is ActiveRecord::Base.connection.execute_structure_dump(ActiveRecord::Base.connection.full_drop). This appears to be related to the changes in https://github.com/rails/rails/pull/44576 and https://github.com/rails/rails/pull/44591. We no longer have a @raw_connection after calling ActiveRecord::Base.establish_connection(CONNECTION_PARAMS) on line 22, so trying work with ActiveRecord::Base.connection gives us the nil error.

3a288c3 addresses the error in starting the tests by:

After those changes, the test start, although with many errors. A couple of the more immediate ones are addressed here as well:

andynu commented 6 months ago

2381 is running against rails 7-1-stable with passing tests.