diff --git a/jOOQ/src/main/java/org/jooq/InsertOnConflictConditionStep.java b/jOOQ/src/main/java/org/jooq/InsertOnConflictConditionStep.java
new file mode 100644
index 0000000000..1ca3bca273
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/InsertOnConflictConditionStep.java
@@ -0,0 +1,275 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq;
+
+import static org.jooq.SQLDialect.POSTGRES_9_5;
+
+import org.jooq.impl.DSL;
+
+/**
+ * This type is used for the {@link Insert}'s DSL API.
+ *
+ * Example:
+ * DSLContext create = DSL.using(configuration);
+ *
+ * create.insertInto(table, field1, field2)
+ * .values(value1, value2)
+ * .values(value3, value4)
+ * .onDuplicateKeyUpdate()
+ * .set(field1, value1)
+ * .set(field2, value2)
+ * .execute();
+ *
+ *
+ * @author Lukas Eder
+ */
+public interface InsertOnConflictConditionStep extends InsertFinalStep {
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#AND} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep and(Condition condition);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#AND} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep and(Field condition);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#AND} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(SQL)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep and(SQL sql);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#AND} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep and(String sql);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#AND} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String, Object...)
+ * @see DSL#sql(String, Object...)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep and(String sql, Object... bindings);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#AND} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String, QueryPart...)
+ * @see DSL#sql(String, QueryPart...)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep and(String sql, QueryPart... parts);
+
+ /**
+ * Combine the currently assembled conditions with a negated other one using
+ * the {@link Operator#AND} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep andNot(Condition condition);
+
+ /**
+ * Combine the currently assembled conditions with a negated other one using
+ * the {@link Operator#AND} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep andNot(Field condition);
+
+ /**
+ * Combine the currently assembled conditions with an EXISTS clause using
+ * the {@link Operator#AND} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep andExists(Select> select);
+
+ /**
+ * Combine the currently assembled conditions with a NOT EXISTS clause using
+ * the {@link Operator#AND} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep andNotExists(Select> select);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#OR} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep or(Condition condition);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#OR} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep or(Field condition);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#OR} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(SQL)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep or(SQL sql);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#OR} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep or(String sql);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#OR} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String, Object...)
+ * @see DSL#sql(String, Object...)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep or(String sql, Object... bindings);
+
+ /**
+ * Combine the currently assembled conditions with another one using the
+ * {@link Operator#OR} operator and proceed to the next step.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String, QueryPart...)
+ * @see DSL#sql(String, QueryPart...)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertOnConflictConditionStep or(String sql, QueryPart... parts);
+
+ /**
+ * Combine the currently assembled conditions with a negated other one using
+ * the {@link Operator#OR} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep orNot(Condition condition);
+
+ /**
+ * Combine the currently assembled conditions with a negated other one using
+ * the {@link Operator#OR} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep orNot(Field condition);
+
+ /**
+ * Combine the currently assembled conditions with an EXISTS clause using
+ * the {@link Operator#OR} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep orExists(Select> select);
+
+ /**
+ * Combine the currently assembled conditions with a NOT EXISTS clause using
+ * the {@link Operator#OR} operator and proceed to the next step.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertOnConflictConditionStep orNotExists(Select> select);
+}
diff --git a/jOOQ/src/main/java/org/jooq/InsertOnConflictWhereStep.java b/jOOQ/src/main/java/org/jooq/InsertOnConflictWhereStep.java
new file mode 100644
index 0000000000..c09688c0a7
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/InsertOnConflictWhereStep.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq;
+
+import static org.jooq.SQLDialect.POSTGRES_9_5;
+
+import java.util.Collection;
+
+import org.jooq.impl.DSL;
+
+/**
+ * This type is used for the {@link Insert}'s DSL API.
+ *
+ * Example:
+ * DSLContext create = DSL.using(configuration);
+ *
+ * create.insertInto(table, field1, field2)
+ * .values(value1, value2)
+ * .values(value3, value4)
+ * .onDuplicateKeyUpdate()
+ * .set(field1, value1)
+ * .set(field2, value2)
+ * .execute();
+ *
+ *
+ * @author Lukas Eder
+ */
+public interface InsertOnConflictWhereStep extends InsertFinalStep {
+
+ /**
+ * Add a WHERE clause to the query, connecting them with each
+ * other with {@link Operator#AND}.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertFinalStep where(Condition... conditions);
+
+ /**
+ * Add a WHERE clause to the query, connecting them with each
+ * other with {@link Operator#AND}.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertFinalStep where(Collection extends Condition> conditions);
+
+ /**
+ * Add a WHERE clause to the query.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertFinalStep where(Field field);
+
+ /**
+ * Add a WHERE clause to the query.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(SQL)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertFinalStep where(SQL sql);
+
+ /**
+ * Add a WHERE clause to the query.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertFinalStep where(String sql);
+
+ /**
+ * Add a WHERE clause to the query.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String, Object...)
+ * @see DSL#sql(String, Object...)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertFinalStep where(String sql, Object... bindings);
+
+ /**
+ * Add a WHERE clause to the query.
+ *
+ * NOTE: When inserting plain SQL into jOOQ objects, you must
+ * guarantee syntax integrity. You may also create the possibility of
+ * malicious SQL injection. Be sure to properly use bind variables and/or
+ * escape literals when concatenated into SQL clauses!
+ *
+ * @see DSL#condition(String, QueryPart...)
+ * @see DSL#sql(String, QueryPart...)
+ * @see SQL
+ */
+ @Support({ POSTGRES_9_5 })
+ @PlainSQL
+ InsertFinalStep where(String sql, QueryPart... parts);
+
+ /**
+ * Add a WHERE EXISTS clause to the query.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertFinalStep whereExists(Select> select);
+
+ /**
+ * Add a WHERE NOT EXISTS clause to the query.
+ */
+ @Support({ POSTGRES_9_5 })
+ InsertFinalStep whereNotExists(Select> select);
+}
diff --git a/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetMoreStep.java b/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetMoreStep.java
index 56507a73f5..dc261e6974 100644
--- a/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetMoreStep.java
+++ b/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetMoreStep.java
@@ -51,6 +51,6 @@ package org.jooq;
*
* @author Lukas Eder
*/
-public interface InsertOnDuplicateSetMoreStep extends InsertOnDuplicateSetStep, InsertFinalStep {
+public interface InsertOnDuplicateSetMoreStep extends InsertOnDuplicateSetStep, InsertOnConflictWhereStep {
}
diff --git a/jOOQ/src/main/java/org/jooq/InsertQuery.java b/jOOQ/src/main/java/org/jooq/InsertQuery.java
index 9081293bfe..639232dd1d 100644
--- a/jOOQ/src/main/java/org/jooq/InsertQuery.java
+++ b/jOOQ/src/main/java/org/jooq/InsertQuery.java
@@ -216,6 +216,54 @@ public interface InsertQuery extends StoreQuery, Insert
@Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
void addValuesForUpdate(Map extends Field>, ?> map);
+ /**
+ * Adds new conditions to the query, connecting them to existing conditions
+ * with {@link Operator#AND}.
+ *
+ * This is for use with {@link SQLDialect#POSTGRES}'s
+ * {@link #onConflict(Field...)} clause.
+ *
+ * @param conditions The condition
+ */
+ @Support({ POSTGRES_9_5 })
+ void addConditions(Condition... conditions);
+
+ /**
+ * Adds new conditions to the query, connecting them to existing
+ * conditions with {@link Operator#AND}.
+ *
+ * This is for use with {@link SQLDialect#POSTGRES}'s
+ * {@link #onConflict(Field...)} clause.
+ *
+ * @param conditions The condition
+ */
+ @Support({ POSTGRES_9_5 })
+ void addConditions(Collection extends Condition> conditions);
+
+ /**
+ * Adds new conditions to the query, connecting them to existing
+ * conditions with the provided operator.
+ *
+ * This is for use with {@link SQLDialect#POSTGRES}'s
+ * {@link #onConflict(Field...)} clause.
+ *
+ * @param conditions The condition
+ */
+ @Support({ POSTGRES_9_5 })
+ void addConditions(Operator operator, Condition... conditions);
+
+ /**
+ * Adds new conditions to the query, connecting them to existing
+ * conditions with the provided operator.
+ *
+ * This is for use with {@link SQLDialect#POSTGRES}'s
+ * {@link #onConflict(Field...)} clause.
+ *
+ * @param conditions The condition
+ */
+ @Support({ POSTGRES_9_5 })
+ void addConditions(Operator operator, Collection extends Condition> conditions);
+
/**
* Set an empty record with the DEFAULT VALUES clause.
*/
diff --git a/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java b/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java
index 417ab0118c..8c625db1f6 100644
--- a/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java
+++ b/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java
@@ -34,6 +34,10 @@
*/
package org.jooq.impl;
+import static org.jooq.impl.DSL.condition;
+import static org.jooq.impl.DSL.exists;
+import static org.jooq.impl.DSL.not;
+import static org.jooq.impl.DSL.notExists;
import static org.jooq.impl.Tools.EMPTY_FIELD;
import java.util.Arrays;
@@ -44,16 +48,26 @@ import java.util.Optional;
import javax.annotation.Generated;
+import org.jooq.Condition;
import org.jooq.Configuration;
import org.jooq.Field;
import org.jooq.FieldLike;
-import org.jooq.InsertOnConflictDoUpdateStep;
import org.jooq.InsertOnDuplicateSetMoreStep;
+import org.jooq.InsertOnConflictConditionStep;
+import org.jooq.InsertOnConflictDoUpdateStep;
import org.jooq.InsertQuery;
import org.jooq.InsertResultStep;
import org.jooq.InsertSetMoreStep;
import org.jooq.InsertSetStep;
import org.jooq.InsertValuesStep1;
+import org.jooq.InsertValuesStep2;
+import org.jooq.InsertValuesStep3;
+import org.jooq.InsertValuesStep4;
+import org.jooq.InsertValuesStep5;
+import org.jooq.InsertValuesStep6;
+import org.jooq.InsertValuesStep7;
+import org.jooq.InsertValuesStep8;
+import org.jooq.InsertValuesStep9;
import org.jooq.InsertValuesStep10;
import org.jooq.InsertValuesStep11;
import org.jooq.InsertValuesStep12;
@@ -64,22 +78,17 @@ import org.jooq.InsertValuesStep16;
import org.jooq.InsertValuesStep17;
import org.jooq.InsertValuesStep18;
import org.jooq.InsertValuesStep19;
-import org.jooq.InsertValuesStep2;
import org.jooq.InsertValuesStep20;
import org.jooq.InsertValuesStep21;
import org.jooq.InsertValuesStep22;
-import org.jooq.InsertValuesStep3;
-import org.jooq.InsertValuesStep4;
-import org.jooq.InsertValuesStep5;
-import org.jooq.InsertValuesStep6;
-import org.jooq.InsertValuesStep7;
-import org.jooq.InsertValuesStep8;
-import org.jooq.InsertValuesStep9;
import org.jooq.InsertValuesStepN;
+import org.jooq.Operator;
+import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Result;
import org.jooq.Select;
+import org.jooq.SQL;
import org.jooq.Table;
/**
@@ -119,6 +128,7 @@ class InsertImpl,
InsertOnDuplicateSetMoreStep,
InsertOnConflictDoUpdateStep,
+ InsertOnConflictConditionStep,
InsertResultStep {
/**
@@ -658,6 +668,155 @@ class InsertImpl condition) {
+ return and(condition(condition));
+ }
+
+ @Override
+ public final InsertImpl and(SQL sql) {
+ return and(condition(sql));
+ }
+
+ @Override
+ public final InsertImpl and(String sql) {
+ return and(condition(sql));
+ }
+
+ @Override
+ public final InsertImpl and(String sql, Object... bindings) {
+ return and(condition(sql, bindings));
+ }
+
+ @Override
+ public final InsertImpl and(String sql, QueryPart... parts) {
+ return and(condition(sql, parts));
+ }
+
+ @Override
+ public final InsertImpl andNot(Condition condition) {
+ return and(not(condition));
+ }
+
+ @Override
+ public final InsertImpl andNot(Field condition) {
+ return and(not(condition(condition)));
+ }
+
+ @Override
+ public final InsertImpl andExists(Select> select) {
+ return and(exists(select));
+ }
+
+ @Override
+ public final InsertImpl andNotExists(Select> select) {
+ return and(notExists(select));
+ }
+
+ @Override
+ public final InsertImpl or(Condition condition) {
+ getDelegate().addConditions(Operator.OR, condition);
+ return this;
+ }
+
+ @Override
+ public final InsertImpl or(Field condition) {
+ return or(condition(condition));
+ }
+
+ @Override
+ public final InsertImpl or(SQL sql) {
+ return or(condition(sql));
+ }
+
+ @Override
+ public final InsertImpl or(String sql) {
+ return or(condition(sql));
+ }
+
+ @Override
+ public final InsertImpl or(String sql, Object... bindings) {
+ return or(condition(sql, bindings));
+ }
+
+ @Override
+ public final InsertImpl or(String sql, QueryPart... parts) {
+ return or(condition(sql, parts));
+ }
+
+ @Override
+ public final InsertImpl orNot(Condition condition) {
+ return or(not(condition));
+ }
+
+ @Override
+ public final InsertImpl orNot(Field condition) {
+ return or(not(condition(condition)));
+ }
+
+ @Override
+ public final InsertImpl orExists(Select> select) {
+ return or(exists(select));
+ }
+
+ @Override
+ public final InsertImpl orNotExists(Select> select) {
+ return or(notExists(select));
+ }
+
+ @Override
+ public final InsertImpl where(Condition... conditions) {
+ getDelegate().addConditions(conditions);
+ return this;
+ }
+
+ @Override
+ public final InsertImpl where(Collection extends Condition> conditions) {
+ getDelegate().addConditions(conditions);
+ return this;
+ }
+
+ @Override
+ public final InsertImpl where(Field field) {
+ return where(condition(field));
+ }
+
+ @Override
+ public final InsertImpl where(SQL sql) {
+ return where(condition(sql));
+ }
+
+ @Override
+ public final InsertImpl where(String sql) {
+ return where(condition(sql));
+ }
+
+ @Override
+ public final InsertImpl where(String sql, Object... bindings) {
+ return where(condition(sql, bindings));
+ }
+
+ @Override
+ public final InsertImpl where(String sql, QueryPart... parts) {
+ return where(condition(sql, parts));
+ }
+
+ @Override
+ public final InsertImpl whereExists(Select> select) {
+ return where(exists(select));
+ }
+
+ @Override
+ public final InsertImpl whereNotExists(Select> select) {
+ return where(notExists(select));
+ }
+
@Override
public final InsertImpl newRecord() {
getDelegate().newRecord();
diff --git a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java
index da64809104..50b21d3636 100644
--- a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java
+++ b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java
@@ -66,6 +66,7 @@ import org.jooq.InsertQuery;
import org.jooq.Merge;
import org.jooq.MergeNotMatchedStep;
import org.jooq.MergeOnConditionStep;
+import org.jooq.Operator;
import org.jooq.QueryPart;
import org.jooq.Record;
import org.jooq.SQLDialect;
@@ -78,22 +79,24 @@ import org.jooq.exception.SQLDialectNotSupportedException;
*/
final class InsertQueryImpl extends AbstractStoreQuery implements InsertQuery {
- private static final long serialVersionUID = 4466005417945353842L;
- private static final Clause[] CLAUSES = { INSERT };
+ private static final long serialVersionUID = 4466005417945353842L;
+ private static final Clause[] CLAUSES = { INSERT };
- private final FieldMapForUpdate updateMap;
- private final FieldMapsForInsert insertMaps;
- private Select> select;
- private boolean defaultValues;
- private boolean onDuplicateKeyUpdate;
- private boolean onDuplicateKeyIgnore;
- private QueryPartList> onConflict;
+ private final FieldMapForUpdate updateMap;
+ private final FieldMapsForInsert insertMaps;
+ private Select> select;
+ private boolean defaultValues;
+ private boolean onDuplicateKeyUpdate;
+ private boolean onDuplicateKeyIgnore;
+ private QueryPartList> onConflict;
+ private final ConditionProviderImpl condition;
InsertQueryImpl(Configuration configuration, WithImpl with, Table into) {
super(configuration, with, into);
this.updateMap = new FieldMapForUpdate(INSERT_ON_DUPLICATE_KEY_UPDATE_ASSIGNMENT);
this.insertMaps = new FieldMapsForInsert();
+ this.condition = new ConditionProviderImpl();
}
@Override
@@ -149,6 +152,26 @@ final class InsertQueryImpl extends AbstractStoreQuery impl
updateMap.set(map);
}
+ @Override
+ public final void addConditions(Condition... conditions) {
+ condition.addConditions(conditions);
+ }
+
+ @Override
+ public final void addConditions(Collection extends Condition> conditions) {
+ condition.addConditions(conditions);
+ }
+
+ @Override
+ public final void addConditions(Operator operator, Condition... conditions) {
+ condition.addConditions(operator, conditions);
+ }
+
+ @Override
+ public final void addConditions(Operator operator, Collection extends Condition> conditions) {
+ condition.addConditions(operator, conditions);
+ }
+
@Override
public final void setDefaultValues() {
defaultValues = true;
@@ -222,8 +245,15 @@ final class InsertQueryImpl extends AbstractStoreQuery impl
.sql(' ')
.formatIndentLockStart()
.visit(updateMap)
- .formatIndentLockEnd()
- .end(INSERT_ON_DUPLICATE_KEY_UPDATE);
+ .formatIndentLockEnd();
+
+ if (!(condition.getWhere() instanceof TrueCondition))
+ ctx.formatSeparator()
+ .keyword("where")
+ .sql(' ')
+ .visit(condition);
+
+ ctx.end(INSERT_ON_DUPLICATE_KEY_UPDATE);
break;
}