From 84d98e8dfaee02b620d096e5ecfa2ecaa35e945f Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 18 Feb 2022 12:58:54 +0100 Subject: [PATCH] [jOOQ/jOOQ#13104] Reimplement SQL Server RETURNING emulation using QueryPart. instead of SchemaMapping --- .../java/org/jooq/impl/AbstractDMLQuery.java | 3 ++ jOOQ/src/main/java/org/jooq/impl/Names.java | 2 ++ jOOQ/src/main/java/org/jooq/impl/Tools.java | 36 ++++--------------- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractDMLQuery.java b/jOOQ/src/main/java/org/jooq/impl/AbstractDMLQuery.java index b3b60c4213..58859fedda 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractDMLQuery.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractDMLQuery.java @@ -89,6 +89,8 @@ import static org.jooq.impl.Keywords.K_ROWCOUNT; import static org.jooq.impl.Keywords.K_SELECT; import static org.jooq.impl.Keywords.K_SQL; import static org.jooq.impl.Keywords.K_TABLE; +import static org.jooq.impl.Names.N_DELETED; +import static org.jooq.impl.Names.N_INSERTED; import static org.jooq.impl.Tools.EMPTY_FIELD; import static org.jooq.impl.Tools.EMPTY_STRING; import static org.jooq.impl.Tools.anyMatch; @@ -805,6 +807,7 @@ abstract class AbstractDMLQuery extends AbstractRowCountQuery + final void toSQLReturning(Context ctx) { diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 3bbadb6d6c..8fe0510c51 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -157,6 +157,7 @@ final class Names { static final Name N_IFNULL = systemName("ifnull"); static final Name N_IIF = systemName("iif"); static final Name N_INSERT = systemName("insert"); + static final Name N_INSERTED = systemName("inserted"); static final Name N_INSTR = systemName("instr"); static final Name N_ISJSON = systemName("isjson"); static final Name N_JOIN = systemName("join"); @@ -361,6 +362,7 @@ final class Names { static final Name N_CURRENT_USER = systemName("current_user"); static final Name N_DATE_ADD = systemName("date_add"); static final Name N_DEGREES = systemName("degrees"); + static final Name N_DELETED = systemName("deleted"); static final Name N_DELETING = systemName("deleting"); static final Name N_DIGITS = systemName("digits"); static final Name N_E = systemName("e"); diff --git a/jOOQ/src/main/java/org/jooq/impl/Tools.java b/jOOQ/src/main/java/org/jooq/impl/Tools.java index af36be264e..a0cad34a39 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Tools.java +++ b/jOOQ/src/main/java/org/jooq/impl/Tools.java @@ -706,12 +706,6 @@ final class Tools { * statement. */ DATA_SELECT_ALIASES, - - /** - * [#8917] An internal schema mapping that overrides any user-defined - * schema mappings. - */ - DATA_SCHEMA_MAPPING, } /** @@ -3201,14 +3195,8 @@ final class Tools { * Map a {@link Catalog} according to the configured {@link org.jooq.SchemaMapping} */ static final Catalog getMappedCatalog(Scope scope, Catalog catalog) { - if (scope != null) { - org.jooq.SchemaMapping mapping = (SchemaMapping) scope.data(DataKey.DATA_SCHEMA_MAPPING); - - if (mapping == null) - mapping = scope.configuration().schemaMapping(); - - return mapping.map(catalog); - } + if (scope != null) + scope.configuration().schemaMapping().map(catalog); return catalog; } @@ -3217,14 +3205,8 @@ final class Tools { * Map a {@link Schema} according to the configured {@link org.jooq.SchemaMapping} */ static final Schema getMappedSchema(Scope scope, Schema schema) { - if (scope != null) { - org.jooq.SchemaMapping mapping = (SchemaMapping) scope.data(DataKey.DATA_SCHEMA_MAPPING); - - if (mapping == null) - mapping = scope.configuration().schemaMapping(); - - return mapping.map(schema); - } + if (scope != null) + return scope.configuration().schemaMapping().map(schema); return schema; } @@ -3233,14 +3215,8 @@ final class Tools { * Map a {@link Table} according to the configured {@link org.jooq.SchemaMapping} */ static final Table getMappedTable(Scope scope, Table table) { - if (scope != null) { - org.jooq.SchemaMapping mapping = (SchemaMapping) scope.data(DataKey.DATA_SCHEMA_MAPPING); - - if (mapping == null) - mapping = scope.configuration().schemaMapping(); - - return mapping.map(table); - } + if (scope != null) + return scope.configuration().schemaMapping().map(table); return table; }