Don't freak out on empty In()'s, just scold the developer.
This commit is contained in:
@@ -220,6 +220,11 @@ public abstract class BuildVisitor implements ExpressionVisitor
|
|||||||
|
|
||||||
public void visit (In in)
|
public void visit (In in)
|
||||||
{
|
{
|
||||||
|
// if the In() expression is empty, replace it with a 'false'
|
||||||
|
if (in.getValues().length == 0) {
|
||||||
|
new ValueExp(false).accept(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
in.getColumn().accept(this);
|
in.getColumn().accept(this);
|
||||||
_builder.append(" in (");
|
_builder.append(" in (");
|
||||||
Comparable<?>[] values = in.getValues();
|
Comparable<?>[] values = in.getValues();
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import com.samskivert.depot.expression.SQLExpression;
|
|||||||
import com.samskivert.depot.impl.ExpressionVisitor;
|
import com.samskivert.depot.impl.ExpressionVisitor;
|
||||||
import com.samskivert.util.Tuple;
|
import com.samskivert.util.Tuple;
|
||||||
|
|
||||||
|
import static com.samskivert.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenient container for implementations of conditional operators. Classes that value brevity
|
* A convenient container for implementations of conditional operators. Classes that value brevity
|
||||||
* classes that feel otherwise will use Conditionals.Equals() and Conditionals.In().
|
* classes that feel otherwise will use Conditionals.Equals() and Conditionals.In().
|
||||||
@@ -195,7 +197,7 @@ public abstract class Conditionals
|
|||||||
public In (ColumnExp column, Comparable<?>... values)
|
public In (ColumnExp column, Comparable<?>... values)
|
||||||
{
|
{
|
||||||
if (values.length == 0) {
|
if (values.length == 0) {
|
||||||
throw new IllegalArgumentException("In() condition needs at least one value.");
|
log.warning("Grouchily allowing empty In() operator", "column", column.name);
|
||||||
}
|
}
|
||||||
_column = column;
|
_column = column;
|
||||||
_values = values;
|
_values = values;
|
||||||
|
|||||||
Reference in New Issue
Block a user