From ccd55c92f7e816cd0faadbb8082cb9fc21eb9270 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 15 Oct 2021 17:21:16 +0200 Subject: [PATCH] [jOOQ/jOOQ#9085] [jOOQ/jOOQ#8640] Change default ON DUPLICATE KEY IGNORE The default SQL generated for unattached queries shouldn't throw exceptions, but generate something meaningful instead. This change switches the default emulation of ON DUPLICATE KEY IGNORE from INSERT .. SELECT (which requires constraint meta data) to MySQL's INSERT IGNORE --- .../java/org/jooq/impl/InsertQueryImpl.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java index efc3251432..4e4b2d8bb0 100644 --- a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java @@ -441,7 +441,7 @@ final class InsertQueryImpl extends AbstractStoreQuery impl else if (onDuplicateKeyIgnore) { switch (ctx.dialect()) { - // MySQL has a nice, native syntax for this + // The default emulation @@ -451,14 +451,18 @@ final class InsertQueryImpl extends AbstractStoreQuery impl + case FIREBIRD: - case MYSQL: - case MARIADB: { - toSQLInsert(ctx); - ctx.start(INSERT_ON_DUPLICATE_KEY_UPDATE) - .end(INSERT_ON_DUPLICATE_KEY_UPDATE); + case IGNITE: + + + + + +{ + ctx.visit(toInsertSelect(ctx.configuration())); break; } @@ -578,8 +582,11 @@ final class InsertQueryImpl extends AbstractStoreQuery impl break; } + // MySQL has a nice, native syntax for this default: { - ctx.visit(toInsertSelect(ctx.configuration())); + toSQLInsert(ctx); + ctx.start(INSERT_ON_DUPLICATE_KEY_UPDATE) + .end(INSERT_ON_DUPLICATE_KEY_UPDATE); break; } }