@Override
public final void accept(Context<?> ctx) {
SQLDialect family = ctx.configuration().dialect().family();
Field<?> lhs = field1;
Field<?> rhs = field2;
Comparator op = comparator;
// [#1159] Some dialects cannot auto-convert the LHS operand to a
// VARCHAR when applying a LIKE predicate
// [#293] TODO: This could apply to other operators, too
if ((op == LIKE || op == NOT_LIKE)
&& field1.getType() != String.class
&& asList(DERBY, POSTGRES).contains(family)) {
lhs = lhs.cast(String.class);
}
// [#1423] Only Postgres knows a true ILIKE operator. Other dialects
// need to simulate this as LOWER(lhs) LIKE LOWER(rhs)
else if ((op == LIKE_IGNORE_CASE || op == NOT_LIKE_IGNORE_CASE)
&& POSTGRES != family) {
lhs = lhs.lower();
rhs = rhs.lower();
op = (op == LIKE_IGNORE_CASE ? LIKE : NOT_LIKE);
}
ctx.visit(lhs)
.sql(" ");
boolean castRhs = false;
/* [pro] xx
xx xxxxxxx xxxx xxxxx xxx xxxxx xxxxx xxxxxx xxxx xxxxxxx xxxx x
xx xxxxxxxxxxxx xxxxxx xxxxxxxxxxx xx xxx xxxxxxxxxx xx xxxx xxxx xxxx
xx xxxxxxxxxx xxxx
xx xxxxxxx xx xxx xx xxx xxxxxxxxxx xxxxxxx
xxxxxxx x xxxxx
xx [/pro] */
ctx.keyword(op.toSQL()).sql(" ");
if (castRhs) ctx.keyword("cast").sql("(");
ctx.visit(rhs);
if (castRhs) ctx.sql(" ").keyword("as").sql(" ").keyword("varchar").sql("(4000))");
if (escape != null) {