rsim / oracle-enhanced

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

ActiveRecord::ConnectionAdapters::OracleEnhanced::SchemaStatements#table_comment not working correctly in 6.x #2285

Open istrasci opened 2 years ago

istrasci commented 2 years ago

Calling this method on a model with a table name in a different schema now only gives nil. Whereas in version 5.2.x, it would correctly fetch the table's comment.

Steps to reproduce

  1. Add to Gemfile:
    gem 'activerecord-oracle_enhanced-adapter', '6.1.4'
    gem 'rails', '6.1.5'
  2. Create a model (w/ migration) that lives in a non-standard DB schema.

    # app/models/my_schema/my_model.rb
    module MySchema
      class MyModel < ApplicationRecord  # which inherits from ActiveRecord::Base
        self.table_name = 'my_schema.my_model'  # intentionally using singular name
        # other stuff...
      end
    end
    
    # db/migrate/01_create_my_schema_my_model.rb
    class CreateMySchemaMyModel < ActiveRecord::Migration[6.1]
      def change
        create_table 'my_schema.my_model', comment: "This model has a comment" do |t|
          # Some column definitions...
        end
      end
    end

    then migrate

  3. Open rails console, then call ApplicationRecord.connection.table_comment(MySchema::MyModel.table_name)
  4. Exit rails consle, change Gemfile to use
    gem 'activerecord-oracle_enhanced-adapter', '5.2.3'
    gem 'rails', '5.2.3'

    re-bundle, then repeat step 3.

Expected behavior

It should return the string "This model has a comment" with all versions of the gem

Actual behavior

System configuration

Rails version: 6.1.5 / 5.2.3 for these examples

Oracle enhanced adapter version: 6.1.4 / 5.2.3 for these examples

Ruby version: 2.6.6 / 2.7.5

Oracle Database version: Oracle Database 19c Enterprise Edition - 19.14.0.0.0