[jOOQ/jOOQ#9928] Added support for PostgreSQL

This commit is contained in:
Lukas Eder 2020-03-09 11:57:42 +01:00
parent 6e95ffce50
commit 36f0a4a56a
2 changed files with 10 additions and 2 deletions

View File

@ -38,6 +38,7 @@
package org.jooq;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.POSTGRES;
import org.jooq.impl.DSL;
@ -53,12 +54,12 @@ public interface JSONObjectNullStep<T> extends Field<T> {
/**
* Include <code>NULL</code> values in output JSON.
*/
@Support({ H2 })
@Support({ H2, POSTGRES })
Field<T> nullOnNull();
/**
* Exclude <code>NULL</code> values in output JSON.
*/
@Support({ H2 })
@Support({ H2, POSTGRES })
Field<T> absentOnNull();
}

View File

@ -119,7 +119,14 @@ final class JSONObject<J> extends AbstractField<J> implements JSONObjectNullStep
case POSTGRES:
if (nullClause == NullClause.ABSENT_ON_NULL)
ctx.visit(unquotedName("json_strip_nulls")).sql('(');
ctx.visit(unquotedName("json_build_object")).sql('(').visit(args).sql(')');
if (nullClause == NullClause.ABSENT_ON_NULL)
ctx.sql(')');
break;