Search in sources :

Example 1 with N_RECORD

use of org.jooq.impl.Names.N_RECORD in project jOOQ by jOOQ.

the class AbstractRowAsField method acceptMultisetContent.

static final void acceptMultisetContent(Context<?> ctx, Row row, Field<?> field, Consumer<? super Context<?>> acceptDefault) {
    Object previous = ctx.data(DATA_MULTISET_CONTENT);
    try {
        ctx.data(DATA_MULTISET_CONTENT, true);
        Name alias = field.getUnqualifiedName();
        switch(emulateMultiset(ctx.configuration())) {
            case JSON:
                switch(ctx.family()) {
                    default:
                        ctx.visit(alias(ctx, alias, returningClob(ctx, jsonArray(row.fields()).nullOnNull())));
                        break;
                }
                break;
            case JSONB:
                switch(ctx.family()) {
                    default:
                        ctx.visit(alias(ctx, alias, returningClob(ctx, jsonbArray(row.fields()).nullOnNull())));
                        break;
                }
                break;
            case XML:
                switch(ctx.family()) {
                    default:
                        ctx.visit(alias(ctx, alias, xmlelement(N_RECORD, map(row.fields(), (f, i) -> xmlelement(fieldNameString(i), f)))));
                        break;
                }
                break;
            // case ARRAY:
            case NATIVE:
            default:
                acceptDefault.accept(ctx);
                break;
        }
    } finally {
        ctx.data(DATA_MULTISET_CONTENT, previous);
    }
}
Also used : Tools.fieldNameString(org.jooq.impl.Tools.fieldNameString) Record(org.jooq.Record) DataType(org.jooq.DataType) Row(org.jooq.Row) Tools.map(org.jooq.impl.Tools.map) Name(org.jooq.Name) Tools.row0(org.jooq.impl.Tools.row0) Field(org.jooq.Field) DSL.jsonbObject(org.jooq.impl.DSL.jsonbObject) DSL.select(org.jooq.impl.DSL.select) DATA_MULTISET_CONTENT(org.jooq.impl.Tools.BooleanDataKey.DATA_MULTISET_CONTENT) DSL.xmlelement(org.jooq.impl.DSL.xmlelement) BooleanSupplier(java.util.function.BooleanSupplier) DSL.jsonbArray(org.jooq.impl.DSL.jsonbArray) Consumer(java.util.function.Consumer) Configuration(org.jooq.Configuration) DSL.jsonArray(org.jooq.impl.DSL.jsonArray) Tools.emulateMultiset(org.jooq.impl.Tools.emulateMultiset) Context(org.jooq.Context) Multiset.returningClob(org.jooq.impl.Multiset.returningClob) Fields(org.jooq.Fields) DSL.jsonObject(org.jooq.impl.DSL.jsonObject) N_RECORD(org.jooq.impl.Names.N_RECORD) TRUE(java.lang.Boolean.TRUE) DSL.jsonbObject(org.jooq.impl.DSL.jsonbObject) DSL.jsonObject(org.jooq.impl.DSL.jsonObject) Name(org.jooq.Name)

Aggregations

TRUE (java.lang.Boolean.TRUE)1 BooleanSupplier (java.util.function.BooleanSupplier)1 Consumer (java.util.function.Consumer)1 Configuration (org.jooq.Configuration)1 Context (org.jooq.Context)1 DataType (org.jooq.DataType)1 Field (org.jooq.Field)1 Fields (org.jooq.Fields)1 Name (org.jooq.Name)1 Record (org.jooq.Record)1 Row (org.jooq.Row)1 DSL.jsonArray (org.jooq.impl.DSL.jsonArray)1 DSL.jsonObject (org.jooq.impl.DSL.jsonObject)1 DSL.jsonbArray (org.jooq.impl.DSL.jsonbArray)1 DSL.jsonbObject (org.jooq.impl.DSL.jsonbObject)1 DSL.select (org.jooq.impl.DSL.select)1 DSL.xmlelement (org.jooq.impl.DSL.xmlelement)1 Multiset.returningClob (org.jooq.impl.Multiset.returningClob)1 N_RECORD (org.jooq.impl.Names.N_RECORD)1 DATA_MULTISET_CONTENT (org.jooq.impl.Tools.BooleanDataKey.DATA_MULTISET_CONTENT)1