[jOOQ/jOOQ#8744] H2: Support INSERT ... ON CONFLICT DO UPDATE
Support this clause by emulating it with MERGE.
This commit is contained in:
parent
6dfd51a8ca
commit
3726b347b4
@ -42,6 +42,7 @@ import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
// ...
|
||||
@ -73,7 +74,7 @@ public interface InsertOnConflictDoUpdateStep<R extends Record> {
|
||||
/**
|
||||
* Add the <code>DO UPDATE</code> clause.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, HSQLDB, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES, SQLITE })
|
||||
InsertOnDuplicateSetStep<R> doUpdate();
|
||||
|
||||
/**
|
||||
|
||||
@ -40,6 +40,7 @@ package org.jooq;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
@ -91,7 +92,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, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
InsertOnConflictConditionStep<R> where(Condition condition);
|
||||
|
||||
/**
|
||||
@ -99,7 +100,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, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
InsertOnConflictConditionStep<R> where(Condition... conditions);
|
||||
|
||||
/**
|
||||
@ -107,14 +108,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, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, 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, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
InsertOnConflictConditionStep<R> where(Field<Boolean> field);
|
||||
|
||||
/**
|
||||
@ -129,7 +130,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
|
||||
* @see DSL#condition(SQL)
|
||||
* @see SQL
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
@PlainSQL
|
||||
InsertOnConflictConditionStep<R> where(SQL sql);
|
||||
|
||||
@ -145,7 +146,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
|
||||
* @see DSL#condition(String)
|
||||
* @see SQL
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
@PlainSQL
|
||||
InsertOnConflictConditionStep<R> where(String sql);
|
||||
|
||||
@ -162,7 +163,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
|
||||
* @see DSL#sql(String, Object...)
|
||||
* @see SQL
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
@PlainSQL
|
||||
InsertOnConflictConditionStep<R> where(String sql, Object... bindings);
|
||||
|
||||
@ -179,7 +180,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
|
||||
* @see DSL#sql(String, QueryPart...)
|
||||
* @see SQL
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
@PlainSQL
|
||||
InsertOnConflictConditionStep<R> where(String sql, QueryPart... parts);
|
||||
|
||||
|
||||
@ -265,7 +265,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
|
||||
*
|
||||
* @param condition The condition
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
void addConditions(Condition condition);
|
||||
|
||||
/**
|
||||
@ -277,7 +277,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
void addConditions(Condition... conditions);
|
||||
|
||||
/**
|
||||
@ -289,7 +289,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
void addConditions(Collection<? extends Condition> conditions);
|
||||
|
||||
/**
|
||||
@ -301,7 +301,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
|
||||
*
|
||||
* @param condition The condition
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
void addConditions(Operator operator, Condition condition);
|
||||
|
||||
/**
|
||||
@ -313,7 +313,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
void addConditions(Operator operator, Condition... conditions);
|
||||
|
||||
/**
|
||||
@ -325,7 +325,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
|
||||
*
|
||||
* @param conditions The condition
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, POSTGRES, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, POSTGRES, SQLITE })
|
||||
void addConditions(Operator operator, Collection<? extends Condition> conditions);
|
||||
|
||||
/**
|
||||
|
||||
@ -42,6 +42,7 @@ package org.jooq;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
@ -110,7 +111,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, SQLITE })
|
||||
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
LoaderOptionsStep<R> onDuplicateKeyUpdate();
|
||||
|
||||
/**
|
||||
|
||||
@ -294,7 +294,6 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
|
||||
|
||||
|
||||
case CUBRID:
|
||||
case H2:
|
||||
case MARIADB:
|
||||
case MYSQL: {
|
||||
|
||||
@ -402,6 +401,7 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
|
||||
|
||||
|
||||
case DERBY:
|
||||
case H2:
|
||||
case HSQLDB: {
|
||||
ctx.visit(toMerge(ctx.configuration()));
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user