Open prashantvithani opened 5 years ago
The problem is, JDBC uses ?
as placeholder instead of the PG-specific $n
. So for prepared statements, the JSONB operator becomes ??
instead of a single ?
. See https://github.com/pgjdbc/pgjdbc/issues/643
Sample Schema
Writing query to retreive user records with
company_id
= 1, and whoseoptions
contains keyskey1
andkey2
Case 1 with Success
[JRuby] SQL Query (
prepared_statements: false
)binds (Array<>): []
(no need as the values are embedded in query already)[MRI] SQL Query (
prepared_statements: true/false
)binds (Array<ActiveRecord::Relation::QueryAttribute>): [argument1, argument2]
(values to be embedded in query replacing$n
)Case 2 with Failure
[JRuby] SQL Query (
prepared_statements: true
)binds (Array<ActiveRecord::Relation::QueryAttribute>): [argument1, argument2]
(values to be embedded in query replacing?
)Error Statement
Rails's connection adapter translates arguments of query in
$n
format, whereas JDBC-adapter translates it into?
and it conflicts with the PostgreSQL'sjsonb
operators?
or?|
and seeks for the extra argument for jsonb operator?
.JRuby:
Java:
PostgreSQL version:
10.4