Skip to content

Commit

Permalink
[#7176] Regression in PostgreSQL MODE function implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed Feb 15, 2018
1 parent ce1d535 commit 6d36567
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jOOQ/src/main/java/org/jooq/impl/Mode.java
Expand Up @@ -38,6 +38,8 @@
package org.jooq.impl;

import org.jooq.AggregateFilterStep;
import org.jooq.DataType;
import org.jooq.Field;
import org.jooq.OrderField;
import org.jooq.OrderedAggregateFunctionOfDeferredType;

Expand All @@ -46,8 +48,15 @@
*/
final class Mode implements OrderedAggregateFunctionOfDeferredType {

@SuppressWarnings("unchecked")
@Override
public final <T> AggregateFilterStep<T> withinGroupOrderBy(OrderField<T> field) {
return new Function<T>("mode", ((SortFieldImpl<T>) field).getField().getDataType()).withinGroupOrderBy(field);
DataType<T> type = field instanceof SortFieldImpl
? ((SortFieldImpl<T>) field).getField().getDataType()
: field instanceof Field
? ((AbstractField<T>) field).getDataType()
: (DataType<T>) SQLDataType.NUMERIC;

return new Function<T>("mode", type).withinGroupOrderBy(field);
}
}

0 comments on commit 6d36567

Please sign in to comment.