[jOOQ/jOOQ#11831] Support parsing array(select)

This commit is contained in:
Lukas Eder 2021-05-03 17:21:04 +02:00
parent f8cd4a9791
commit 8c0f7eb076
2 changed files with 22 additions and 11 deletions

View File

@ -8476,19 +8476,28 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
private final Field<?> parseArrayValueConstructorIf() {
if (parseKeywordIf("ARRAY")) {
parse('[');
if (parseIf('[')) {
List<Field<?>> fields;
List<Field<?>> fields;
if (parseIf(']')) {
fields = emptyList();
}
else {
fields = parseList(',', ParseContext::parseField);
parse(']');
}
if (parseIf(']')) {
fields = emptyList();
}
else {
fields = parseList(',', ParseContext::parseField);
parse(']');
}
// Prevent "wrong" javac method bind
return DSL.array((Collection) fields);
// Prevent "wrong" javac method bind
return DSL.array((Collection) fields);
}
else if (parseIf('(')) {
SelectQueryImpl select = parseWithOrSelect(1);
parse(')');
return DSL.array(select);
}
else
throw expected("[", "(");
}
return null;

View File

@ -283,6 +283,8 @@ import org.jooq.tools.Convert;
import org.jooq.tools.JooqLogger;
import org.jooq.tools.StringUtils;
import org.jetbrains.annotations.Nullable;
/**
* A sub-select is a <code>SELECT</code> statement that can be combined with
* other <code>SELECT</code> statement in <code>UNION</code>s and similar