From d93eba5a338fcc8d97143dac81423f1cf14dc961 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Tue, 10 Jan 2023 16:56:04 +0100 Subject: [PATCH] [jOOQ/jOOQ#5799] Fix asterisk expansion for WITH ORDINALITY If WITH ORDINALITY is emulated using a derived table, then we must not fully qualify the fields. This probably produces other issues when it is safe to expect fully qualified columns from a WITH ORDINALITY table, including a performance penalty when looking up field references in records. --- jOOQ/src/main/java/org/jooq/impl/WithOrdinalityTable.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/impl/WithOrdinalityTable.java b/jOOQ/src/main/java/org/jooq/impl/WithOrdinalityTable.java index 1e8277c646..8c99ebb6c1 100644 --- a/jOOQ/src/main/java/org/jooq/impl/WithOrdinalityTable.java +++ b/jOOQ/src/main/java/org/jooq/impl/WithOrdinalityTable.java @@ -146,6 +146,12 @@ implements @Override final FieldsImpl fields0() { FieldsImpl r = new FieldsImpl<>(delegate.fields0().fields); + + // [#5799] If WITH ORDINALITY is emulated using a derived table, then + // we must not fully qualify the fields. + for (int i = 0; i < r.fields.length; i++) + r.fields[i] = DSL.field(delegate.getUnqualifiedName().append(r.fields[i].getUnqualifiedName()), r.fields[i].getDataType()); + r.add(DSL.field(N_ORDINAL, BIGINT)); return r; }