From 31dc00fb1dd49ca16fd8754c989d8021a235be67 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Mon, 24 Mar 2025 15:12:28 +0100 Subject: [PATCH] [jOOQ/jOOQ#18202] DSL.excluded with UDTField creates query with syntax error --- jOOQ/src/main/java/org/jooq/impl/Excluded.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/Excluded.java b/jOOQ/src/main/java/org/jooq/impl/Excluded.java index de05a7660e..c8b51a2ed6 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Excluded.java +++ b/jOOQ/src/main/java/org/jooq/impl/Excluded.java @@ -121,11 +121,15 @@ implements default: // [#7552] When emulating INSERT .. ON DUPLICATE KEY UPDATE using // MERGE, the EXCLUDED pseudo table is called "t", instead - ctx.visit(ctx.data(ExtendedDataKey.DATA_INSERT_ON_DUPLICATE_KEY_UPDATE) != null - ? name("t") - : N_EXCLUDED) - .sql('.') - .qualify(false, c -> c.visit(field)); + // [#18202] Don't render the EXCLUDED name here in case it needs to be enclosed + // in parentheses, e.g. in a UDTPathField + Table t = (Table) ctx.data(SimpleDataKey.DATA_DML_TARGET_TABLE); + ctx.scopeRegister(t, false, + ctx.data(ExtendedDataKey.DATA_INSERT_ON_DUPLICATE_KEY_UPDATE) != null + ? table(name("t")) + : table(N_EXCLUDED)) + .visit(field) + .scopeRegister(t, false, null); break; } }