@Override public Expression getNotIfPossible(Session session) { return new Comparison(session, Comparison.EQUAL, this, ValueExpression.get(ValueBoolean.get(false))); }
@Override public String getSQL() { StringBuilder buff = new StringBuilder(); buff.append('(').append(left.getSQL()).append(' '); if (all) { buff.append(Comparison.getCompareOperator(compareType)). append(" ALL"); } else { if (compareType == Comparison.EQUAL) { buff.append("IN"); } else { buff.append(Comparison.getCompareOperator(compareType)). append(" ANY"); } } buff.append("(\n").append(StringUtils.indent(query.getPlanSQL(), 4, false)). append("))"); return buff.toString(); }
/** * Add an additional element if possible. Example: given two conditions * A IN(1, 2) OR A=3, the constant 3 is added: A IN(1, 2, 3). * * @param other the second condition * @return null if the condition was not added, or the new condition */ Expression getAdditional(Comparison other) { Expression add = other.getIfEquals(left); if (add != null) { valueList.add(add); return this; } return null; }
@Override public Expression getNotIfPossible(Session session) { int type = getNotCompareType(); return new Comparison(session, type, left, right); }
return new Comparison(session, Comparison.IS_NOT_NULL, left, null).optimize(session); return new Comparison(session, Comparison.EQUAL, left, expr).optimize(session);
left = right; right = temp; compareType = getReversedCompareType(compareType); return ValueExpression.get(getValue(session)); return ValueExpression.get(getValue(session));
private Value getValueSlow(LocalResult rows, Value l) { // this only returns the correct result if the result has at least one // row, and if l is not null boolean hasNull = false; boolean result = all; while (rows.next()) { boolean value; Value r = rows.currentRow()[0]; if (r == ValueNull.INSTANCE) { value = false; hasNull = true; } else { value = Comparison.compareNotNull(database, l, r, compareType); } if (!value && all) { result = false; break; } else if (value && !all) { result = true; break; } } if (!result && hasNull) { return ValueNull.INSTANCE; } return ValueBoolean.get(result); }
Comparison compLeft = (Comparison) left; Comparison compRight = (Comparison) right; Expression added = compLeft.getAdditional( session, compRight, true); if (added != null) { Comparison compLeft = (Comparison) left; Comparison compRight = (Comparison) right; Expression added = compLeft.getAdditional( session, compRight, false); if (added != null) {
IndexCondition.get(compareType, l, right)); } else if (r != null) { int compareRev = getReversedCompareType(compareType); filter.addIndexCondition( IndexCondition.get(compareRev, r, left));
@Override public Value getValue(Session session) { Value l = left.getValue(session); if (l == ValueNull.INSTANCE) { return l; } boolean result = false; boolean hasNull = false; for (Expression e : valueList) { Value r = e.getValue(session); if (r == ValueNull.INSTANCE) { hasNull = true; } else { r = r.convertTo(l.getType()); result = Comparison.compareNotNull(database, l, r, Comparison.EQUAL); if (result) { break; } } } if (!result && hasNull) { return ValueNull.INSTANCE; } return ValueBoolean.get(result); }
@Override public Expression getNotIfPossible(Session session) { return new Comparison(session, Comparison.EQUAL, this, ValueExpression.get(ValueBoolean.get(false))); }
@Override public String getPreparedSQL(Session session, List<Value> parameters) { String sql; switch (compareType) { case IS_NULL: sql = left.getPreparedSQL(session, parameters) + " IS NULL"; break; case IS_NOT_NULL: sql = left.getPreparedSQL(session, parameters) + " IS NOT NULL"; break; default: sql = left.getPreparedSQL(session, parameters) + " " + getCompareOperator(compareType) + " " + right.getPreparedSQL(session, parameters); } return "(" + sql + ")"; }
l = l.convertTo(dataType); r = r.convertTo(dataType); boolean result = compareNotNull(database, l, r, compareType); return ValueBoolean.get(result);
/** * Add an additional element if possible. Example: given two conditions * A IN(1, 2) OR A=3, the constant 3 is added: A IN(1, 2, 3). * * @param session the session * @param other the second condition * @return null if the condition was not added, or the new condition */ Expression getAdditional(Session session, Comparison other) { Expression add = other.getIfEquals(left); if (add != null) { if (add.isConstant()) { valueList.add(add); valueSet.add(add.getValue(session).convertTo(left.getType())); return this; } } return null; }
@Override public Expression getNotIfPossible(Session session) { return new Comparison(session, Comparison.EQUAL, this, ValueExpression.get(ValueBoolean.get(false))); }
@Override public String getSQL() { String sql; switch (compareType) { case IS_NULL: sql = left.getSQL() + " IS NULL"; break; case IS_NOT_NULL: sql = left.getSQL() + " IS NOT NULL"; break; default: sql = left.getSQL() + " " + getCompareOperator(compareType) + " " + right.getSQL(); } return "(" + sql + ")"; }
col = col.getNonAliasExpression(); if (col.isEverything(ExpressionVisitor.QUERY_COMPARABLE_VISITOR)) { comp = new Comparison(session, comparisonType, col, param); } else { comp = new Comparison(session, Comparison.EQUAL_NULL_SAFE, param, param);
buff.append(Comparison.getCompareOperator(compareType)). append(" ALL"); } else { buff.append(Comparison.getCompareOperator(compareType)). append(" ANY");
return new Comparison(session, EQUAL, right, other.right); } else if (!(rc && l2c) && l.equals(r2)) { return new Comparison(session, EQUAL, right, other.left); } else if (!(lc && r2c) && r.equals(l2)) { return new Comparison(session, EQUAL, left, other.right); } else if (!(lc && l2c) && r.equals(r2)) { return new Comparison(session, EQUAL, left, other.left);
Expression expr = new Comparison(session, Comparison.EQUAL, left, right); expr = expr.optimize(session); return expr;