[#8300] Support MODE() and MEDIAN() in H2

This commit is contained in:
lukaseder 2019-02-06 10:43:59 +01:00
parent 942fff54e6
commit 9e40e28c13
3 changed files with 6 additions and 5 deletions

View File

@ -38,6 +38,7 @@
package org.jooq;
// ...
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.POSTGRES_9_4;
/**
@ -69,6 +70,6 @@ public interface OrderedAggregateFunctionOfDeferredType {
* Add an <code>WITHIN GROUP (ORDER BY ..)</code> clause to the ordered
* aggregate function
*/
@Support({ POSTGRES_9_4 })
@Support({ H2, POSTGRES_9_4 })
<T> AggregateFilterStep<T> withinGroupOrderBy(OrderField<T> field);
}

View File

@ -17837,7 +17837,7 @@ public class DSL {
/**
* The <code>mode(field)</code> aggregate function.
*/
@Support({ POSTGRES_9_4 })
@Support({ H2, POSTGRES_9_4 })
public static <T> AggregateFunction<T> mode(Field<T> field) {
return new org.jooq.impl.Function<T>(Term.MODE, nullSafeDataType(field), field);
}
@ -17845,7 +17845,7 @@ public class DSL {
/**
* Get the median over a numeric field: median(field).
*/
@Support({ CUBRID, HSQLDB, MARIADB, POSTGRES_9_4 })
@Support({ CUBRID, H2, HSQLDB, MARIADB, POSTGRES_9_4 })
public static AggregateFunction<BigDecimal> median(Field<? extends Number> field) {
return new org.jooq.impl.Function<BigDecimal>(Term.MEDIAN, SQLDataType.NUMERIC, nullSafe(field));
}
@ -18155,7 +18155,7 @@ public class DSL {
* The <code>mode() within group (oder by [order clause])</code> ordered
* aggregate function.
*/
@Support({ POSTGRES_9_4 })
@Support({ H2, POSTGRES_9_4 })
public static OrderedAggregateFunctionOfDeferredType mode() {
return new Mode();
}

View File

@ -239,7 +239,7 @@ class Function<T> extends AbstractField<T> implements
else if (term == MODE && ( ctx.family() == POSTGRES)) {
else if (term == MODE && ( ctx.family() == H2 || ctx.family() == POSTGRES)) {
ctx.visit(mode().withinGroupOrderBy(DSL.field("{0}", arguments.get(0))));
}
else if (term == MEDIAN && ( ctx.family() == POSTGRES)) {