Skip to content
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

PG strings in arrays are casted to UUIDs when not needed #1086

Open
imustafin opened this issue Mar 5, 2021 · 0 comments · May be fixed by #1087
Open

PG strings in arrays are casted to UUIDs when not needed #1086

imustafin opened this issue Mar 5, 2021 · 0 comments · May be fixed by #1087

Comments

@imustafin
Copy link

I'm trying to migrate from MRI and pg to JRuby and AR-JDBC.

Suppose I have a column

my_string character varying,

for the model Test. Additionally, my_string can sometimes contain strings which match the UUID format.

The problem: when I do

Test.where(my_string: ["ec984527-9a13-3049-acd9-f862108257e4",
  "d4c22210-1824-37b1-bbe8-54558b2613dc",
  "dd7400e5-b306-39a5-b001-32af27d42a78"])

I get

ActiveRecord::JDBCError: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = uuid
  Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
  Position: 106
arjdbc/jdbc/RubyJdbcConnection.java:1161:in `execute_prepared_query'
/usr/local/bundle/gems/activerecord-jdbc-adapter-61.0-java/lib/arjdbc/abstract/database_statements.rb:49:in `block in exec_query'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:696:in `block in log'
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block in synchronize'
org/jruby/RubyThread.java:759:in `handle_interrupt'
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
org/jruby/RubyThread.java:759:in `handle_interrupt'
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:695:in `block in log'
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/local/bundle/gems/sentry-rails-4.2.2/lib/sentry/rails/tracing.rb:41:in `instrument'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:687:in `log'
/usr/local/bundle/gems/activerecord-jdbc-adapter-61.0-java/lib/arjdbc/abstract/core.rb:73:in `log'
/usr/local/bundle/gems/activerecord-jdbc-adapter-61.0-java/lib/arjdbc/abstract/database_statements.rb:46:in `exec_query'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:532:in `select'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:69:in `select_all'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:101:in `block in select_all'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:118:in `block in cache_sql'
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block in synchronize'
org/jruby/RubyThread.java:759:in `handle_interrupt'
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
org/jruby/RubyThread.java:759:in `handle_interrupt'
/usr/local/bundle/gems/activesupport-6.1.3/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:109:in `cache_sql'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:101:in `select_all'
/usr/local/bundle/gems/activerecord-jdbc-adapter-61.0-java/lib/arjdbc/abstract/database_statements.rb:86:in `select_all'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/querying.rb:47:in `find_by_sql'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/relation.rb:849:in `block in exec_queries'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/relation.rb:867:in `skip_query_cache_if_necessary'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/relation.rb:834:in `exec_queries'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/association_relation.rb:54:in `exec_queries'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/relation.rb:638:in `load'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/relation.rb:249:in `records'
/usr/local/bundle/gems/activerecord-6.1.3/lib/active_record/relation.rb:244:in `to_ary'

This was working on MRI with pg.

My versions:

activerecord-jdbcpostgresql-adapter (61.0-java)
rails (6.1.3)
jruby 9.2.15.0 (2.5.7) 2021-02-24 aa05fda562 OpenJDK 64-Bit Server VM 25.282-b08 on 1.8.0_282-b08 +jit [linux-x86_64]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant