Justin Coyne created JRUBY-6358: ----------------------------------- Summary: find by id fails when using schema_search_path and set_table_name (activerecord-jdbcpostgresql-adapter) Key: JRUBY-6358 URL: https://jira.codehaus.org/browse/JRUBY-6358 Project: JRuby Issue Type: Bug Affects Versions: JRuby 1.6.5 Environment: jruby-1.6.5.1 rails 3.1 postgres Reporter: Justin Coyne Assignee: Thomas E Enebo
In my database.yml I'm using: schema_search_path: dtu_search_production app/models/metastore.rb looks like this: class Metastore < ActiveRecord::Base set_table_name 'public.metastore' end Here's the expected output from 1.9.3: 1.9.3p0 :003 > Metastore.find(304156028, 304654300, 304669715) Metastore Load (280.2ms) SELECT "public"."metastore".* FROM "public"."metastore" WHERE "public"."metastore"."id" IN (304156028, 304654300, 304669715) => [#<Metastore id: 304156028, dedup: 181874021, doctype: 1, source: 2, xml: "<sf:art xmlns:xsi=\"http://www.w3.org/2001/XMLSchema...">, #<Metastore id: 304654300, dedup: 181874021, doctype: 1, source: 3, xml: "<sf:art xmlns:xsi=\"http://www.w3.org/2001/XMLSchema...">, #<Metastore id: 304669715, dedup: 181874021, doctype: 1, source: 11, xml: "<sf:art xmlns:xsi=\"http://www.w3.org/2001/XMLSchema...">] Here's the output from jruby: jruby-1.6.5.1 :001 > Metastore.find(304156028, 304654300, 304669715) PK and serial sequence (3.0ms) SELECT attr.attname, seq.relname FROM pg_class seq, pg_attribute attr, pg_depend dep, pg_namespace name, pg_constraint cons WHERE seq.oid = dep.objid AND seq.relkind = 'S' AND attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid AND attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1] AND cons.contype = 'p' AND dep.refobjid = '"public"."metastore"'::regclass PK and custom sequence (2.0ms) SELECT attr.attname, CASE WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN substr(split_part(def.adsrc, '''', 2), strpos(split_part(def.adsrc, '''', 2), '.')+1) ELSE split_part(def.adsrc, '''', 2) END as relname FROM pg_class t JOIN pg_attribute attr ON (t.oid = attrelid) JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum) JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1]) WHERE t.oid = '"public"."metastore"'::regclass AND cons.contype = 'p' AND def.adsrc ~* 'nextval' PK and serial sequence (2.0ms) SELECT attr.attname, seq.relname FROM pg_class seq, pg_attribute attr, pg_depend dep, pg_namespace name, pg_constraint cons WHERE seq.oid = dep.objid AND seq.relkind = 'S' AND attr.attrelid = dep.refobjid AND attr.attnum = dep.refobjsubid AND attr.attrelid = cons.conrelid AND attr.attnum = cons.conkey[1] AND cons.contype = 'p' AND dep.refobjid = '"public"."metastore"'::regclass PK and custom sequence (1.0ms) SELECT attr.attname, CASE WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN substr(split_part(def.adsrc, '''', 2), strpos(split_part(def.adsrc, '''', 2), '.')+1) ELSE split_part(def.adsrc, '''', 2) END as relname FROM pg_class t JOIN pg_attribute attr ON (t.oid = attrelid) JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum) JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1]) WHERE t.oid = '"public"."metastore"'::regclass AND cons.contype = 'p' AND def.adsrc ~* 'nextval' Metastore Load (9.0ms) SELECT "public"."metastore".* FROM "public"."metastore" WHERE "public"."metastore"."" IN (304156028, 304654300, 304669715) ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: ERROR: zero-length delimited identifier at or near """" Position: 85: SELECT "public"."metastore".* FROM "public"."metastore" WHERE "public"."metastore"."" IN (304156028, 304654300, 304669715) from arjdbc/jdbc/RubyJdbcConnection.java:191:in `execute' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.1/lib/arjdbc/jdbc/adapter.rb:216:in `_execute' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.1/lib/arjdbc/jdbc/adapter.rb:208:in `execute' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `log' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.1/lib/arjdbc/jdbc/adapter.rb:208:in `execute' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-jdbc-adapter-1.2.1/lib/arjdbc/jdbc/adapter.rb:334:in `select' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/base.rb:470:in `find_by_sql' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/relation.rb:111:in `to_a' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:159:in `all' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:346:in `find_some' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:313:in `find_with_ids' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/relation/finder_methods.rb:107:in `find' from org/jruby/RubyBasicObject.java:1715:in `__send__' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/activerecord-3.1.3/lib/active_record/base.rb:441:in `find' from (irb):1:in `evaluate' from org/jruby/RubyKernel.java:1093:in `eval' from org/jruby/RubyKernel.java:1420:in `loop' from org/jruby/RubyKernel.java:1206:in `catch' from org/jruby/RubyKernel.java:1206:in `catch' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in `start' from /usr/local/rvm/gems/jruby-1.6.5.1/gems/railties-3.1.3/lib/rails/commands.rb:40:in `(root)' from org/jruby/RubyKernel.java:1047:in `require' from script/rails:6:in `(root) 'jruby-1.6.5.1 :002 > -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email