[jOOQ/jOOQ#17708] Wrong SQL syntax generated for empty inserts of fetched records without any touched values

This commit is contained in:
Lukas Eder 2024-12-02 09:29:42 +01:00
parent c856b93ecd
commit 55aeb55387

View File

@ -183,7 +183,12 @@ implements
InsertQuery<R> insert = create.insertQuery(getTable());
List<Field<?>> changedFields = addTouchedValues(storeFields, insert, false);
if (changedFields.isEmpty()) {
// [#1596] Set timestamp and/or version columns to appropriate values
BigInteger version = addRecordVersion(insert, false);
Timestamp timestamp = addRecordTimestamp(insert, false);
// [#17708] DEFAULT VALUES applies only if we're not generating timestamp and/or version values!
if (changedFields.isEmpty() && version == null && timestamp == null) {
// Don't store records if no value was set by client code
if (FALSE.equals(create.settings().isInsertUnchangedRecords())) {
@ -197,10 +202,6 @@ implements
insert.setDefaultValues();
}
// [#1596] Set timestamp and/or version columns to appropriate values
BigInteger version = addRecordVersion(insert, false);
Timestamp timestamp = addRecordTimestamp(insert, false);
// [#814] Refresh identity and/or main unique key values
// [#1002] Consider also identity columns of non-updatable records
// [#1537] Avoid refreshing identity columns on batch inserts