Hi,
I have two different code paths that make use of org.jooq.Condition and
add it to the where clause of a query. The first path is all JOOQ in that
it creates a query using mostly JOOQ DSL, the second code path is more
"stringy" and creates the SQL in a String buffer and adds to it various
JOOQ conditions.
I'm experiencing an error in the second code path because the condition is
rendered differently than in the first case and PostgreSQL complains about
casting.
To illustrate, we have a column called TAGS of type varchar[ ] on a table
named POSTS
org.jooq.Condition c = DSL.field("tags",String[].class).contains(
aStringArray);
The above condition can be used two different ways in our code:
1. Like this:
d.select(...).from(table("posts").where( c );
the WHERE clause renders:
WHERE tags @> '{"tag2"}'
2. Or like this
String sql = "Select * FROM posts where " + c.toString();
the WHERE clause renders:
WHERE tags @> ARRAY['tag9']
and I get the following error from postgresql
ERROR: operator does not exist: character varying[] @> text[] at character
387
HINT: No operator matches the given name and argument type(s). You might
need to add explicit type casts.
Postgres is being picky and wants the string 'tag9' cast to type varchar.
Why is the jooq condition being rendered two different ways? How can I fix
this?
--
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.