JOOQ version: 3.8.6
MySQL version:  5.7.22

Hi
I'm trying to write query, which uses MySQL JSON data type. 
But, unfortunately, one of my key contains whitespace. The specification 
<https://dev.mysql.com/doc/refman/8.0/en/json.html> says 

>
>    - 
>    
>     The key name must be specified within double quotation marks if the 
>    name without quotes is not legal within path expressions (for example, if 
>    it contains a space).
>    
>
This is my query, which works fine in MySQL console:
SELECT .... WHERE JSON_EXTRACT(DATA, "$.elements.""key with space""") = "some 
value";

But when I try to write it in JOOQ (only condition part for readability)
Condition c = DSL.condition("JSON_EXTRACT(DATA, \"$.elements.\"\"key with 
space\"\"\") = ?", someValue);

System.out.println(c);


I get the following error:
java.lang.ArrayIndexOutOfBoundsException: 59
 at org.jooq.impl.Tools.renderAndBind(Tools.java:1614) ~[jooq-3.8.6.jar:na]
 at org.jooq.impl.SQLImpl.accept(SQLImpl.java:69) ~[jooq-3.8.6.jar:na]
 at org.jooq.impl.DefaultRenderContext.visit0(DefaultRenderContext.java:396) 
~[jooq-3.8.6.jar:na]
 at org.jooq.impl.AbstractContext.visit0(AbstractContext.java:394) ~[jooq-
3.8.6.jar:na]
 at org.jooq.impl.AbstractContext.visit(AbstractContext.java:159) ~[jooq-3.8
.6.jar:na]
 at org.jooq.impl.SQLCondition.accept(SQLCondition.java:69) ~[jooq-3.8.6.jar
:na]
 at org.jooq.impl.DefaultRenderContext.visit0(DefaultRenderContext.java:396) 
~[jooq-3.8.6.jar:na]
 at org.jooq.impl.AbstractContext.visit0(AbstractContext.java:394) ~[jooq-
3.8.6.jar:na]
 at org.jooq.impl.AbstractContext.visit(AbstractContext.java:159) ~[jooq-3.8
.6.jar:na]
 at org.jooq.impl.DefaultDSLContext.renderInlined(DefaultDSLContext.java:525
) ~[jooq-3.8.6.jar:na]
 at org.jooq.impl.AbstractQueryPart.toString(AbstractQueryPart.java:169) ~[
jooq-3.8.6.jar:na]
 at java.lang.String.valueOf(String.java:2994) ~[na:1.8.0_162]
 at java.io.PrintStream.println(PrintStream.java:821) ~[na:1.8.0_162]


I reckon the problem is with quotation marks, because when I use a key 
without space (and without escaping with quotation marks) the query works 
fine.
Any way to solve this?

Thanks 

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to