[#2956] isFalse()/isTrue() result in extra parameters

This commit is contained in:
Lukas Eder 2014-01-22 17:44:38 +01:00
parent 755eaa28ea
commit ce46c54fff
2 changed files with 23 additions and 11 deletions

View File

@ -64,6 +64,8 @@ import static org.jooq.impl.ExpressionOperator.ADD;
import static org.jooq.impl.ExpressionOperator.DIVIDE;
import static org.jooq.impl.ExpressionOperator.MULTIPLY;
import static org.jooq.impl.ExpressionOperator.SUBTRACT;
import static org.jooq.tools.Convert.FALSE_VALUES;
import static org.jooq.tools.Convert.TRUE_VALUES;
import static org.jooq.tools.StringUtils.defaultString;
import java.math.BigDecimal;
@ -96,7 +98,6 @@ import org.jooq.SortField;
import org.jooq.SortOrder;
import org.jooq.WindowIgnoreNullsStep;
import org.jooq.WindowPartitionByStep;
import org.jooq.tools.Convert;
import org.jooq.tools.StringUtils;
/**
@ -591,16 +592,16 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
Class<?> type = getType();
if (type == String.class) {
return ((Field<String>) this).in(Convert.TRUE_VALUES);
return ((Field<String>) this).in((Collection) Utils.inline(TRUE_VALUES.toArray(new String[TRUE_VALUES.size()])));
}
else if (Number.class.isAssignableFrom(type)) {
return ((Field<Number>) this).equal((Number) getDataType().convert(1));
return ((Field<Number>) this).equal(inline((Number) getDataType().convert(1)));
}
else if (Boolean.class.isAssignableFrom(type)) {
return ((Field<Boolean>) this).equal(true);
return ((Field<Boolean>) this).equal(inline(true));
}
else {
return cast(String.class).in(Convert.TRUE_VALUES);
return cast(String.class).in(TRUE_VALUES);
}
}
@ -610,16 +611,16 @@ abstract class AbstractField<T> extends AbstractQueryPart implements Field<T> {
Class<?> type = getType();
if (type == String.class) {
return ((Field<String>) this).in(Convert.FALSE_VALUES);
return ((Field<String>) this).in((Collection) Utils.inline(FALSE_VALUES.toArray(new String[FALSE_VALUES.size()])));
}
else if (Number.class.isAssignableFrom(type)) {
return ((Field<Number>) this).equal((Number) getDataType().convert(0));
return ((Field<Number>) this).equal(inline((Number) getDataType().convert(0)));
}
else if (Boolean.class.isAssignableFrom(type)) {
return ((Field<Boolean>) this).equal(false);
return ((Field<Boolean>) this).equal(inline(false));
}
else {
return cast(String.class).in(Convert.FALSE_VALUES);
return cast(String.class).in((Collection) Utils.inline(FALSE_VALUES.toArray(new String[FALSE_VALUES.size()])));
}
}

View File

@ -50,7 +50,6 @@ import static org.jooq.impl.DSL.concat;
import static org.jooq.impl.DSL.escape;
import static org.jooq.impl.DSL.fieldByName;
import static org.jooq.impl.DSL.getDataType;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.nullSafe;
import static org.jooq.impl.DSL.val;
import static org.jooq.impl.DefaultExecuteContext.localConnection;
@ -762,6 +761,18 @@ final class Utils {
return result;
}
static final <T> List<Field<T>> inline(T[] values) {
List<Field<T>> result = new ArrayList<Field<T>>();
if (values != null) {
for (T value : values) {
result.add(DSL.inline(value));
}
}
return result;
}
/**
* Return a list of unqualified {@link Field}s.
*/
@ -1399,7 +1410,7 @@ final class Utils {
/* [pro] xx
xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxx x
xxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxx
xxxxxx xxxxxxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxx
x
xxxx
xx [/pro] */