[jOOQ/jOOQ#9111] Support parsing COUNT(DISTINCT ROW(A, B))
In H2 a row value expression can alternatively also use the `ROW()` syntax.
This commit is contained in:
parent
a8ffd253aa
commit
eaf48e48ef
@ -4918,6 +4918,10 @@ final class ParserImpl implements Parser {
|
||||
return parseTuple(ctx, degree, false);
|
||||
}
|
||||
|
||||
private static final RowN parseTupleIf(ParserContext ctx, Integer degree) {
|
||||
return parseTupleIf(ctx, degree, false);
|
||||
}
|
||||
|
||||
private static final RowN parseTuple(ParserContext ctx, Integer degree, boolean allowDoubleParens) {
|
||||
parse(ctx, '(');
|
||||
List<? extends FieldOrRow> fieldsOrRows;
|
||||
@ -4945,6 +4949,13 @@ final class ParserImpl implements Parser {
|
||||
return row;
|
||||
}
|
||||
|
||||
private static final RowN parseTupleIf(ParserContext ctx, Integer degree, boolean allowDoubleParens) {
|
||||
if (peek(ctx, '('))
|
||||
return parseTuple(ctx, degree, allowDoubleParens);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Table<?> parseJoinedTable(ParserContext ctx) {
|
||||
Table<?> result = parseLateral(ctx);
|
||||
|
||||
@ -5147,6 +5158,10 @@ final class ParserImpl implements Parser {
|
||||
return parseRow(ctx, null);
|
||||
}
|
||||
|
||||
private static final RowN parseRowIf(ParserContext ctx) {
|
||||
return parseRowIf(ctx, null);
|
||||
}
|
||||
|
||||
private static final List<RowN> parseRows(ParserContext ctx, Integer degree) {
|
||||
List<RowN> result = new ArrayList<>();
|
||||
|
||||
@ -5164,6 +5179,12 @@ final class ParserImpl implements Parser {
|
||||
return row;
|
||||
}
|
||||
|
||||
private static final RowN parseRowIf(ParserContext ctx, Integer degree) {
|
||||
parseFunctionNameIf(ctx, "ROW");
|
||||
RowN row = parseTupleIf(ctx, degree);
|
||||
return row;
|
||||
}
|
||||
|
||||
private static final RowN parseRow(ParserContext ctx, Integer degree, boolean allowDoubleParens) {
|
||||
parseFunctionNameIf(ctx, "ROW");
|
||||
RowN row = parseTuple(ctx, degree, allowDoubleParens);
|
||||
@ -8713,30 +8734,29 @@ final class ParserImpl implements Parser {
|
||||
else
|
||||
return count();
|
||||
|
||||
boolean parens = parseIf(ctx, '(');
|
||||
Field<?>[] fields = null;
|
||||
QualifiedAsterisk asterisk = null;
|
||||
RowN row = parseRowIf(ctx);
|
||||
if (row != null)
|
||||
fields = row.fields();
|
||||
else if ((asterisk = parseQualifiedAsteriskIf(ctx)) == null)
|
||||
fields = distinct
|
||||
? parseFields(ctx).toArray(EMPTY_FIELD)
|
||||
: new Field[] { parseField(ctx) };
|
||||
|
||||
QualifiedAsterisk asterisk = parseQualifiedAsteriskIf(ctx);
|
||||
List<Field<?>> fields = (asterisk == null)
|
||||
? distinct
|
||||
? parseFields(ctx)
|
||||
: Collections.<Field<?>>singletonList(parseField(ctx))
|
||||
: null;
|
||||
|
||||
if (parens)
|
||||
parse(ctx, ')');
|
||||
parse(ctx, ')');
|
||||
|
||||
if (distinct)
|
||||
if (fields == null)
|
||||
return countDistinct(asterisk);
|
||||
else if (fields.size() > 0)
|
||||
return countDistinct(fields.toArray(EMPTY_FIELD));
|
||||
else if (fields.length > 0)
|
||||
return countDistinct(fields);
|
||||
else
|
||||
return countDistinct(fields.get(0));
|
||||
return countDistinct(fields[0]);
|
||||
else if (fields == null)
|
||||
return count(asterisk);
|
||||
else
|
||||
return count(fields.get(0));
|
||||
return count(fields[0]);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user