[jOOQ/jOOQ#8545] Better numeric data type handling in CockroachDB
This commit is contained in:
parent
cfddca49d6
commit
c90824afe9
@ -55,7 +55,7 @@ final class CountTable extends Function<Integer> {
|
||||
private final boolean distinct;
|
||||
|
||||
CountTable(Table<?> table, boolean distinct) {
|
||||
super("count", distinct, SQLDataType.INTEGER, DSL.name(table.getName()));
|
||||
super("count", distinct, SQLDataType.INTEGER, DSL.field(DSL.name(table.getName())));
|
||||
|
||||
this.table = table;
|
||||
this.distinct = distinct;
|
||||
|
||||
@ -95,7 +95,6 @@ import static org.jooq.impl.Term.PERCENT_RANK;
|
||||
import static org.jooq.impl.Term.RANK;
|
||||
import static org.jooq.impl.Term.ROW_NUMBER;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_QUERYPART;
|
||||
import static org.jooq.impl.Tools.combine;
|
||||
import static org.jooq.impl.Tools.configuration;
|
||||
import static org.jooq.tools.StringUtils.isEmpty;
|
||||
@ -16585,12 +16584,12 @@ public class DSL {
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static GroupField groupingSets(Collection<? extends Field<?>>... fieldSets) {
|
||||
WrappedList[] array = new WrappedList[fieldSets.length];
|
||||
QueryPartList<WrappedList> arg = new QueryPartList<>();
|
||||
|
||||
for (int i = 0; i < fieldSets.length; i++)
|
||||
array[i] = new WrappedList(new QueryPartList<>(fieldSets[i]));
|
||||
for (Collection<? extends Field<?>> fieldsSet : fieldSets)
|
||||
arg.add(new WrappedList(new QueryPartList<>(fieldsSet)));
|
||||
|
||||
return new org.jooq.impl.Function<>("grouping sets", SQLDataType.OTHER, array);
|
||||
return field("grouping sets({0})", SQLDataType.OTHER, arg);
|
||||
}
|
||||
|
||||
|
||||
@ -18776,7 +18775,7 @@ public class DSL {
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
public static OrderedAggregateFunction<Integer> rank(Collection<? extends Field<?>> fields) {
|
||||
return new org.jooq.impl.Function<>("rank", SQLDataType.INTEGER, fields.toArray(EMPTY_QUERYPART));
|
||||
return new org.jooq.impl.Function<>("rank", SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -18794,7 +18793,7 @@ public class DSL {
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
public static OrderedAggregateFunction<Integer> denseRank(Collection<? extends Field<?>> fields) {
|
||||
return new org.jooq.impl.Function<>("dense_rank", SQLDataType.INTEGER, fields.toArray(EMPTY_QUERYPART));
|
||||
return new org.jooq.impl.Function<>("dense_rank", SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -18812,7 +18811,7 @@ public class DSL {
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
public static OrderedAggregateFunction<Integer> percentRank(Collection<? extends Field<?>> fields) {
|
||||
return new org.jooq.impl.Function<>("percent_rank", SQLDataType.INTEGER, fields.toArray(EMPTY_QUERYPART));
|
||||
return new org.jooq.impl.Function<>("percent_rank", SQLDataType.INTEGER, fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -18830,7 +18829,7 @@ public class DSL {
|
||||
*/
|
||||
@Support({ H2, POSTGRES })
|
||||
public static OrderedAggregateFunction<BigDecimal> cumeDist(Collection<? extends Field<?>> fields) {
|
||||
return new org.jooq.impl.Function<>("cume_dist", SQLDataType.NUMERIC, fields.toArray(EMPTY_QUERYPART));
|
||||
return new org.jooq.impl.Function<>("cume_dist", SQLDataType.NUMERIC, fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -165,7 +165,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
private final Term term;
|
||||
|
||||
// Other attributes
|
||||
private final QueryPartList<QueryPart> arguments;
|
||||
private final QueryPartList<Field<?>> arguments;
|
||||
private final boolean distinct;
|
||||
private SortFieldList withinGroupOrderBy;
|
||||
private SortFieldList keepDenseRankOrderBy;
|
||||
@ -182,19 +182,19 @@ class Function<T> extends AbstractField<T> implements
|
||||
// XXX Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Function(String name, DataType<T> type, QueryPart... arguments) {
|
||||
Function(String name, DataType<T> type, Field<?>... arguments) {
|
||||
this(name, false, type, arguments);
|
||||
}
|
||||
|
||||
Function(Term term, DataType<T> type, QueryPart... arguments) {
|
||||
Function(Term term, DataType<T> type, Field<?>... arguments) {
|
||||
this(term, false, type, arguments);
|
||||
}
|
||||
|
||||
Function(Name name, DataType<T> type, QueryPart... arguments) {
|
||||
Function(Name name, DataType<T> type, Field<?>... arguments) {
|
||||
this(name, false, type, arguments);
|
||||
}
|
||||
|
||||
Function(String name, boolean distinct, DataType<T> type, QueryPart... arguments) {
|
||||
Function(String name, boolean distinct, DataType<T> type, Field<?>... arguments) {
|
||||
super(DSL.name(name), type);
|
||||
|
||||
this.term = null;
|
||||
@ -203,7 +203,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
this.arguments = new QueryPartList<>(arguments);
|
||||
}
|
||||
|
||||
Function(Term term, boolean distinct, DataType<T> type, QueryPart... arguments) {
|
||||
Function(Term term, boolean distinct, DataType<T> type, Field<?>... arguments) {
|
||||
super(term.toName(), type);
|
||||
|
||||
this.term = term;
|
||||
@ -212,7 +212,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
this.arguments = new QueryPartList<>(arguments);
|
||||
}
|
||||
|
||||
Function(Name name, boolean distinct, DataType<T> type, QueryPart... arguments) {
|
||||
Function(Name name, boolean distinct, DataType<T> type, Field<?>... arguments) {
|
||||
super(name, type);
|
||||
|
||||
this.term = null;
|
||||
@ -257,7 +257,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
else if (term == PRODUCT) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
final Field<Integer> f = (Field) DSL.field("{0}", arguments.get(0));
|
||||
final Field<Integer> f = (Field) DSL.field("{0}", arguments.get(0).getDataType(), arguments.get(0));
|
||||
final Field<Integer> negatives = DSL.when(f.lt(zero()), inline(-1));
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@ -566,7 +566,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
toSQLArguments1(ctx, arguments);
|
||||
}
|
||||
|
||||
final void toSQLArguments1(Context<?> ctx, QueryPartList<QueryPart> args) {
|
||||
final void toSQLArguments1(Context<?> ctx, QueryPartList<Field<?>> args) {
|
||||
if (distinct) {
|
||||
ctx.visit(K_DISTINCT).sql(' ');
|
||||
|
||||
@ -582,7 +582,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
else {
|
||||
QueryPartList<Field<?>> expressions = new QueryPartList<>();
|
||||
|
||||
for (QueryPart argument : args)
|
||||
for (Field<?> argument : args)
|
||||
expressions.add(DSL.when(filter, argument == ASTERISK ? one() : argument));
|
||||
|
||||
ctx.visit(expressions);
|
||||
@ -639,7 +639,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
// XXX aggregate and window function fluent API methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
final QueryPartList<QueryPart> getArguments() {
|
||||
final QueryPartList<Field<?>> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user