New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use :string
instead of :text
for JsonAttributeTest
#31344
Conversation
Since CLOB data type has many limitations in Oracle SELECT WHERE clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍
Thanks for the pull request and I've found I was misunderstanding / confusing between JSON data type and JSON attribute testing. I've got to know this test already have passed with MariaDB which I have tested this pull request with Oracle enhanced adapter. Due to Oracle database primary key implementation difference, insert statement needs $ ARCONN=oracle bin/test test/cases/json_attribute_test.rb
Using oracle
Run options: --seed 16772
# Running:
E......E..E.EE........E.
Finished in 3.894214s, 6.1630 runs/s, 11.8124 assertions/s.
1) Error:
JsonAttributeTest#test_rewrite_array_json_value:
ActiveRecord::NotNullViolation: OCIError: ORA-01400: cannot insert NULL into ("ARUNIT"."JSON_DATA_TYPE"."ID"): insert into json_data_type (payload) VALUES ('["v0",{"k1":"v1"}]')
stmt.c:243:in oci8lib_250.so
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/cursor.rb:131:in `exec'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:272:in `exec_internal'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:263:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:424:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:97:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `block in execute'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `block (2 levels) in log'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:570:in `block in log'
/home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:561:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb:36:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `execute'
/home/yahonda/git/rails/activerecord/test/cases/json_shared_test_cases.rb:116:in `test_rewrite_array_json_value'
2) Error:
JsonAttributeTest#test_select_array_json_value:
ActiveRecord::NotNullViolation: OCIError: ORA-01400: cannot insert NULL into ("ARUNIT"."JSON_DATA_TYPE"."ID"): insert into json_data_type (payload) VALUES ('["v0",{"k1":"v1"}]')
stmt.c:243:in oci8lib_250.so
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/cursor.rb:131:in `exec'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:272:in `exec_internal'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:263:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:424:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:97:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `block in execute'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `block (2 levels) in log'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:570:in `block in log'
/home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:561:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb:36:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `execute'
/home/yahonda/git/rails/activerecord/test/cases/json_shared_test_cases.rb:110:in `test_select_array_json_value'
3) Error:
JsonAttributeTest#test_select:
ActiveRecord::NotNullViolation: OCIError: ORA-01400: cannot insert NULL into ("ARUNIT"."JSON_DATA_TYPE"."ID"): insert into json_data_type (payload) VALUES ('{"k":"v"}')
stmt.c:243:in oci8lib_250.so
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/cursor.rb:131:in `exec'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:272:in `exec_internal'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:263:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:424:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:97:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `block in execute'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `block (2 levels) in log'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:570:in `block in log'
/home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:561:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb:36:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `execute'
/home/yahonda/git/rails/activerecord/test/cases/json_shared_test_cases.rb:76:in `test_select'
4) Error:
JsonAttributeTest#test_null_json:
ActiveRecord::NotNullViolation: OCIError: ORA-01400: cannot insert NULL into ("ARUNIT"."JSON_DATA_TYPE"."ID"): insert into json_data_type (payload) VALUES(null)
stmt.c:243:in oci8lib_250.so
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/cursor.rb:131:in `exec'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:272:in `exec_internal'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:263:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:424:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:97:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `block in execute'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `block (2 levels) in log'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:570:in `block in log'
/home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:561:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb:36:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `execute'
/home/yahonda/git/rails/activerecord/test/cases/json_shared_test_cases.rb:88:in `test_null_json'
5) Error:
JsonAttributeTest#test_select_multikey:
ActiveRecord::NotNullViolation: OCIError: ORA-01400: cannot insert NULL into ("ARUNIT"."JSON_DATA_TYPE"."ID"): insert into json_data_type (payload) VALUES ('{"k1":"v1", "k2":"v2", "k3":[1,2,3]}')
stmt.c:243:in oci8lib_250.so
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/cursor.rb:131:in `exec'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:272:in `exec_internal'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:263:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:424:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:97:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `block in execute'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `block (2 levels) in log'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:570:in `block in log'
/home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:561:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb:36:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `execute'
/home/yahonda/git/rails/activerecord/test/cases/json_shared_test_cases.rb:82:in `test_select_multikey'
6) Error:
JsonAttributeTest#test_rewrite:
ActiveRecord::NotNullViolation: OCIError: ORA-01400: cannot insert NULL into ("ARUNIT"."JSON_DATA_TYPE"."ID"): insert into json_data_type (payload) VALUES ('{"k":"v"}')
stmt.c:243:in oci8lib_250.so
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/cursor.rb:131:in `exec'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:272:in `exec_internal'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/gems/2.5.0/gems/ruby-oci8-2.2.5/lib/oci8/oci8.rb:263:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:424:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:97:in `exec'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `block in execute'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `block (2 levels) in log'
/home/yahonda/.rbenv/versions/2.5.0-dev/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:570:in `block in log'
/home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:561:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb:36:in `log'
/home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:13:in `execute'
/home/yahonda/git/rails/activerecord/test/cases/json_shared_test_cases.rb:69:in `test_rewrite'
24 runs, 46 assertions, 0 failures, 6 errors, 0 skips
$ Would you review yahonda@8adb5ca and it would be helpful to cherry-pick this commit . Thank you. |
…cle database which requires primary key value mentioned in insert statement explicitly.
Thanks for your confirming. I missed that oracle-enhanced is not using Identity Column for primary keys yet. I've cherry-picked yahonda@8adb5ca and going to merge this. Thanks! |
Thank you. |
Since CLOB data type has many limitations in Oracle SELECT WHERE clause.
JsonAttributeTest
is a test for JSON attribute (attribute :payload, :json
on text column), not for JSON data type. So it should pass the test regardless ofsupports_json?
.I think that the oracle enhanced failure is due to CLOB data type limitations.
@yahonda Can you confirm the test result on this branch?