From c0e63ae2f72b6341256c7c9559ce9729cbfd861d Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Mon, 20 Apr 2020 17:47:02 +0200 Subject: [PATCH] [jOOQ/jOOQ#10089] JSON_OBJECTAGG window function support --- .../java/org/jooq/impl/JSONObjectAgg.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/JSONObjectAgg.java b/jOOQ/src/main/java/org/jooq/impl/JSONObjectAgg.java index 67eaa7d22d..d052ec58c6 100644 --- a/jOOQ/src/main/java/org/jooq/impl/JSONObjectAgg.java +++ b/jOOQ/src/main/java/org/jooq/impl/JSONObjectAgg.java @@ -119,7 +119,7 @@ implements JSONObjectAggNullStep { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked", "rawtypes", "serial" }) private final void acceptGroupConcat(Context ctx) { Field value; @@ -133,12 +133,19 @@ implements JSONObjectAggNullStep { value = when(entry.value().isNull(), inline((String) null)).else_((Field) value); } - Field listagg = groupConcat(DSL.concat( - inline('"'), - DSL.replace(entry.key(), inline('"'), inline("\\\"")), - inline("\":"), - nullClause == ABSENT_ON_NULL ? value : DSL.coalesce(value, inline("null")) - )); + final Field value1 = value; + final Field listagg = DSL.field("{0}", String.class, new CustomQueryPart() { + @Override + public void accept(Context c) { + c.visit(groupConcat(DSL.concat( + inline('"'), + DSL.replace(entry.key(), inline('"'), inline("\\\"")), + inline("\":"), + nullClause == ABSENT_ON_NULL ? value1 : DSL.coalesce(value1, inline("null")) + ))); + acceptOverClause(c); + } + }); ctx.sql('(').visit(DSL.concat(inline('{'), listagg, inline('}'))).sql(')'); } @@ -148,6 +155,8 @@ implements JSONObjectAggNullStep { ctx.visit(entry); acceptJSONNullClause(ctx, nullClause); ctx.sql(')'); + + acceptOverClause(ctx); } @Override