[jOOQ/jOOQ#15582] MariaDB UPDATE .. RETURNING emulation should work on tables with unique constraints only

This commit is contained in:
Lukas Eder 2023-09-19 16:38:30 +02:00
parent 68dc0f4ce5
commit 9f1b86a1a0

View File

@ -566,7 +566,13 @@ implements
acceptFromAsMerge(ctx);
return;
}
else if (!returning.isEmpty() && EMULATE_RETURNING_WITH_UPSERT.contains(ctx.dialect())) {
else if (!returning.isEmpty()
&& EMULATE_RETURNING_WITH_UPSERT.contains(ctx.dialect())
&& table instanceof TableImpl
// [#15582] This implementation should be done only for plain SQL templates
// or generated code with at least one known unique key
&& (((TableImpl<?>) table).fields.fields.length == 0 || !table.getKeys().isEmpty())) {
acceptReturningAsUpsert(ctx);
return;
}