select.getBindValues() shouldn't include inlined parameters

39 views
Skip to first unread message

Ariel Tal

unread,
Mar 14, 2014, 2:55:57 PM3/14/14
to jooq...@googlegroups.com
Hi,
Not sure if this is a bug or I'm missing some other way to achieve what I'm trying to do.

I realize this slightly goes around the 'fetch' capabilities of JOOQ but this is my use-case:
  1. Use JOOQ as an SQL builder by constructing queries and using getSQL() to get a prepared statement template. 
  2. Create a prepared statement on using the template and bind the values as passed by the Select<?> object, by calling getBindValues and iterating over the results.
The problem: inlined parameters replace the '?' sign, but are included in the BindValues list.

Tried using 'val' but that produces another '?' which is not necessary if this value doesn't change. 
Is this a bug? Is there a different way to get the bind values?

Thanks in advance,
Ariel

Lukas Eder

unread,
Mar 17, 2014, 10:15:33 AM3/17/14
to jooq...@googlegroups.com
Hi Ariel,

Thanks for reporting this. This is indeed a bug because the getSQL() and getBindValues() methods should work together for use-cases where jOOQ is used to generate but not to execute SQL. I have registered #3131 for this:

As this will incompatibly change behaviour, I think it will be better not to merge this fix to 3.2 and 3.3 minor releases.

In the mean time, as a workaround, you could implement a VisitListener or a BindContext to extract bind values from your queries. Note that the BindContext SPI is an internal SPI, so workarounds built upon this SPI might break in future releases.

Let me know if you have any questions regarding the above SPIs.

Another, perhaps a bit simpler workaround is to use Query.getParams()

... and then retain only those Params that have the inline flag set to false:

Cheers
Lukas


--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages