[jOOQ/jOOQ#16529] Auto wrap Field arguments to a Routine's Object typed parameter in Field<Object>
This commit is contained in:
parent
2e6e83afaa
commit
cfca1e440c
@ -331,7 +331,7 @@ implements
|
||||
|
||||
@Override
|
||||
public final <Z> void set(Parameter<Z> parameter, Z value) {
|
||||
setField(parameter, val(value, parameter.getDataType()));
|
||||
setField(parameter, Tools.field(value, parameter.getDataType()));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -114,7 +114,9 @@ import org.jooq.Generator;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Nullability;
|
||||
import org.jooq.QualifiedRecord;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.exception.DataTypeException;
|
||||
import org.jooq.exception.MappingException;
|
||||
import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
import org.jooq.impl.DefaultBinding.InternalBinding;
|
||||
@ -931,6 +933,32 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
|
||||
else if (java.util.Date.class == type)
|
||||
return (DataType<T>) SQLDataType.TIMESTAMP;
|
||||
|
||||
|
||||
// [#16529] Help users trouble shoot this particular problem
|
||||
else if (QueryPart.class.isAssignableFrom(type))
|
||||
throw new DataTypeException(
|
||||
"""
|
||||
Type {type} cannot be used as a bind variable type.
|
||||
|
||||
This error often appears when a wrong overload is chosen, e.g. among:
|
||||
|
||||
- <T> Field<T> someFunction(T arg1, T arg2);
|
||||
- <T> Field<T> someFunction(Field<T> arg1, Field<T> arg2)
|
||||
|
||||
When mixing expression arguments with bind value arguments, such as:
|
||||
|
||||
someFunction(TABLE.COLUMN, "bind value")
|
||||
|
||||
Then only the first overload is applicable, and in some cases, jOOQ cannot auto-wrap
|
||||
the "bind value" in DSL.val("bind value") for you. Consider calling the function
|
||||
like this, instead:
|
||||
|
||||
someFunction(TABLE.COLUMN, DSL.val("bind value"))
|
||||
|
||||
If you think this error shouldn't appear, please report it here: https://jooq.org/bug
|
||||
""".replace("{type}", type.getName())
|
||||
);
|
||||
|
||||
// All other data types are illegal
|
||||
else
|
||||
throw new SQLDialectNotSupportedException("Type " + type + " is not supported in dialect " + dialect);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user