[jOOQ/jOOQ#11449] Support parsing SQLite MIN() and MAX() functions
This commit is contained in:
parent
4fa4e13807
commit
75ca50a8d2
@ -39,6 +39,7 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.Names.N_GREATEST;
|
||||
import static org.jooq.impl.Names.N_MAX;
|
||||
import static org.jooq.impl.Names.N_MAXVALUE;
|
||||
|
||||
import org.jooq.Context;
|
||||
@ -111,7 +112,7 @@ final class Greatest<T> extends AbstractField<T> {
|
||||
return;
|
||||
|
||||
case SQLITE:
|
||||
ctx.visit(function("max", getDataType(), args));
|
||||
ctx.visit(function(N_MAX, getDataType(), args));
|
||||
return;
|
||||
|
||||
default:
|
||||
|
||||
@ -39,6 +39,7 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.Names.N_LEAST;
|
||||
import static org.jooq.impl.Names.N_MIN;
|
||||
import static org.jooq.impl.Names.N_MINVALUE;
|
||||
|
||||
import org.jooq.Context;
|
||||
@ -110,7 +111,7 @@ final class Least<T> extends AbstractField<T> {
|
||||
return;
|
||||
|
||||
case SQLITE:
|
||||
ctx.visit(function("min", getDataType(), args));
|
||||
ctx.visit(function(N_MIN, getDataType(), args));
|
||||
return;
|
||||
|
||||
default:
|
||||
|
||||
@ -190,10 +190,12 @@ final class Names {
|
||||
static final Name N_LOWER = unquotedName("lower");
|
||||
static final Name N_LPAD = unquotedName("lpad");
|
||||
static final Name N_LTRIM = unquotedName("ltrim");
|
||||
static final Name N_MAX = unquotedName("max");
|
||||
static final Name N_MAXVALUE = unquotedName("maxvalue");
|
||||
static final Name N_MD5 = unquotedName("md5");
|
||||
static final Name N_MEDIAN = unquotedName("median");
|
||||
static final Name N_MID = unquotedName("mid");
|
||||
static final Name N_MIN = unquotedName("min");
|
||||
static final Name N_MINVALUE = unquotedName("minvalue");
|
||||
static final Name N_MOD = unquotedName("mod");
|
||||
static final Name N_MODE = unquotedName("mode");
|
||||
|
||||
@ -10297,8 +10297,15 @@ final class ParserContext {
|
||||
Condition condition = null;
|
||||
|
||||
keep = over = filter = agg = parseCountIf();
|
||||
if (filter == null)
|
||||
keep = over = filter = agg = parseGeneralSetFunctionIf();
|
||||
if (filter == null) {
|
||||
Field<?> field = parseGeneralSetFunctionIf();
|
||||
|
||||
if (field != null && !(field instanceof AggregateFunction))
|
||||
return field;
|
||||
|
||||
keep = over = filter = agg = (AggregateFunction<?>) field;
|
||||
}
|
||||
|
||||
if (filter == null && !basic)
|
||||
over = filter = agg = parseBinarySetFunctionIf();
|
||||
if (filter == null && !basic)
|
||||
@ -10835,7 +10842,7 @@ final class ParserContext {
|
||||
return ordered;
|
||||
}
|
||||
|
||||
private final AggregateFunction<?> parseGeneralSetFunctionIf() {
|
||||
private final Field<?> parseGeneralSetFunctionIf() {
|
||||
boolean distinct;
|
||||
Field arg;
|
||||
Field arg2;
|
||||
@ -10861,6 +10868,18 @@ final class ParserContext {
|
||||
|
||||
arg = parseField();
|
||||
|
||||
switch (operation) {
|
||||
case MAX:
|
||||
case MIN: {
|
||||
if (!distinct && parseIf(',')) {
|
||||
List<Field<?>> fields = parseFields();
|
||||
parse(')');
|
||||
|
||||
return operation == ComputationalOperation.MAX ? greatest(arg, fields.toArray(EMPTY_FIELD)) : least(arg, fields.toArray(EMPTY_FIELD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parse(')');
|
||||
|
||||
switch (operation) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user