Skip to content

Add max_identifier_length and remove its own table_alias_length - #840

Merged
kares merged 1 commit into
jruby:masterfrom
yahonda:add_max_identifier_length
Nov 20, 2017
Merged

kares merged 1 commit into
jruby:masterfrom
yahonda:add_max_identifier_length

Conversation

@yahonda

@yahonda yahonda commented Nov 17, 2017

Copy link
Copy Markdown
Contributor

Refer rails/rails#28339

Steps to reproduce:

$ git clone https://github.com/rails/rails.git
$ cd rails/activerecord
$ git checkout 5-1-stable
$ bundle install
$ bundle exec rake test:jdbcpostgresql

Actual result without this pull request

$ bundle exec rake test:jdbcpostgresql
... snip ...
Using jdbcpostgresql
NameError: undefined local variable or method `max_identifier_length' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x1f66d8e1>
           new_column_from_field at /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb:163
                block in columns at /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:167
                             map at org/jruby/RubyArray.java:2486
                         columns at /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:166
                         columns at /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/schema_cache.rb:67
                    columns_hash at /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/schema_cache.rb:73
                    load_schema! at /home/yahonda/git/rails/activerecord/lib/active_record/model_schema.rb:471
                    load_schema! at /home/yahonda/git/rails/activerecord/lib/active_record/attributes.rb:233
                    load_schema! at /home/yahonda/git/rails/activerecord/lib/active_record/attribute_decorators.rb:50
            block in load_schema at /home/yahonda/git/rails/activerecord/lib/active_record/model_schema.rb:464
                 mon_synchronize at /home/yahonda/.rbenv/versions/jruby-9.1.14.0/lib/ruby/stdlib/monitor.rb:214
                     load_schema at /home/yahonda/git/rails/activerecord/lib/active_record/model_schema.rb:461
                 attribute_types at /home/yahonda/git/rails/activerecord/lib/active_record/model_schema.rb:353
              type_for_attribute at /home/yahonda/git/rails/activerecord/lib/active_record/model_schema.rb:376
                            type at /home/yahonda/git/rails/activerecord/lib/active_record/table_metadata.rb:32
                build_bind_param at /home/yahonda/git/rails/activerecord/lib/active_record/relation/predicate_builder.rb:168
  block in create_binds_for_hash at /home/yahonda/git/rails/activerecord/lib/active_record/relation/predicate_builder.rb:114
                            each at org/jruby/RubyHash.java:1343
           create_binds_for_hash at /home/yahonda/git/rails/activerecord/lib/active_record/relation/predicate_builder.rb:89
                    create_binds at /home/yahonda/git/rails/activerecord/lib/active_record/relation/predicate_builder.rb:34
                           build at /home/yahonda/git/rails/activerecord/lib/active_record/relation/where_clause_factory.rb:21
                          where! at /home/yahonda/git/rails/activerecord/lib/active_record/relation/query_methods.rb:612
                           where at /home/yahonda/git/rails/activerecord/lib/active_record/relation/query_methods.rb:605
                         find_by at /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:78
           find_or_initialize_by at /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:233
           find_or_initialize_by at /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:6
                             []= at /home/yahonda/git/rails/activerecord/lib/active_record/internal_metadata.rb:18
                          define at /home/yahonda/git/rails/activerecord/lib/active_record/schema.rb:56
                          define at /home/yahonda/git/rails/activerecord/lib/active_record/schema.rb:44
                          <main> at /home/yahonda/git/rails/activerecord/test/schema/schema.rb:1
                            load at org/jruby/RubyKernel.java:973
                 block in (root) at /home/yahonda/git/rails/activesupport/lib/active_support/dependencies.rb:1
                            load at /home/yahonda/git/rails/activesupport/lib/active_support/dependencies.rb:286
                 load_dependency at /home/yahonda/git/rails/activesupport/lib/active_support/dependencies.rb:258
                            load at /home/yahonda/git/rails/activesupport/lib/active_support/dependencies.rb:286
                          <main> at /home/yahonda/git/rails/activerecord/test/cases/helper.rb:139
                         require at org/jruby/RubyKernel.java:955
                          <main> at /home/yahonda/git/rails/activerecord/test/cases/helper.rb:148
                         require at org/jruby/RubyKernel.java:955
                 block in (root) at /home/yahonda/git/rails/activerecord/test/cases/batches_test.rb:1
                          select at org/jruby/RubyArray.java:2565
                          <main> at /home/yahonda/git/rails/activerecord/test/cases/batches_test.rb:1
rake aborted!

With this pull request

5004 runs, 13992 assertions, 6 failures, 29 errors, 6 skips

@kares

kares commented Nov 17, 2017

Copy link
Copy Markdown
Member

looks good to me, what do you think @rdubya ?

@rdubya

rdubya commented Nov 20, 2017

Copy link
Copy Markdown
Collaborator

Looks good to me as long as we are ok with dropping support for Postgres 7-. I assume its old enough we probably don't need to support it anymore, specially since AR only officially supports 9.1+ I believe. @kares @enebo ?

@kares

kares commented Nov 20, 2017

Copy link
Copy Markdown
Member

there were some folks attempting to support the strip down version of Postgres that Amazon has (not sure about its name), believe that product was based on 8.4 but still had its issues with AR-JDBC.
not sure about the status whether it worked in the end, but 7 sounds like it can go ...

@yahonda

yahonda commented Nov 20, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for the discussion. I'd prefer AR-JDBC supports the same database and same range of database versions as Rails does. I mean if Rails 5.1 supports PostgreSQL 9.1 or higher, AR-JDBC also supports PostgreSQL 9.1 or higher.

Rails itself does not support AWS Redshift database and there is another 3rd party gem called https://github.com/ConsultingMD/activerecord5-redshift-adapter If AR-JDBC had plenty resources to support databases more than Rails does it would be nice to consider them but I do not think there is.

@kares

kares commented Nov 20, 2017

Copy link
Copy Markdown
Member

the point is it would be just minor differences compared to postgresql adapter (due similar JDBC layer)
... but yeah - we do not care at this point. it was mostly to feed some historical perspectives into the box

@kares
kares merged commit 5df0c82 into jruby:master Nov 20, 2017
@kares

kares commented Nov 20, 2017

Copy link
Copy Markdown
Member

@yahonda thanks for the quick fix 💚 ... we shall get CI into shape in a week or two

@yahonda

yahonda commented Nov 20, 2017

Copy link
Copy Markdown
Contributor Author

Thank you.

@yahonda
yahonda deleted the add_max_identifier_length branch November 20, 2017 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants