[#1523] Support ROW_NUMBER() OVER() for the latest version of Derby and

H2, which support it
This commit is contained in:
Lukas Eder 2012-07-01 10:49:38 +02:00
parent 71588514ff
commit 577ddd4a60
3 changed files with 23 additions and 4 deletions

View File

@ -70,6 +70,7 @@ import static org.jooq.impl.Factory.varPop;
import static org.jooq.impl.Factory.varSamp;
import java.math.BigDecimal;
import java.util.List;
import org.jooq.Field;
import org.jooq.Record;
@ -255,8 +256,6 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658,
switch (getDialect()) {
case ASE:
case CUBRID:
case DERBY:
case H2:
case HSQLDB:
case INGRES:
case MYSQL:
@ -265,6 +264,20 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T658,
return;
}
// [#1523] Derby now supports the ROW_NUMBER() OVER() window function
// without any window clause, though
List<Integer> rows =
create().select(rowNumber().over()).from(TBook()).fetch(0, Integer.class);
assertEquals(asList(1, 2, 3, 4), rows);
switch (getDialect()) {
case DERBY:
case H2:
log.info("SKIPPING", "Advanced window function tests");
return;
}
int column = 0;
// ROW_NUMBER()

View File

@ -36,6 +36,8 @@
package org.jooq;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLSERVER;
@ -65,7 +67,7 @@ public interface WindowOverStep<T> {
/**
* Add an <code>OVER</code> clause
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, DERBY, H2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
WindowPartitionByStep<T> over();
}

View File

@ -5098,8 +5098,12 @@ public class Factory implements FactoryOperations {
* <p>
* Window functions are supported in DB2, Postgres, Oracle, SQL Server and
* Sybase.
* <p>
* Newer versions of {@link SQLDialect#DERBY} and {@link SQLDialect#H2} also
* support the <code>ROW_NUMBER() OVER()</code> window function without any
* window clause. See the respective docs for details
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, DERBY, H2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
public static WindowOverStep<Integer> rowNumber() {
return new Function<Integer>("row_number", SQLDataType.INTEGER);
}