[#595] Add support for Oracle's PIVOT clause - Prefer replacing "FOR" by "ON" rather than by "OVER", "OF"
This commit is contained in:
parent
1a90f3d7cd
commit
7e466b72ea
@ -9209,7 +9209,7 @@ public abstract class jOOQAbstractTest<
|
||||
create().select()
|
||||
.from(TBookToBookStore()
|
||||
.pivot(count())
|
||||
.over(TBookToBookStore_BOOK_STORE_NAME())
|
||||
.on(TBookToBookStore_BOOK_STORE_NAME())
|
||||
.in("Orell Füssli",
|
||||
"Ex Libris",
|
||||
"Buchhandlung im Volkshaus"))
|
||||
@ -9253,7 +9253,7 @@ public abstract class jOOQAbstractTest<
|
||||
max(TBookToBookStore_STOCK()).as("MAX"),
|
||||
sum(TBookToBookStore_STOCK()).as("SUM"),
|
||||
count(TBookToBookStore_STOCK()).as("CNT"))
|
||||
.over(TBookToBookStore_BOOK_STORE_NAME())
|
||||
.on(TBookToBookStore_BOOK_STORE_NAME())
|
||||
.in(val("Orell Füssli").as("BS1"),
|
||||
val("Ex Libris").as("BS2"),
|
||||
val("Buchhandlung im Volkshaus").as("BS3")))
|
||||
@ -9301,7 +9301,7 @@ public abstract class jOOQAbstractTest<
|
||||
.from(table(create().select(TBook_AUTHOR_ID(), lang)
|
||||
.from(TBook()))
|
||||
.pivot(count())
|
||||
.over(lang)
|
||||
.on(lang)
|
||||
.in(1, 2, 3, 4))
|
||||
.fetch();
|
||||
|
||||
|
||||
@ -48,12 +48,12 @@ public interface PivotForStep {
|
||||
/**
|
||||
* Add a list of fields to the <code>PIVOT</code> clause. Normally, the
|
||||
* keyword used here would be <code>FOR</code>, but <code>for</code> is a
|
||||
* reserved word in Java and cannot be used. <code>over</code> is close
|
||||
* reserved word in Java and cannot be used. <code>on</code> is close
|
||||
* enough.
|
||||
*
|
||||
* @param field The pivoting field
|
||||
* @return A DSL object to create the <code>PIVOT</code> expression
|
||||
*/
|
||||
@Support({ ORACLE })
|
||||
<T> PivotInStep<T> over(Field<T> field);
|
||||
<T> PivotInStep<T> on(Field<T> field);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ implements
|
||||
|
||||
private final Table<?> table;
|
||||
private final FieldList aggregateFunctions;
|
||||
private Field<T> over;
|
||||
private Field<T> on;
|
||||
private FieldList in;
|
||||
|
||||
Pivot(Table<?> table, Field<?>... aggregateFunctions) {
|
||||
@ -100,7 +100,7 @@ implements
|
||||
.declareFields(true)
|
||||
.sql(aggregateFunctions)
|
||||
.sql(" for ")
|
||||
.literal(over.getName())
|
||||
.literal(on.getName())
|
||||
.sql(" in (")
|
||||
.sql(in)
|
||||
.declareFields(declare)
|
||||
@ -130,7 +130,7 @@ implements
|
||||
|
||||
@Override
|
||||
protected final List<Attachable> getAttachables0() {
|
||||
return getAttachables(table, aggregateFunctions, over, in);
|
||||
return getAttachables(table, aggregateFunctions, on, in);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -139,9 +139,9 @@ implements
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final <Z> Pivot<Z> over(Field<Z> field) {
|
||||
public final <Z> Pivot<Z> on(Field<Z> field) {
|
||||
// The previous bound of <T> is Object, but that's irrelevant
|
||||
this.over = (Field<T>) field;
|
||||
this.on = (Field<T>) field;
|
||||
return (Pivot<Z>) this;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user