[jOOQ/jOOQ#18144] MULTISET emulation using XML doesn't correctly encode
NULL String values when nesting tables as SelectField
This commit is contained in:
parent
6e0d1c7807
commit
443c09a4f1
@ -45,6 +45,7 @@ import static org.jooq.impl.DSL.jsonbObject;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.xmlelement;
|
||||
import static org.jooq.impl.Multiset.returningClob;
|
||||
import static org.jooq.impl.Multiset.wrapXmlelement;
|
||||
import static org.jooq.impl.Names.N_RECORD;
|
||||
import static org.jooq.impl.RowAsField.NO_NATIVE_SUPPORT;
|
||||
import static org.jooq.impl.Tools.emulateMultiset;
|
||||
@ -218,8 +219,8 @@ implements
|
||||
|
||||
default:
|
||||
ctx.visit(alias(ctx, alias, xmlelement(N_RECORD,
|
||||
map(row.fields(), (f, i) -> xmlelement(fieldNameString(i), f)))
|
||||
));
|
||||
map(row.fields(), (f, i) -> wrapXmlelement(ctx, f, fieldNameString(i)))
|
||||
)));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -653,19 +653,23 @@ final class Multiset<R extends Record> extends AbstractField<Result<R>> implemen
|
||||
map(fields.fields(), (f, i) -> {
|
||||
Field<?> v = castForXML(ctx, agg ? f : DSL.field(fieldName(i), f.getDataType()));
|
||||
String n = fieldNameString(i);
|
||||
DataType<?> t = v.getDataType();
|
||||
|
||||
// [#13181] We must make the '' vs NULL distinction explicit in XML
|
||||
// [#13872] Same with ARRAY[] vs NULL
|
||||
if (t.isString() || t.isArray())
|
||||
return xmlelement(n, xmlattributes(when(v.isNull(), inline("true")).as(xsiNil(ctx))), v);
|
||||
else
|
||||
return xmlelement(n, v);
|
||||
return wrapXmlelement(ctx, v, n);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static final Field<XML> wrapXmlelement(Context<?> ctx, Field<?> v, String n) {
|
||||
DataType<?> t = v.getDataType();
|
||||
|
||||
// [#13181] We must make the '' vs NULL distinction explicit in XML
|
||||
// [#13872] Same with ARRAY[] vs NULL
|
||||
if (t.isString() || t.isArray())
|
||||
return xmlelement(n, xmlattributes(when(v.isNull(), inline("true")).as(xsiNil(ctx))), v);
|
||||
else
|
||||
return xmlelement(n, v);
|
||||
}
|
||||
|
||||
static final ArrayAggOrderByStep<?> arrayAggEmulation(Fields fields, boolean agg) {
|
||||
return arrayAgg(
|
||||
new RowAsField<>(row(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user