[jOOQ/jOOQ#7912] Add InsertOnDuplicateSetStep::setAllToExcluded to auto-set all insert column list columns to their EXCLUDED value
This commit is contained in:
parent
b650db1f0d
commit
b8fcf22fb9
@ -63,6 +63,8 @@ import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -172,4 +174,12 @@ public interface InsertOnDuplicateSetStep<R extends Record> {
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
InsertOnDuplicateSetMoreStep<R> set(Record record);
|
||||
|
||||
/**
|
||||
* Sets all columns from the insert column list to
|
||||
* {@link DSL#excluded(Field)}.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB })
|
||||
InsertOnDuplicateSetMoreStep<R> setAllToExcluded();
|
||||
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.excluded;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.not;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
@ -139,6 +140,8 @@ import org.jooq.SelectFieldOrAsterisk;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.UniqueKey;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
@ -1232,6 +1235,14 @@ final class InsertImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
return set(Tools.mapOfChangedValues(record));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final InsertImpl setAllToExcluded() {
|
||||
for (Field<?> field : fields)
|
||||
set(field, (Field) excluded(field));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final InsertImpl and(Condition condition) {
|
||||
getDelegate().addConditions(condition);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user