Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ORA-00907: missing right parenthesis since #5153 merged #6147

Closed
yahonda opened this Issue May 3, 2012 · 19 comments

Comments

Projects
None yet
6 participants
Contributor

yahonda commented May 3, 2012

Since pull request #5153 (commit 07e5301) has been merged
to the rails-master branch, these 4 tests got errors with the Oracle enhanced adapter.

This error message is not straightforward although, it means Oracle does not allow ORDER BY clause within subquery.

ORA-00907: missing right parenthesis:
SELECT * FROM (SELECT  "PEOPLE".* FROM "PEOPLE"  WHERE "PEOPLE"."ID" = :a1 ORDER BY "PEOPLE"."ID" ASC FOR UPDATE) WHERE ROWNUM <= 1
$ ARCONN=oracle ruby -Itest test/cases/locking_test.rb
Using oracle
Run options: --seed 58662

# Running tests:

... snip ...

Finished tests in 21.402423s, 1.4484 tests/s, 4.8593 assertions/s.

  1) Error:
test_eager_find_with_lock(PessimisticLockingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00907: missing right parenthesis: SELECT * FROM (SELECT  "PEOPLE".* FROM "PEOPLE"  WHERE "PEOPLE"."ID" = :a1 ORDER BY "PEOPLE"."ID" ASC FOR UPDATE) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:365:in `find_first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:99:in `first'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:126:in `first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:313:in `find_one'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:299:in `find_with_ids'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:40:in `find'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:119:in `find'
    test/cases/locking_test.rb:372:in `block (2 levels) in test_eager_find_with_lock'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /home/yahonda/git/rails/activerecord/lib/active_record/transactions.rb:208:in `transaction'
    test/cases/locking_test.rb:371:in `block in test_eager_find_with_lock'
    /home/yahonda/git/rails/activesupport/lib/active_support/test_case.rb:52:in `assert_nothing_raised'
    test/cases/locking_test.rb:370:in `test_eager_find_with_lock'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.3/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__4574323970468579703__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

  2) Error:
test_sane_find_with_lock(PessimisticLockingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00907: missing right parenthesis: SELECT * FROM (SELECT  "PEOPLE".* FROM "PEOPLE"  WHERE "PEOPLE"."ID" = :a1 ORDER BY "PEOPLE"."ID" ASC FOR UPDATE) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:365:in `find_first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:99:in `first'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:126:in `first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:313:in `find_one'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:299:in `find_with_ids'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:40:in `find'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:119:in `find'
    test/cases/locking_test.rb:361:in `block (2 levels) in test_sane_find_with_lock'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /home/yahonda/git/rails/activerecord/lib/active_record/transactions.rb:208:in `transaction'
    test/cases/locking_test.rb:360:in `block in test_sane_find_with_lock'
    /home/yahonda/git/rails/activesupport/lib/active_support/test_case.rb:52:in `assert_nothing_raised'
    test/cases/locking_test.rb:359:in `test_sane_find_with_lock'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.3/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__4574323970468579703__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

  3) Error:
test_sane_lock_method(PessimisticLockingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00907: missing right parenthesis: SELECT * FROM (SELECT  "PEOPLE".* FROM "PEOPLE"  WHERE "PEOPLE"."ID" = :a1 ORDER BY "PEOPLE"."ID" ASC FOR UPDATE) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:365:in `find_first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:99:in `first'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:126:in `first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:313:in `find_one'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:299:in `find_with_ids'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:40:in `find'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:119:in `find'
    /home/yahonda/git/rails/activerecord/lib/active_record/persistence.rb:273:in `block in reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/scoping/default.rb:42:in `block in unscoped'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:240:in `scoping'
    /home/yahonda/git/rails/activerecord/lib/active_record/scoping/default.rb:42:in `unscoped'
    /home/yahonda/git/rails/activerecord/lib/active_record/persistence.rb:273:in `reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/attribute_methods/dirty.rb:39:in `reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/autosave_association.rb:223:in `reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/locking/pessimistic.rb:62:in `lock!'
    test/cases/locking_test.rb:384:in `block (2 levels) in test_sane_lock_method'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /home/yahonda/git/rails/activerecord/lib/active_record/transactions.rb:208:in `transaction'
    test/cases/locking_test.rb:381:in `block in test_sane_lock_method'
    /home/yahonda/git/rails/activesupport/lib/active_support/test_case.rb:52:in `assert_nothing_raised'
    test/cases/locking_test.rb:380:in `test_sane_lock_method'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.3/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__4574323970468579703__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

  4) Error:
test_with_lock_commits_transaction(PessimisticLockingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00907: missing right parenthesis: SELECT * FROM (SELECT  "PEOPLE".* FROM "PEOPLE"  WHERE "PEOPLE"."ID" = :a1 ORDER BY "PEOPLE"."ID" ASC FOR UPDATE) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:365:in `find_first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:99:in `first'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:126:in `first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:313:in `find_one'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:299:in `find_with_ids'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:40:in `find'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:119:in `find'
    /home/yahonda/git/rails/activerecord/lib/active_record/persistence.rb:273:in `block in reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/scoping/default.rb:42:in `block in unscoped'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:240:in `scoping'
    /home/yahonda/git/rails/activerecord/lib/active_record/scoping/default.rb:42:in `unscoped'
    /home/yahonda/git/rails/activerecord/lib/active_record/persistence.rb:273:in `reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/attribute_methods/dirty.rb:39:in `reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/autosave_association.rb:223:in `reload'
    /home/yahonda/git/rails/activerecord/lib/active_record/locking/pessimistic.rb:62:in `lock!'
    /home/yahonda/git/rails/activerecord/lib/active_record/locking/pessimistic.rb:71:in `block in with_lock'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /home/yahonda/git/rails/activerecord/lib/active_record/transactions.rb:208:in `transaction'
    /home/yahonda/git/rails/activerecord/lib/active_record/transactions.rb:232:in `transaction'
    /home/yahonda/git/rails/activerecord/lib/active_record/locking/pessimistic.rb:70:in `with_lock'
    test/cases/locking_test.rb:392:in `test_with_lock_commits_transaction'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.3/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__4574323970468579703__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

31 tests, 104 assertions, 0 failures, 4 errors, 0 skips
$
Contributor

yahonda commented May 3, 2012

The same commit introduces one more error.

$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates
Using oracle
Run options: -n test_scope_select_concatenates --seed 57747

# Running tests:

E

Finished tests in 2.908395s, 0.3438 tests/s, 0.0000 assertions/s.

  1) Error:
test_scope_select_concatenates(RelationScopingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00918: column ambiguously defined: SELECT * FROM (SELECT  id, name, id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY "DEVELOPERS"."ID" ASC) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:365:in `find_first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:99:in `first'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-59a4f84c48be/lib/active_record_deprecated_finders/relation.rb:126:in `first'
    test/cases/relation_scoping_test.rb:87:in `block in test_scope_select_concatenates'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:240:in `scoping'
    test/cases/relation_scoping_test.rb:86:in `test_scope_select_concatenates'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.3/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__2032040941876411286__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$
Contributor

mhfs commented May 4, 2012

@yahonda sorry about that. Although I don't have an Oracle database available I'll try to take a look on that on the weekend. Thanks for reporting.

Contributor

yahonda commented May 4, 2012

@mhfs No problem, please update if you have any questions.

Contributor

mhfs commented May 4, 2012

@yahonda I figured out what's the problem. It's not related to Oracle itself. It's only complaining about something the other databases don't care about. My patch impacted queries that it shouldn't. I'll submit a patch ASAP.

Contributor

mhfs commented May 5, 2012

@yahonda would you run the oracle suite against my mhfs:takes_instead_first branch please? I believe it's solved.

@jeremy jeremy closed this in 56bf1f7 May 5, 2012

Contributor

yahonda commented May 5, 2012

@mhfs Tested with the mhfs:takes_instead_first branch, original 4 ORA-00907 have been successfully finished. Thanks!

ARCONN=oracle ruby -Itest test/cases/locking_test.rb

...snip...

Finished tests in 18.884084s, 1.6416 tests/s, 5.6132 assertions/s.

31 tests, 106 assertions, 0 failures, 0 errors, 0 skips

Another error OCIError: ORA-00918 exists.

$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates
Using oracle
Run options: -n test_scope_select_concatenates --seed 40843

# Running tests:

E

Finished tests in 3.058160s, 0.3270 tests/s, 0.0000 assertions/s.

  1) Error:
test_scope_select_concatenates(RelationScopingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00918: column ambiguously defined: SELECT * FROM (SELECT  id, name, id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY "DEVELOPERS"."ID" ASC) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:324:in `find_first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:99:in `first'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-fff16f0c9a31/lib/active_record_deprecated_finders/relation.rb:126:in `first'
    test/cases/relation_scoping_test.rb:87:in `block in test_scope_select_concatenates'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:240:in `scoping'
    test/cases/relation_scoping_test.rb:86:in `test_scope_select_concatenates'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.4/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__1898347316854067876__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
SQL> SELECT  id, name, id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY "DEVELOPERS"."ID" ASC;

    ID
----------
NAME
--------------------------------------------------------------------------------
    ID     SALARY
---------- ----------
     1
David
     1  80000

It works but,

SQL> SELECT * FROM (SELECT  id, name, id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY "DEVELOPERS"."ID" ASC) WHERE ROWNUM <= 1;
SELECT * FROM (SELECT  id, name, id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY "DEVELOPERS"."ID" ASC) WHERE ROWNUM <= 1
       *
ERROR at line 1:
ORA-00918: column ambiguously defined

This original sql statement does not work. It looks two 'id' columns are ambiguously defined.

Contributor

yahonda commented May 5, 2012

I'll open another one for test_scope_select_concatenates.

Contributor

mhfs commented May 5, 2012

@yahonda thanks for the tests. I think we can continue on this one. Can you reopen?

I'll take a look on the failing test ASAP.

Owner

rafaelfranca commented May 5, 2012

Reopened

@rafaelfranca rafaelfranca reopened this May 5, 2012

Contributor

mhfs commented May 6, 2012

@yahonda would you please make a test? I'd like to know if the test pass if you replace first by take on relation_scoping_test.rb:87.

Also, I'd like to know if the test pass keeping first on line 87 if you use developers.id instead of just id in the calls to select on lines 86 and 87.

Thanks!

Contributor

yahonda commented May 7, 2012

@mhfs The first one works. however the second one also got the same error.

$ git diff
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 342f7a8..690c68c 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -84,7 +84,7 @@ class RelationScopingTest < ActiveRecord::TestCase

   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('id, salary').where("name = 'David'").take
       assert_equal 80000, developer.salary
       assert developer.has_attribute?(:id)
       assert developer.has_attribute?(:name)
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates
Using oracle
Run options: -n test_scope_select_concatenates --seed 25819

# Running tests:

... snip ...

Finished tests in 3.596949s, 0.2780 tests/s, 1.1121 assertions/s.

1 tests, 4 assertions, 0 failures, 0 errors, 0 skips
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ 
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ git diff
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 342f7a8..36b432c 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -83,8 +83,8 @@ class RelationScopingTest < ActiveRecord::TestCase
   end

   def test_scope_select_concatenates
-    Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+    Developer.select("developers.id, name").scoping do
+      developer = Developer.select('developers.id, salary').where("name = 'David'").first
       assert_equal 80000, developer.salary
       assert developer.has_attribute?(:id)
       assert developer.has_attribute?(:name)
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates
Using oracle
Run options: -n test_scope_select_concatenates --seed 32473

# Running tests:

E

Finished tests in 3.144538s, 0.3180 tests/s, 0.0000 assertions/s.

  1) Error:
test_scope_select_concatenates(RelationScopingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00918: column ambiguously defined: SELECT * FROM (SELECT  developers.id, name, developers.id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY "DEVELOPERS"."ID" ASC) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:324:in `find_first'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:99:in `first'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/bundler/gems/active_record_deprecated_finders-fff16f0c9a31/lib/active_record_deprecated_finders/relation.rb:126:in `first'
    test/cases/relation_scoping_test.rb:87:in `block in test_scope_select_concatenates'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:240:in `scoping'
    test/cases/relation_scoping_test.rb:86:in `test_scope_select_concatenates'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.4/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__2509420744868073234__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ 
Contributor

mhfs commented May 7, 2012

@yahonda thanks! It seems to me that Oracle is ok with the duplicated id in select until it gets used in the order too. This failure does not seem to be directly related to the changes in first but to the way the spec is constructed and Oracle restrictions now that first has an implied order clause. Would you agree?

Sorry to ask for more, but would you try these last changes just to confirm my hypothesis?

   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('id, salary').where("name = 'David'").order("id").take
       assert_equal 80000, developer.salary
   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('id, salary').where("name = 'David'").order("developers.id").take
       assert_equal 80000, developer.salary
   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('id as second_id, salary').where("name = 'David'").first
       assert_equal 80000, developer.salary
   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('salary').where("name = 'David'").first
       assert_equal 80000, developer.salary

Thanks in advance!

Contributor

yahonda commented May 7, 2012

@mhfs Hi, Tested 4 cases, the first and second ones got an error. The third and last ones finish successfully.

The first one an error.

$ git diff
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 342f7a8..7fed7f0 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -84,7 +84,7 @@ class RelationScopingTest < ActiveRecord::TestCase

   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('id, salary').where("name = 'David'").order("id").take
       assert_equal 80000, developer.salary
       assert developer.has_attribute?(:id)
       assert developer.has_attribute?(:name)
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates                         Using oracle
Run options: -n test_scope_select_concatenates --seed 38779

# Running tests:

E

Finished tests in 3.079204s, 0.3248 tests/s, 0.0000 assertions/s.

  1) Error:
test_scope_select_concatenates(RelationScopingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00960: ambiguous column naming in select list: SELECT * FROM (SELECT  id, name, id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY id) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:314:in `find_take'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:73:in `take'
    test/cases/relation_scoping_test.rb:87:in `block in test_scope_select_concatenates'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:240:in `scoping'
    test/cases/relation_scoping_test.rb:86:in `test_scope_select_concatenates'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.4/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__2597596766910970323__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

Second one got an error.

$ git diff
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 342f7a8..8daa36d 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -84,7 +84,7 @@ class RelationScopingTest < ActiveRecord::TestCase

   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('id, salary').where("name = 'David'").order("developers.id").take
       assert_equal 80000, developer.salary
       assert developer.has_attribute?(:id)
       assert developer.has_attribute?(:name)
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates
Using oracle
Run options: -n test_scope_select_concatenates --seed 9887

# Running tests:

E

Finished tests in 3.195023s, 0.3130 tests/s, 0.0000 assertions/s.

  1) Error:
test_scope_select_concatenates(RelationScopingTest):
ActiveRecord::StatementInvalid: OCIError: ORA-00918: column ambiguously defined: SELECT * FROM (SELECT  id, name, id, salary FROM "DEVELOPERS"  WHERE (name = 'David') ORDER BY developers.id) WHERE ROWNUM <= 1
    stmt.c:253:in oci8lib_191.so
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/ruby-oci8-2.1.2/lib/oci8/oci8.rb:474:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:143:in `exec'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:639:in `block in exec_query'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:288:in `block in log'
    /home/yahonda/git/rails/activesupport/lib/active_support/notifications/instrumenter.rb:18:in `instrument'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:283:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1322:in `log'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:619:in `exec_query'
    /home/yahonda/git/oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:1276:in `select'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:40:in `block in find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/querying.rb:39:in `find_by_sql'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:174:in `exec_queries'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:164:in `block in to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/explain.rb:37:in `logging_query_plan'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:163:in `to_a'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:314:in `find_take'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation/finder_methods.rb:73:in `take'
    test/cases/relation_scoping_test.rb:87:in `block in test_scope_select_concatenates'
    /home/yahonda/git/rails/activerecord/lib/active_record/relation.rb:240:in `scoping'
    test/cases/relation_scoping_test.rb:86:in `test_scope_select_concatenates'
    /home/yahonda/.rvm/gems/ruby-1.9.3-p194@railsmaster/gems/mocha-0.11.4/lib/mocha/integration/mini_test/version_230_to_262.rb:28:in `run'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:29:in `block in run'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:354:in `_run__2086688549155571454__setup__callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
    /home/yahonda/git/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:28:in `run'

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$

Third one finished successfully.

$ git diff
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 342f7a8..af74521 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -84,7 +84,7 @@ class RelationScopingTest < ActiveRecord::TestCase

   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('id as second_id, salary').where("name = 'David'").first
       assert_equal 80000, developer.salary
       assert developer.has_attribute?(:id)
       assert developer.has_attribute?(:name)
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates
Using oracle
Run options: -n test_scope_select_concatenates --seed 30740

# Running tests:

... snip ...
.

Finished tests in 3.244584s, 0.3082 tests/s, 1.2328 assertions/s.

1 tests, 4 assertions, 0 failures, 0 errors, 0 skips
$

The last one finished successfully.

$ vi test/cases/relation_scoping_test.rb
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ git diff
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 342f7a8..3462fd9 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -84,7 +84,7 @@ class RelationScopingTest < ActiveRecord::TestCase

   def test_scope_select_concatenates
     Developer.select("id, name").scoping do
-      developer = Developer.select('id, salary').where("name = 'David'").first
+      developer = Developer.select('salary').where("name = 'David'").first
       assert_equal 80000, developer.salary
       assert developer.has_attribute?(:id)
       assert developer.has_attribute?(:name)
ruby-1.9.3-p194@railsmaster [yahonda activerecord]$ ARCONN=oracle ruby -Itest test/cases/relation_scoping_test.rb -n test_scope_select_concatenates
Using oracle
Run options: -n test_scope_select_concatenates --seed 63776

# Running tests:

... snip ...
.

Finished tests in 3.029133s, 0.3301 tests/s, 1.3205 assertions/s.

1 tests, 4 assertions, 0 failures, 0 errors, 0 skips
$
Contributor

mhfs commented May 7, 2012

@yahonda thanks for all the patience and help. You should be good as soon as #6193 gets merged.

Contributor

yahonda commented May 7, 2012

I've tested the mhfs:fix_oracle_spec branch. I hope it get merged.

Owner

rafaelfranca commented May 12, 2012

@yahonda merged.

@mhfs thank you for the pull request.

Contributor

mhfs commented May 12, 2012

@rafaelfranca thank YOU. you're doing an awesome job on rails!

Contributor

oscardelben commented May 13, 2012

@rafaelfranca you are indeed!

👍 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment