Expression(ExpressionOperator operator, Field<T> lhs, Field<?>... rhs) { super(operator.toSQL(), lhs.getDataType(), Util.combine(lhs, rhs)); this.operator = operator; this.lhs = lhs; this.rhs = new FieldList(); this.rhs.addAll(Arrays.asList(rhs)); }
@Override public final void accept(Context<?> ctx) { SQLDialect family = ctx.configuration().dialect().family(); if (operator == BIT_NOT && asList(H2, HSQLDB).contains(family)) { ctx.sql("(0 - ").visit(field).sql(" - 1)"); } else if (operator == BIT_NOT && family == FIREBIRD) { ctx.keyword("bin_not(").visit(field).sql(')'); } else { ctx.sql(operator.toSQL()).sql('(').visit(field).sql(')'); } }
Neg(Field<T> field, ExpressionOperator operator) { super(operator.toSQL() + field.getName(), field.getDataType()); this.operator = operator; this.field = field; }