[jOOQ/jOOQ#11015] CockroachDB needs more fixing

See: https://github.com/cockroachdb/cockroach/issues/98122. To play safe, we're casting all null literals and bind values of unknown type to the known column type in VALUES()
This commit is contained in:
Lukas Eder 2023-03-07 09:49:03 +01:00
parent 275df337f3
commit 54bc17d766

View File

@ -207,11 +207,11 @@ implements
}
private final Row castNullLiteralToRowType(Context<?> ctx, Row row) {
if (anyMatch(row.fields(), f -> rendersNullLiteral(ctx, f))) {
if (anyMatch(row.fields(), f -> nullLiteralOrUntypedNullBind(ctx, f))) {
Field<?>[] result = new Field[row.size()];
for (int i = 0; i < result.length; i++)
if (rendersNullLiteral(ctx, row.field(i)) && rowType()[i].getType() != Object.class)
if (nullLiteralOrUntypedNullBind(ctx, row.field(i)) && rowType()[i].getType() != Object.class)
result[i] = row.field(i).cast(rowType()[i]);
else
result[i] = row.field(i);
@ -222,8 +222,10 @@ implements
return row;
}
private final boolean rendersNullLiteral(Context<?> ctx, Field<?> field) {
return isVal(field) && ((Val<?>) field).getValue() == null && ((Val<?>) field).isInline(ctx)
private final boolean nullLiteralOrUntypedNullBind(Context<?> ctx, Field<?> field) {
return isVal(field)
&& ((Val<?>) field).getValue() == null
&& (((Val<?>) field).isInline(ctx) || field.getType() == Object.class)
|| field instanceof NullCondition;
}