[#595] Add support for Oracle's PIVOT clause - Prefer replacing "FOR" by "OVER" rather than by "OF"

This commit is contained in:
Lukas Eder 2012-01-07 10:14:24 +00:00
parent 45176b07cf
commit 1a90f3d7cd
3 changed files with 10 additions and 10 deletions

View File

@ -9209,7 +9209,7 @@ public abstract class jOOQAbstractTest<
create().select()
.from(TBookToBookStore()
.pivot(count())
.of(TBookToBookStore_BOOK_STORE_NAME())
.over(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"))
.of(TBookToBookStore_BOOK_STORE_NAME())
.over(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())
.of(lang)
.over(lang)
.in(1, 2, 3, 4))
.fetch();

View File

@ -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>of</code> is close
* reserved word in Java and cannot be used. <code>over</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> of(Field<T> field);
<T> PivotInStep<T> over(Field<T> field);
}

View File

@ -68,7 +68,7 @@ implements
private final Table<?> table;
private final FieldList aggregateFunctions;
private Field<T> of;
private Field<T> over;
private FieldList in;
Pivot(Table<?> table, Field<?>... aggregateFunctions) {
@ -100,7 +100,7 @@ implements
.declareFields(true)
.sql(aggregateFunctions)
.sql(" for ")
.literal(of.getName())
.literal(over.getName())
.sql(" in (")
.sql(in)
.declareFields(declare)
@ -130,7 +130,7 @@ implements
@Override
protected final List<Attachable> getAttachables0() {
return getAttachables(table, aggregateFunctions, of, in);
return getAttachables(table, aggregateFunctions, over, in);
}
// ------------------------------------------------------------------------
@ -139,9 +139,9 @@ implements
@SuppressWarnings("unchecked")
@Override
public final <Z> Pivot<Z> of(Field<Z> field) {
public final <Z> Pivot<Z> over(Field<Z> field) {
// The previous bound of <T> is Object, but that's irrelevant
this.of = (Field<T>) field;
this.over = (Field<T>) field;
return (Pivot<Z>) this;
}