[jOOQ/jOOQ#14416] Support UNNEST(ARRAY[...]) in dialects that do not otherwise support arrays
This commit is contained in:
parent
80395e3c5b
commit
e8175b9392
@ -67,7 +67,7 @@ final class Array<T> extends AbstractField<T[]> implements QOM.Array<T> {
|
||||
|
||||
private static final Set<SQLDialect> REQUIRES_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
|
||||
|
||||
private final FieldsImpl<Record> fields;
|
||||
final FieldsImpl<Record> fields;
|
||||
|
||||
Array(Collection<? extends Field<T>> fields) {
|
||||
super(N_ARRAY, type(fields));
|
||||
|
||||
@ -177,6 +177,8 @@ implements
|
||||
}
|
||||
|
||||
private final QueryPart table(Configuration configuration) {
|
||||
boolean isArray = array.getDataType().getType().isArray();
|
||||
|
||||
switch (configuration.family()) {
|
||||
|
||||
|
||||
@ -187,6 +189,8 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Most dialects can simulate unnested arrays using UNION ALL
|
||||
|
||||
|
||||
@ -211,8 +215,12 @@ implements
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
case SQLITE:
|
||||
if (array.getDataType().getType().isArray() && array instanceof Param)
|
||||
return emulate();
|
||||
if (isArray && array instanceof Param)
|
||||
return emulateParam();
|
||||
|
||||
// [#14416] While Array isn't supported everywhere, Unnest(Array) is
|
||||
else if (isArray && array instanceof Array)
|
||||
return emulateArray();
|
||||
|
||||
|
||||
|
||||
@ -283,7 +291,12 @@ implements
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private final QueryPart emulate() {
|
||||
private final QueryPart emulateParam() {
|
||||
return new ArrayTableEmulation(((Param<Object[]>) array).getValue(), fieldAliases);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private final QueryPart emulateArray() {
|
||||
return new ArrayTableEmulation(((Array<Object>) array).fields.fields, fieldAliases);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user