From 8cbd0208b3ddf311ed470b2343dbb7d0e72bbc66 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Mon, 18 Feb 2019 09:29:04 +0100 Subject: [PATCH] [#8333] Support INSERT .. ON ( DUPLICATE KEY | CONFLICT ) in Derby --- .../jooq/InsertOnConflictDoUpdateStep.java | 3 ++- .../org/jooq/InsertOnConflictWhereStep.java | 21 ++++++++++--------- .../org/jooq/InsertOnDuplicateSetStep.java | 11 +++++----- .../java/org/jooq/InsertOnDuplicateStep.java | 5 +++-- jOOQ/src/main/java/org/jooq/InsertQuery.java | 12 +++++------ .../main/java/org/jooq/LoaderOptionsStep.java | 3 ++- .../java/org/jooq/impl/InsertQueryImpl.java | 1 + 7 files changed, 31 insertions(+), 25 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/InsertOnConflictDoUpdateStep.java b/jOOQ/src/main/java/org/jooq/InsertOnConflictDoUpdateStep.java index ed3a91e2cd..c73be1c442 100644 --- a/jOOQ/src/main/java/org/jooq/InsertOnConflictDoUpdateStep.java +++ b/jOOQ/src/main/java/org/jooq/InsertOnConflictDoUpdateStep.java @@ -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 { /** * Add the DO UPDATE clause. */ - @Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 }) InsertOnDuplicateSetStep doUpdate(); /** diff --git a/jOOQ/src/main/java/org/jooq/InsertOnConflictWhereStep.java b/jOOQ/src/main/java/org/jooq/InsertOnConflictWhereStep.java index 63d8059167..8629c6e6b8 100644 --- a/jOOQ/src/main/java/org/jooq/InsertOnConflictWhereStep.java +++ b/jOOQ/src/main/java/org/jooq/InsertOnConflictWhereStep.java @@ -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 extends InsertRetur * Add a WHERE 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 where(Condition condition); /** * Add a WHERE 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 where(Condition... conditions); /** * Add a WHERE 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 where(Collection conditions); /** * Add a WHERE clause to the query. */ - @Support({ CUBRID, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, POSTGRES_9_5 }) InsertReturningStep where(Field field); /** @@ -122,7 +123,7 @@ public interface InsertOnConflictWhereStep extends InsertRetur * @see DSL#condition(SQL) * @see SQL */ - @Support({ CUBRID, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, POSTGRES_9_5 }) @PlainSQL InsertReturningStep where(SQL sql); @@ -137,7 +138,7 @@ public interface InsertOnConflictWhereStep extends InsertRetur * @see DSL#condition(String) * @see SQL */ - @Support({ CUBRID, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, POSTGRES_9_5 }) @PlainSQL InsertReturningStep where(String sql); @@ -153,7 +154,7 @@ public interface InsertOnConflictWhereStep extends InsertRetur * @see DSL#sql(String, Object...) * @see SQL */ - @Support({ CUBRID, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, POSTGRES_9_5 }) @PlainSQL InsertReturningStep where(String sql, Object... bindings); @@ -169,19 +170,19 @@ public interface InsertOnConflictWhereStep extends InsertRetur * @see DSL#sql(String, QueryPart...) * @see SQL */ - @Support({ CUBRID, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, POSTGRES_9_5 }) @PlainSQL InsertReturningStep where(String sql, QueryPart... parts); /** * Add a WHERE EXISTS clause to the query. */ - @Support({ CUBRID, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, POSTGRES_9_5 }) InsertReturningStep whereExists(Select select); /** * Add a WHERE NOT EXISTS clause to the query. */ - @Support({ CUBRID, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, POSTGRES_9_5 }) InsertReturningStep whereNotExists(Select select); } diff --git a/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetStep.java b/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetStep.java index c96091aa8a..4026f6016b 100644 --- a/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetStep.java +++ b/jOOQ/src/main/java/org/jooq/InsertOnDuplicateSetStep.java @@ -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 { * Set values for UPDATE in the INSERT statement's * ON DUPLICATE KEY UPDATE clause. */ - @Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) InsertOnDuplicateSetMoreStep set(Field field, T value); /** * Set values for UPDATE in the INSERT statement's * ON DUPLICATE KEY UPDATE clause. */ - @Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) InsertOnDuplicateSetMoreStep set(Field field, Field value); /** * Set values for UPDATE in the INSERT statement's * ON DUPLICATE KEY UPDATE clause. */ - @Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) InsertOnDuplicateSetMoreStep set(Field field, Select> value); /** @@ -121,7 +122,7 @@ public interface InsertOnDuplicateSetStep { * Field<T>. 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 set(Map map); /** @@ -133,7 +134,7 @@ public interface InsertOnDuplicateSetStep { * * @see #set(Map) */ - @Support({ CUBRID, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) InsertOnDuplicateSetMoreStep set(Record record); } diff --git a/jOOQ/src/main/java/org/jooq/InsertOnDuplicateStep.java b/jOOQ/src/main/java/org/jooq/InsertOnDuplicateStep.java index 26d2a2d17e..833decf29b 100644 --- a/jOOQ/src/main/java/org/jooq/InsertOnDuplicateStep.java +++ b/jOOQ/src/main/java/org/jooq/InsertOnDuplicateStep.java @@ -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 extends InsertReturning /** * Add a ON CONFLICT ON CONSTRAINT clause to this query. */ - @Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 }) InsertOnConflictDoUpdateStep onConflictOnConstraint(Constraint constraint); /** * Add a ON CONFLICT ON CONSTRAINT clause to this query. */ - @Support({ CUBRID, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, FIREBIRD_3_0, HSQLDB, POSTGRES_9_5 }) InsertOnConflictDoUpdateStep onConflictOnConstraint(Name constraint); /** diff --git a/jOOQ/src/main/java/org/jooq/InsertQuery.java b/jOOQ/src/main/java/org/jooq/InsertQuery.java index a60ce9c234..b94461d03f 100644 --- a/jOOQ/src/main/java/org/jooq/InsertQuery.java +++ b/jOOQ/src/main/java/org/jooq/InsertQuery.java @@ -134,7 +134,7 @@ public interface InsertQuery extends StoreQuery, Insert * ON CONFLICT ON CONSTRAINT clause in this INSERT * 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 extends StoreQuery, Insert * ON CONFLICT ON CONSTRAINT clause in this INSERT * 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 extends StoreQuery, Insert * * @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 extends StoreQuery, Insert * * @see InsertOnDuplicateStep#onDuplicateKeyUpdate() */ - @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) void addValueForUpdate(Field field, T value); /** @@ -239,7 +239,7 @@ public interface InsertQuery extends StoreQuery, Insert * * @see InsertOnDuplicateStep#onDuplicateKeyUpdate() */ - @Support({ CUBRID, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) + @Support({ CUBRID, DERBY, H2, HSQLDB, MARIADB, MYSQL, POSTGRES_9_5 }) void addValueForUpdate(Field field, Field value); /** @@ -252,7 +252,7 @@ public interface InsertQuery extends StoreQuery, Insert * * @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); /** diff --git a/jOOQ/src/main/java/org/jooq/LoaderOptionsStep.java b/jOOQ/src/main/java/org/jooq/LoaderOptionsStep.java index 808cfad8fa..c350164730 100644 --- a/jOOQ/src/main/java/org/jooq/LoaderOptionsStep.java +++ b/jOOQ/src/main/java/org/jooq/LoaderOptionsStep.java @@ -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 extends LoaderSourceStep * 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 onDuplicateKeyUpdate(); /** diff --git a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java index 6ced936e5a..efcae299de 100644 --- a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java @@ -495,6 +495,7 @@ final class InsertQueryImpl extends AbstractStoreQuery impl + case DERBY: case HSQLDB: { ctx.visit(toMerge(ctx.configuration())); break;