[#8433] INSERT ... ON CONFLICT clause for SQLite

As of version 3.24.0 SQLite natively supports INSERT's ON CONFLICT
clause, which can thus also be used by jOOQ.

Note: SQLite doesn't support combining DEFAULT VALUES with ON CONFLICT.
And since SQLite does not support the DEFAULT keyword in INSERT the
DEFAULT VALUES clause cannot be emulated.
This commit is contained in:
Knut Wannheden 2019-04-18 10:48:37 +02:00
parent 861c4422c7
commit e24d186330
8 changed files with 81 additions and 74 deletions

View File

@ -39,6 +39,7 @@ package org.jooq;
// ...
import static org.jooq.SQLDialect.POSTGRES_9_5;
import static org.jooq.SQLDialect.SQLITE;
import org.jooq.impl.DSL;
@ -84,14 +85,14 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* Combine the currently assembled conditions with another one using the
* {@link Operator#AND} operator and proceed to the next step.
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> and(Field<Boolean> condition);
/**
@ -106,7 +107,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#condition(SQL)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> and(SQL sql);
@ -122,7 +123,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#condition(String)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> and(String sql);
@ -139,7 +140,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> and(String sql, Object... bindings);
@ -156,7 +157,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> and(String sql, QueryPart... parts);
@ -164,42 +165,42 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> andNot(Field<Boolean> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> or(Field<Boolean> condition);
/**
@ -214,7 +215,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#condition(SQL)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> or(SQL sql);
@ -230,7 +231,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#condition(String)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> or(String sql);
@ -247,7 +248,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> or(String sql, Object... bindings);
@ -264,7 +265,7 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support({ POSTGRES_9_5 })
@Support({ POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> or(String sql, QueryPart... parts);
@ -272,27 +273,27 @@ public interface InsertOnConflictConditionStep<R extends Record> extends InsertR
* 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> orNot(Field<Boolean> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> 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 })
@Support({ POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> orNotExists(Select<?> select);
}

View File

@ -46,6 +46,7 @@ import static org.jooq.SQLDialect.HSQLDB;
// ...
// ...
import static org.jooq.SQLDialect.POSTGRES_9_5;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
// ...
@ -59,6 +60,7 @@ import static org.jooq.SQLDialect.POSTGRES_9_5;
* create.insertInto(table, field1, field2)
* .values(value1, value2)
* .onConflict(field1)
* .doUpdate()
* .set(field2, value2)
* .execute();
* </pre></code>
@ -71,7 +73,7 @@ public interface InsertOnConflictDoUpdateStep<R extends Record> {
/**
* Add the <code>DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5, SQLITE })
InsertOnDuplicateSetStep<R> doUpdate();
/**

View File

@ -42,6 +42,7 @@ import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DERBY;
// ...
import static org.jooq.SQLDialect.POSTGRES_9_5;
import static org.jooq.SQLDialect.SQLITE;
// ...
import java.util.Collection;
@ -57,9 +58,10 @@ import org.jooq.impl.DSL;
* create.insertInto(table, field1, field2)
* .values(value1, value2)
* .values(value3, value4)
* .onDuplicateKeyUpdate()
* .set(field1, value1)
* .where(field2.eq(value5))
* .onConflict(field1)
* .doUpdate()
* .set(field2, value2)
* .where(field3.eq(value5))
* .execute();
* </pre></code>
* <p>
@ -89,7 +91,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* Add a <code>WHERE</code> clause to the <code>INSERT</code> statement's
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> where(Condition condition);
/**
@ -97,7 +99,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause,
* connecting them with each other using {@link Operator#AND}.
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> where(Condition... conditions);
/**
@ -105,14 +107,14 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause,
* connecting them with each other using {@link Operator#AND}.
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> where(Collection<? extends Condition> conditions);
/**
* Add a <code>WHERE</code> clause to the <code>INSERT</code> statement's
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> where(Field<Boolean> field);
/**
@ -127,7 +129,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#condition(SQL)
* @see SQL
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> where(SQL sql);
@ -143,7 +145,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#condition(String)
* @see SQL
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> where(String sql);
@ -160,7 +162,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> where(String sql, Object... bindings);
@ -177,7 +179,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
@PlainSQL
InsertOnConflictConditionStep<R> where(String sql, QueryPart... parts);
@ -185,13 +187,13 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* Add a <code>WHERE EXISTS</code> clause to the <code>INSERT</code> statement's
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> whereExists(Select<?> select);
/**
* Add a <code>WHERE NOT EXISTS</code> clause to the <code>INSERT</code> statement's
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
InsertOnConflictConditionStep<R> whereNotExists(Select<?> select);
}

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES_9_5;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
// ...
@ -95,21 +96,21 @@ public interface InsertOnDuplicateSetStep<R extends Record> {
* Set values for <code>UPDATE</code> in the <code>INSERT</code> statement's
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
<T> InsertOnDuplicateSetMoreStep<R> set(Field<T> field, T value);
/**
* Set values for <code>UPDATE</code> in the <code>INSERT</code> statement's
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
<T> InsertOnDuplicateSetMoreStep<R> set(Field<T> field, Field<T> value);
/**
* Set values for <code>UPDATE</code> in the <code>INSERT</code> statement's
* <code>ON DUPLICATE KEY UPDATE</code> or <code>ON CONFLICT ... DO UPDATE</code> clause.
*/
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
<T> InsertOnDuplicateSetMoreStep<R> set(Field<T> field, Select<? extends Record1<T>> value);
/**
@ -123,7 +124,7 @@ public interface InsertOnDuplicateSetStep<R extends Record> {
* <code>Field&lt;T&gt;</code>. jOOQ will attempt to convert values to their
* corresponding field's type.
*/
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
InsertOnDuplicateSetMoreStep<R> set(Map<?, ?> map);
/**
@ -135,7 +136,7 @@ public interface InsertOnDuplicateSetStep<R extends Record> {
*
* @see #set(Map)
*/
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
InsertOnDuplicateSetMoreStep<R> set(Record record);
}

View File

@ -50,6 +50,7 @@ import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES_9_5;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
@ -113,9 +114,9 @@ public interface InsertOnDuplicateStep<R extends Record> extends InsertReturning
/**
* Add an <code>ON CONFLICT</code> clause to this INSERT statement.
* <p>
* Only {@link SQLDialect#POSTGRES} has native support for this clause. The
* other dialects can emulate it using <code>MERGE</code>, if table meta
* data is available.
* Only {@link SQLDialect#POSTGRES} and {@link SQLDialect#SQLITE} have
* native support for this clause. The other dialects can emulate it using
* <code>MERGE</code>, if table meta data is available.
*/
@Support
InsertOnConflictDoUpdateStep<R> onConflict(Field<?>... keys);
@ -123,9 +124,9 @@ public interface InsertOnDuplicateStep<R extends Record> extends InsertReturning
/**
* Add an <code>ON CONFLICT</code> clause to this INSERT statement.
* <p>
* Only {@link SQLDialect#POSTGRES} has native support for this clause. The
* other dialects can emulate it using <code>MERGE</code>, if table meta
* data is available.
* Only {@link SQLDialect#POSTGRES} and {@link SQLDialect#SQLITE} have
* native support for this clause. The other dialects can emulate it using
* <code>MERGE</code>, if table meta data is available.
*/
@Support
InsertOnConflictDoUpdateStep<R> onConflict(Collection<? extends Field<?>> keys);
@ -133,9 +134,9 @@ public interface InsertOnDuplicateStep<R extends Record> extends InsertReturning
/**
* Add an <code>ON CONFLICT DO NOTHING</code> clause to this INSERT statement.
* <p>
* Only {@link SQLDialect#POSTGRES} has native support for this clause. The
* other dialects can emulate it using <code>MERGE</code>, if table meta
* data is available.
* Only {@link SQLDialect#POSTGRES} and {@link SQLDialect#SQLITE} have
* native support for this clause. The other dialects can emulate it using
* <code>MERGE</code>, if table meta data is available.
*/
@Support
InsertReturningStep<R> onConflictDoNothing();
@ -160,7 +161,7 @@ public interface InsertOnDuplicateStep<R extends Record> extends InsertReturning
* <p>
* H2 supports this clause in MySQL mode.
*/
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
InsertOnDuplicateSetStep<R> onDuplicateKeyUpdate();
/**
@ -183,7 +184,7 @@ public interface InsertOnDuplicateStep<R extends Record> extends InsertReturning
* <td><code><pre>INSERT IGNORE INTO ..</pre></code></td>
* </tr>
* <tr>
* <td>{@link SQLDialect#POSTGRES_9_5}</td>
* <td>{@link SQLDialect#POSTGRES_9_5} and {@link SQLDialect#SQLITE}</td>
* <td><code><pre>INSERT INTO .. ON CONFLICT DO NOTHING</pre></code></td>
* </tr>
* <tr>

View File

@ -130,7 +130,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
void onConflict(Collection<? extends Field<?>> fields);
/**
* Whether use a <code>On CONFLICT</code> or
* Whether use a <code>ON CONFLICT</code> or
* <code>ON CONFLICT ON CONSTRAINT</code> clause in this <code>INSERT</code>
* statement.
*/
@ -138,7 +138,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
void onConflictOnConstraint(Name constraint);
/**
* Whether use a <code>On CONFLICT</code> or
* Whether use a <code>ON CONFLICT</code> or
* <code>ON CONFLICT ON CONSTRAINT</code> clause in this <code>INSERT</code>
* statement.
*/
@ -146,7 +146,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
void onConflictOnConstraint(Constraint constraint);
/**
* Whether use a <code>On CONFLICT</code> or
* Whether use a <code>ON CONFLICT</code> or
* <code>ON CONFLICT ON CONSTRAINT</code> clause in this <code>INSERT</code>
* statement.
*/
@ -166,7 +166,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @see InsertOnDuplicateStep#onDuplicateKeyUpdate()
*/
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
void onDuplicateKeyUpdate(boolean flag);
/**
@ -185,7 +185,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
* <td><code><pre>INSERT IGNORE INTO ..</pre></code></td>
* </tr>
* <tr>
* <td>{@link SQLDialect#POSTGRES_9_5}</td>
* <td>{@link SQLDialect#POSTGRES_9_5} and {@link SQLDialect#SQLITE}</td>
* <td><code><pre>INSERT INTO .. ON CONFLICT DO NOTHING</pre></code></td>
* </tr>
* <tr>
@ -230,7 +230,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @see InsertOnDuplicateStep#onDuplicateKeyUpdate()
*/
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
<T> void addValueForUpdate(Field<T> field, T value);
/**
@ -239,7 +239,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @see InsertOnDuplicateStep#onDuplicateKeyUpdate()
*/
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
<T> void addValueForUpdate(Field<T> field, Field<T> value);
/**
@ -252,7 +252,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @see InsertOnDuplicateStep#onDuplicateKeyUpdate()
*/
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
void addValuesForUpdate(Map<?, ?> map);
/**
@ -264,7 +264,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @param condition The condition
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
void addConditions(Condition condition);
/**
@ -276,7 +276,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @param conditions The condition
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
void addConditions(Condition... conditions);
/**
@ -288,7 +288,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @param conditions The condition
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
void addConditions(Collection<? extends Condition> conditions);
/**
@ -300,7 +300,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @param condition The condition
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
void addConditions(Operator operator, Condition condition);
/**
@ -312,7 +312,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @param conditions The condition
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
void addConditions(Operator operator, Condition... conditions);
/**
@ -324,7 +324,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @param conditions The condition
*/
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5, SQLITE })
void addConditions(Operator operator, Collection<? extends Condition> conditions);
/**

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES_9_5;
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
// ...
@ -108,7 +109,7 @@ public interface LoaderOptionsStep<R extends Record> extends LoaderSourceStep<R>
* the default. This cannot be combined with {@link #onDuplicateKeyError()}
* or {@link #onDuplicateKeyIgnore()}
*/
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5, SQLITE })
LoaderOptionsStep<R> onDuplicateKeyUpdate();
/**

View File

@ -69,7 +69,6 @@ import static org.jooq.impl.Keywords.K_INTO;
import static org.jooq.impl.Keywords.K_ON_CONFLICT;
import static org.jooq.impl.Keywords.K_ON_CONSTRAINT;
import static org.jooq.impl.Keywords.K_ON_DUPLICATE_KEY_UPDATE;
import static org.jooq.impl.Keywords.K_OR;
import static org.jooq.impl.Keywords.K_SET;
import static org.jooq.impl.Keywords.K_VALUES;
import static org.jooq.impl.Keywords.K_WHERE;
@ -327,7 +326,8 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
case POSTGRES: {
case POSTGRES:
case SQLITE: {
toSQLInsert(ctx);
ctx.formatSeparator()
.start(INSERT_ON_DUPLICATE_KEY_UPDATE)
@ -418,8 +418,7 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
case MARIADB:
case MYSQL_5_7:
case MYSQL_8_0:
case MYSQL:
case SQLITE: {
case MYSQL: {
toSQLInsert(ctx);
ctx.start(INSERT_ON_DUPLICATE_KEY_UPDATE)
.end(INSERT_ON_DUPLICATE_KEY_UPDATE);
@ -432,7 +431,8 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
case POSTGRES_9_5:
case POSTGRES_10:
case POSTGRES_11:
case POSTGRES: {
case POSTGRES:
case SQLITE: {
toSQLInsert(ctx);
ctx.formatSeparator()
.start(INSERT_ON_DUPLICATE_KEY_UPDATE)
@ -543,13 +543,12 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
.visit(K_INSERT)
.sql(' ');
// [#1295] [#4376] MySQL and SQLite have native syntaxes for
// INSERT [ OR ] IGNORE
// [#1295] MySQL dialects have native syntax for INSERT IGNORE
// [#4376] [#8433] for SQLite render using ON CONFLICT DO NOTHING
// rather than INSERT OR IGNORE
if (onDuplicateKeyIgnore)
if (SUPPORT_INSERT_IGNORE.contains(ctx.family()))
ctx.visit(K_IGNORE).sql(' ');
else if (SQLDialect.SQLITE == ctx.family())
ctx.visit(K_OR).sql(' ').visit(K_IGNORE).sql(' ');
ctx.visit(K_INTO)
.sql(' ')