[#3045] DSL.groupConcat() without orderBy() is incorrectly emulated for Oracle
This commit is contained in:
parent
d9328672d6
commit
6b941eda98
@ -59,6 +59,7 @@ import static org.jooq.impl.Keywords.K_FIRST;
|
||||
import static org.jooq.impl.Keywords.K_IGNORE_NULLS;
|
||||
import static org.jooq.impl.Keywords.K_KEEP;
|
||||
import static org.jooq.impl.Keywords.K_LAST;
|
||||
import static org.jooq.impl.Keywords.K_NULL;
|
||||
import static org.jooq.impl.Keywords.K_ORDER_BY;
|
||||
import static org.jooq.impl.Keywords.K_OVER;
|
||||
import static org.jooq.impl.Keywords.K_RESPECT_NULLS;
|
||||
@ -408,12 +409,15 @@ class Function<T> extends AbstractField<T> implements
|
||||
* Render <code>WITHIN GROUP (ORDER BY ..)</code> clause
|
||||
*/
|
||||
final void toSQLWithinGroupClause(Context<?> ctx) {
|
||||
if (!withinGroupOrderBy.isEmpty()) {
|
||||
ctx.sql(' ').visit(K_WITHIN_GROUP)
|
||||
.sql(" (").visit(K_ORDER_BY)
|
||||
.sql(' ').visit(withinGroupOrderBy)
|
||||
.sql(')');
|
||||
}
|
||||
ctx.sql(' ').visit(K_WITHIN_GROUP)
|
||||
.sql(" (").visit(K_ORDER_BY).sql(' ');
|
||||
|
||||
if (withinGroupOrderBy.isEmpty())
|
||||
ctx.visit(K_NULL);
|
||||
else
|
||||
ctx.visit(withinGroupOrderBy);
|
||||
|
||||
ctx.sql(')');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -89,13 +89,10 @@ final class GroupConcat extends AbstractFunction<String> implements GroupConcatO
|
||||
final Field<String> getFunction0(Configuration configuration) {
|
||||
Function<String> result;
|
||||
|
||||
if (separator == null) {
|
||||
result = new Function<String>(Term.LIST_AGG, distinct, SQLDataType.VARCHAR, field);
|
||||
}
|
||||
else {
|
||||
Field<String> literal = inline(separator);
|
||||
result = new Function<String>(Term.LIST_AGG, distinct, SQLDataType.VARCHAR, field, literal);
|
||||
}
|
||||
if (separator == null)
|
||||
result = new Function<String>(Term.LIST_AGG, distinct, SQLDataType.VARCHAR, field, inline(","));
|
||||
else
|
||||
result = new Function<String>(Term.LIST_AGG, distinct, SQLDataType.VARCHAR, field, inline(separator));
|
||||
|
||||
return result.withinGroupOrderBy(orderBy);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user