Re: JDBC and the hstore ? operator - no longer working with build 1211

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JDBC and the hstore ? operator - no longer working with build 1211
Date: 2017-03-06 07:36:13
Message-ID: o9j3h7$ghu$1@blaine.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Mark Rotteveel schrieb am 02.03.2017 um 19:10:
>> connection.prepareStatement("select * from foo where hstore_column ?& array['key']");
>> connection.prepareStatement("select * from foo where hstore_column ?| array['key']");
>>
>> The prepareStatement() call succeeds, but when calling executeQuery()
>> an exception is thrown:
>>
>> org.postgresql.util.PSQLException: No value specified for parameter 1.
>>
>> The goal is to pass the array as a parameter, something like:
>>
>> Array keys = con.createArrayOf("text", new String[] {"key1","key2"});
>> connection.prepareStatement("select * from foo where hstore_column ?& ?");
>> pstmt.setArray(1, keys);
>> ResultSet rs = pstmt.executeQuery();
>>
>> Tested with 1212 and 42.0.0
>
> I haven't tried it, but would you logically need to use ??& and ??|, if the ? operator is escaped using ??

That indeed does work.

We first tried it with an obfuscation layer (aka "ORM") which seems to mess around with those operators and breaks that escaping.

Thomas

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Bogdan Daniliuc 2017-03-06 08:23:12 Re: Problem updating driver to 42.0.0
Previous Message Tsunakawa, Takayuki 2017-03-06 02:27:06 Re: Statement-level rollback