[#8333] Support INSERT .. ON ( DUPLICATE KEY | CONFLICT ) in Derby

This commit is contained in:
lukaseder 2019-02-18 09:29:04 +01:00
parent 2eb488aab1
commit 8cbd0208b3
7 changed files with 31 additions and 25 deletions

View File

@ -40,6 +40,7 @@ package org.jooq;
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD_3_0;
import static org.jooq.SQLDialect.HSQLDB;
// ...
@ -71,7 +72,7 @@ public interface InsertOnConflictDoUpdateStep<R extends Record> {
/**
* Add the <code>DO UPDATE</code> clause.
*/
@Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
InsertOnDuplicateSetStep<R> doUpdate();
/**

View File

@ -39,6 +39,7 @@ package org.jooq;
// ...
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DERBY;
// ...
import static org.jooq.SQLDialect.POSTGRES_9_5;
// ...
@ -88,27 +89,27 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* Add a <code>WHERE</code> clause to the query, connecting them with each
* other with {@link Operator#AND}.
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
InsertReturningStep<R> where(Condition condition);
/**
* Add a <code>WHERE</code> clause to the query, connecting them with each
* other with {@link Operator#AND}.
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
InsertReturningStep<R> where(Condition... conditions);
/**
* Add a <code>WHERE</code> clause to the query, connecting them with each
* other with {@link Operator#AND}.
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
InsertReturningStep<R> where(Collection<? extends Condition> conditions);
/**
* Add a <code>WHERE</code> clause to the query.
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
InsertReturningStep<R> where(Field<Boolean> field);
/**
@ -122,7 +123,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#condition(SQL)
* @see SQL
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@PlainSQL
InsertReturningStep<R> where(SQL sql);
@ -137,7 +138,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#condition(String)
* @see SQL
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@PlainSQL
InsertReturningStep<R> where(String sql);
@ -153,7 +154,7 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#sql(String, Object...)
* @see SQL
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@PlainSQL
InsertReturningStep<R> where(String sql, Object... bindings);
@ -169,19 +170,19 @@ public interface InsertOnConflictWhereStep<R extends Record> extends InsertRetur
* @see DSL#sql(String, QueryPart...)
* @see SQL
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
@PlainSQL
InsertReturningStep<R> where(String sql, QueryPart... parts);
/**
* Add a <code>WHERE EXISTS</code> clause to the query.
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
InsertReturningStep<R> whereExists(Select<?> select);
/**
* Add a <code>WHERE NOT EXISTS</code> clause to the query.
*/
@Support({ CUBRID, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, POSTGRES_9_5 })
InsertReturningStep<R> whereNotExists(Select<?> select);
}

View File

@ -41,6 +41,7 @@ package org.jooq;
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
@ -93,21 +94,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> clause.
*/
@Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
<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> clause.
*/
@Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
<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> clause.
*/
@Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
<T> InsertOnDuplicateSetMoreStep<R> set(Field<T> field, Select<? extends Record1<T>> value);
/**
@ -121,7 +122,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, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
InsertOnDuplicateSetMoreStep<R> set(Map<?, ?> map);
/**
@ -133,7 +134,7 @@ public interface InsertOnDuplicateSetStep<R extends Record> {
*
* @see #set(Map)
*/
@Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
InsertOnDuplicateSetMoreStep<R> set(Record record);
}

View File

@ -41,6 +41,7 @@ package org.jooq;
// ...
import static org.jooq.SQLDialect.CUBRID;
// ...
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD_3_0;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.HSQLDB;
@ -94,13 +95,13 @@ public interface InsertOnDuplicateStep<R extends Record> extends InsertReturning
/**
* Add a <code>ON CONFLICT ON CONSTRAINT</code> clause to this query.
*/
@Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
InsertOnConflictDoUpdateStep<R> onConflictOnConstraint(Constraint constraint);
/**
* Add a <code>ON CONFLICT ON CONSTRAINT</code> clause to this query.
*/
@Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
InsertOnConflictDoUpdateStep<R> onConflictOnConstraint(Name constraint);
/**

View File

@ -134,7 +134,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
* <code>ON CONFLICT ON CONSTRAINT</code> clause in this <code>INSERT</code>
* statement.
*/
@Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
void onConflictOnConstraint(Name constraint);
/**
@ -142,7 +142,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
* <code>ON CONFLICT ON CONSTRAINT</code> clause in this <code>INSERT</code>
* statement.
*/
@Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 })
void onConflictOnConstraint(Constraint constraint);
/**
@ -166,7 +166,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @see InsertOnDuplicateStep#onDuplicateKeyUpdate()
*/
@Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
void onDuplicateKeyUpdate(boolean flag);
/**
@ -230,7 +230,7 @@ public interface InsertQuery<R extends Record> extends StoreQuery<R>, Insert<R>
*
* @see InsertOnDuplicateStep#onDuplicateKeyUpdate()
*/
@Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
<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, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
<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, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
@Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 })
void addValuesForUpdate(Map<?, ?> map);
/**

View File

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

View File

@ -495,6 +495,7 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
case DERBY:
case HSQLDB: {
ctx.visit(toMerge(ctx.configuration()));
break;