From b16664d1ec083cdae1f307dd680a619ef500568c Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 16 Jul 2020 14:49:31 +0200 Subject: [PATCH] [jOOQ/jOOQ#10408] Error in Sybase ASE INSERT .. DEFAULT VALUES emulation when used with identity column --- .../java/org/jooq/impl/InsertQueryImpl.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java index 66172a8f6d..fa08866718 100644 --- a/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/InsertQueryImpl.java @@ -55,6 +55,7 @@ import static org.jooq.SQLDialect.MYSQL; // ... // ... import static org.jooq.impl.DSL.constraint; +import static org.jooq.impl.DSL.defaultValue; import static org.jooq.impl.DSL.dual; import static org.jooq.impl.DSL.falseCondition; import static org.jooq.impl.DSL.name; @@ -677,6 +678,22 @@ final class InsertQueryImpl extends AbstractStoreQuery impl + + + + + + + + + + + + + + + + @@ -685,13 +702,9 @@ final class InsertQueryImpl extends AbstractStoreQuery impl case DERBY: case MARIADB: case MYSQL: - ctx.formatSeparator() - .visit(K_VALUES) - .sql(" (") - .visit(wrap(nCopies(table().fields().length, K_DEFAULT))) - .sql(')'); - + acceptDefaultValuesEmulation(ctx, table().fields().length); break; + default: ctx.formatSeparator() .visit(K_DEFAULT_VALUES); @@ -713,6 +726,14 @@ final class InsertQueryImpl extends AbstractStoreQuery impl } } + private final void acceptDefaultValuesEmulation(Context ctx, int length) { + ctx.formatSeparator() + .visit(K_VALUES) + .sql(" (") + .visit(wrap(nCopies(length, K_DEFAULT))) + .sql(')'); + } +