[jOOQ/jOOQ#9930] Extracted AbstractAggregateFunction
- Fixed regression
This commit is contained in:
parent
e5f62a3849
commit
54c5ff3567
76
jOOQ/src/main/java/org/jooq/impl/ArrayAgg.java
Normal file
76
jOOQ/src/main/java/org/jooq/impl/ArrayAgg.java
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Keywords.K_ORDER_BY;
|
||||
import static org.jooq.impl.Names.N_ARRAY_AGG;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class ArrayAgg<T> extends DefaultAggregateFunction<T[]> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 8039163610536383826L;
|
||||
|
||||
ArrayAgg(boolean distinct, Field<T> arg) {
|
||||
super(distinct, N_ARRAY_AGG, arg.getDataType().getArrayDataType(), arg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(N_ARRAY_AGG).sql('(');
|
||||
acceptArguments1(ctx, new QueryPartList<>(Arrays.asList(arguments.get(0))));
|
||||
|
||||
if (!Tools.isEmpty(withinGroupOrderBy))
|
||||
ctx.sql(' ').visit(K_ORDER_BY).sql(' ')
|
||||
.visit(withinGroupOrderBy);
|
||||
|
||||
ctx.sql(')');
|
||||
|
||||
acceptFilterClause(ctx);
|
||||
acceptOverClause(ctx);
|
||||
}
|
||||
}
|
||||
@ -112,8 +112,8 @@ class DefaultAggregateFunction<T> extends AbstractAggregateFunction<T> {
|
||||
}
|
||||
else {
|
||||
toSQLArguments(ctx);
|
||||
toSQLKeepDenseRankOrderByClause(ctx);
|
||||
toSQLWithinGroupClause(ctx);
|
||||
acceptKeepDenseRankOrderByClause(ctx);
|
||||
acceptWithinGroupClause(ctx);
|
||||
acceptFilterClause(ctx);
|
||||
acceptOverClause(ctx);
|
||||
}
|
||||
@ -122,21 +122,20 @@ class DefaultAggregateFunction<T> extends AbstractAggregateFunction<T> {
|
||||
/**
|
||||
* Render <code>KEEP (DENSE_RANK [FIRST | LAST] ORDER BY {...})</code> clause
|
||||
*/
|
||||
final void toSQLKeepDenseRankOrderByClause(Context<?> ctx) {
|
||||
if (!Tools.isEmpty(keepDenseRankOrderBy)) {
|
||||
private final void acceptKeepDenseRankOrderByClause(Context<?> ctx) {
|
||||
if (!Tools.isEmpty(keepDenseRankOrderBy))
|
||||
ctx.sql(' ').visit(K_KEEP)
|
||||
.sql(" (").visit(K_DENSE_RANK)
|
||||
.sql(' ').visit(first ? K_FIRST : K_LAST)
|
||||
.sql(' ').visit(K_ORDER_BY)
|
||||
.sql(' ').visit(keepDenseRankOrderBy)
|
||||
.sql(')');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render <code>WITHIN GROUP (ORDER BY ..)</code> clause
|
||||
*/
|
||||
final void toSQLWithinGroupClause(Context<?> ctx) {
|
||||
private final void acceptWithinGroupClause(Context<?> ctx) {
|
||||
if (withinGroupOrderBy != null) {
|
||||
ctx.sql(' ').visit(K_WITHIN_GROUP)
|
||||
.sql(" (").visit(K_ORDER_BY).sql(' ');
|
||||
@ -153,14 +152,14 @@ class DefaultAggregateFunction<T> extends AbstractAggregateFunction<T> {
|
||||
/**
|
||||
* Render function arguments and argument modifiers
|
||||
*/
|
||||
final void toSQLArguments(Context<?> ctx) {
|
||||
private final void toSQLArguments(Context<?> ctx) {
|
||||
toSQLFunctionName(ctx);
|
||||
ctx.sql('(');
|
||||
acceptArguments0(ctx);
|
||||
ctx.sql(')');
|
||||
}
|
||||
|
||||
final void toSQLFunctionName(Context<?> ctx) {
|
||||
private final void toSQLFunctionName(Context<?> ctx) {
|
||||
if (term != null)
|
||||
ctx.sql(term.translate(ctx.dialect()));
|
||||
else
|
||||
|
||||
@ -55,7 +55,7 @@ final class Function<T> extends AbstractField<T> {
|
||||
private final QueryPartList<Field<?>> arguments;
|
||||
|
||||
Function(String name, DataType<T> type, Field<?>... arguments) {
|
||||
this(DSL.name(name), type, arguments);
|
||||
this(DSL.unquotedName(name), type, arguments);
|
||||
}
|
||||
|
||||
Function(Name name, DataType<T> type, Field<?>... arguments) {
|
||||
@ -66,8 +66,6 @@ final class Function<T> extends AbstractField<T> {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
|
||||
// For historic reasons, we're not generating the quoted name here.
|
||||
ctx.sql(getName()).sql('(').visit(arguments).sql(')');
|
||||
ctx.visit(getQualifiedName()).sql('(').visit(arguments).sql(')');
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,6 +61,7 @@ final class Names {
|
||||
static final Name N_CEIL = DSL.unquotedName("ceil");
|
||||
static final Name N_CHOOSE = DSL.unquotedName("choose");
|
||||
static final Name N_COALESCE = DSL.unquotedName("coalesce");
|
||||
static final Name N_COLLECT = DSL.unquotedName("collect");
|
||||
static final Name N_CONCAT = DSL.unquotedName("concat");
|
||||
static final Name N_CONVERT = DSL.unquotedName("convert");
|
||||
static final Name N_COSH = DSL.unquotedName("cosh");
|
||||
|
||||
@ -570,7 +570,7 @@ final class ParserImpl implements Parser {
|
||||
return dsl.queries(result);
|
||||
}
|
||||
|
||||
private static final Pattern P_SEARCH_PATH = Pattern.compile("select\\s+(pg_catalog\\s*\\.\\s*)?set_config\\s*\\(\\s*'search_path'\\s*,\\s*'([^']*)'\\s*,\\s*\\w+\\s*\\)");
|
||||
private static final Pattern P_SEARCH_PATH = Pattern.compile("(?i:select\\s+(pg_catalog\\s*\\.\\s*)?set_config\\s*\\(\\s*'search_path'\\s*,\\s*'([^']*)'\\s*,\\s*\\w+\\s*\\))");
|
||||
|
||||
private final Query patchParsedQuery(ParserContext ctx, Query query) {
|
||||
|
||||
|
||||
@ -39,7 +39,6 @@ package org.jooq.impl;
|
||||
|
||||
import org.jooq.Keyword;
|
||||
import org.jooq.Name;
|
||||
// ...
|
||||
import org.jooq.SQLDialect;
|
||||
|
||||
/**
|
||||
@ -121,10 +120,6 @@ enum Term {
|
||||
return "char_length";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
MODE {
|
||||
@Override
|
||||
public String translate(SQLDialect dialect) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user