pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: Re: JDBC and the hstore ? operator - no longer working with build 1211
Date: Mon, 6 Mar 2017 08:36:13 +0100
Message-ID: <o9j3h7$ghu$1@blaine.gmane.org> (raw)
In-Reply-To: <7cab903f4c0f8cd90f83f71db275f6ce@lawinegevaar.nl>
References: <nv8bpg$ivu$1@blaine.gmane.org>
	<CADK3HHJ50aqPHqGOdpeja1tHnpgju8HwKA9Yi8j_1wk0n58ifg@mail.gmail.com>
	<CAB=Je-HqKThJtpYJZ9tspv2amRV5Koa-Tb+B16NwNBeCywPrsg@mail.gmail.com>
	<o98mjn$dre$1@blaine.gmane.org>
	<7cab903f4c0f8cd90f83f71db275f6ce@lawinegevaar.nl>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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





-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (16+ messages)

Message-ID: <o9j3h7$ghu$1@blaine.gmane.org>
Permalink:  ../o9j3h7$ghu$1@blaine.gmane.org/
Also on:    postgresql.org/message-id/o9j3h7$ghu$1@blaine.gmane.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: JDBC and the hstore ? operator - no longer working with build 1211
  In-Reply-To: <o9j3h7$ghu$1@blaine.gmane.org>
  References: <nv8bpg$ivu$1@blaine.gmane.org> <CADK3HHJ50aqPHqGOdpeja1tHnpgju8HwKA9Yi8j_1wk0n58ifg@mail.gmail.com> <CAB=Je-HqKThJtpYJZ9tspv2amRV5Koa-Tb+B16NwNBeCywPrsg@mail.gmail.com> <o98mjn$dre$1@blaine.gmane.org> <7cab903f4c0f8cd90f83f71db275f6ce@lawinegevaar.nl> <o9j3h7$ghu$1@blaine.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox