[jOOQ/jOOQ#15685] Emulate DEFAULT expression in multi row INSERT .. VALUES, where that is emulated with INSERT .. SELECT

This commit is contained in:
Lukas Eder 2023-10-05 14:25:58 +02:00
parent 0d83a4894a
commit b82c6a3e91

View File

@ -412,7 +412,9 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
for (int i = 0; i < rows; i++) {
int row = i;
Select<Record> iteration = DSL.select(Tools.map(v.values(), l -> castNullsIfNeeded(ctx, needsCast, l.get(row))));
Select<Record> iteration = DSL.select(Tools.map(
v.entrySet(), e -> patchDefault0(castNullsIfNeeded(ctx, needsCast, e.getValue().get(row)), e.getKey())
));
if (select == null)
select = iteration;
@ -507,6 +509,13 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
return d;
}
private final Field<?> patchDefault0(Field<?> d, Field<?> f) {
if (d instanceof Default)
return orElse(f.getDataType().default_(), () -> DSL.inline(null, f));
return d;
}