This commit is contained in:
parent
ec42a92708
commit
de8efe0430
@ -16622,6 +16622,14 @@ public class DSL {
|
||||
return new org.jooq.impl.Function<Integer>("count", SQLDataType.INTEGER, nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the count(field) function.
|
||||
*/
|
||||
@Support
|
||||
public static AggregateFunction<Integer> count(SelectFieldOrAsterisk field) {
|
||||
return new org.jooq.impl.Function<Integer>("count", SQLDataType.INTEGER, field("{0}", field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the count(table) function.
|
||||
* <p>
|
||||
@ -16642,6 +16650,14 @@ public class DSL {
|
||||
return new org.jooq.impl.Function<Integer>("count", true, SQLDataType.INTEGER, nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the count(distinct field) function.
|
||||
*/
|
||||
@Support({ CUBRID, DERBY, H2, HSQLDB, FIREBIRD, MARIADB, MYSQL, POSTGRES, SQLITE })
|
||||
public static AggregateFunction<Integer> countDistinct(SelectFieldOrAsterisk field) {
|
||||
return new org.jooq.impl.Function<Integer>("count", true, SQLDataType.INTEGER, field("{0}", field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the count(distinct table) function.
|
||||
* <p>
|
||||
|
||||
@ -5999,22 +5999,31 @@ final class ParserImpl implements Parser {
|
||||
private static final AggregateFunction<?> parseCountIf(ParserContext ctx) {
|
||||
if (parseFunctionNameIf(ctx, "COUNT")) {
|
||||
parse(ctx, '(');
|
||||
if (parseIf(ctx, '*')) {
|
||||
parse(ctx, ')');
|
||||
return count();
|
||||
}
|
||||
|
||||
boolean distinct = parseSetQuantifier(ctx);
|
||||
List<Field<?>> fields = distinct
|
||||
? parseFields(ctx)
|
||||
: Collections.<Field<?>>singletonList(parseField(ctx));
|
||||
|
||||
if (parseIf(ctx, '*') && parse(ctx, ')'))
|
||||
if (distinct)
|
||||
return countDistinct();
|
||||
else
|
||||
return count();
|
||||
|
||||
QualifiedAsterisk asterisk = parseQualifiedAsteriskIf(ctx);
|
||||
List<Field<?>> fields = (asterisk == null)
|
||||
? distinct
|
||||
? parseFields(ctx)
|
||||
: Collections.<Field<?>>singletonList(parseField(ctx))
|
||||
: null;
|
||||
parse(ctx, ')');
|
||||
|
||||
if (distinct)
|
||||
if (fields.size() > 0)
|
||||
if (fields == null)
|
||||
return countDistinct(asterisk);
|
||||
else if (fields.size() > 0)
|
||||
return countDistinct(fields.toArray(EMPTY_FIELD));
|
||||
else
|
||||
return countDistinct(fields.get(0));
|
||||
else if (fields == null)
|
||||
return count(asterisk);
|
||||
else
|
||||
return count(fields.get(0));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user