[#430] Add support for the Firebird database - Fixed LIMIT
This commit is contained in:
parent
deb5529a2f
commit
4ff3c98bcc
@ -1851,6 +1851,9 @@ SELECT * FROM BOOK OFFSET 2 ROWS FETCH NEXT 1 ROWS ONLY
|
||||
-- Ingres
|
||||
SELECT * FROM BOOK OFFSET 2 FETCH FIRST 1 ROWS ONLY
|
||||
|
||||
-- Firebird
|
||||
SELECT FIRST 1 SKIP 3 * FROM BOOK
|
||||
|
||||
-- Sybase SQL Anywhere
|
||||
SELECT TOP 1 ROWS START AT 3 * FROM BOOK
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ package org.jooq;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.DB2;
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.INGRES;
|
||||
@ -103,7 +104,7 @@ public interface OrderProvider {
|
||||
* This clause can be used only along with Oracle's <code>CONNECT BY</code>
|
||||
* clause, to indicate that the hierarchical ordering should be preserved
|
||||
* and elements of each hierarchy should be ordered among themselves.
|
||||
*
|
||||
*
|
||||
* @param orderBySiblings
|
||||
*/
|
||||
@Support({ CUBRID, ORACLE })
|
||||
@ -152,7 +153,7 @@ public interface OrderProvider {
|
||||
* @param offset The lowest offset starting at 0
|
||||
* @param numberOfRows The number of rows to return
|
||||
*/
|
||||
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
void addLimit(int offset, int numberOfRows);
|
||||
|
||||
/**
|
||||
|
||||
@ -38,6 +38,7 @@ package org.jooq;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.DB2;
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.INGRES;
|
||||
@ -134,7 +135,7 @@ public interface SelectLimitStep extends SelectForUpdateStep {
|
||||
* simulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
SelectForUpdateStep limit(int offset, int numberOfRows);
|
||||
|
||||
/**
|
||||
|
||||
@ -38,6 +38,7 @@ package org.jooq;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.DB2;
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.INGRES;
|
||||
@ -100,7 +101,7 @@ public interface SelectOffsetStep extends SelectForUpdateStep {
|
||||
* simulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
SelectForUpdateStep offset(int offset);
|
||||
|
||||
/**
|
||||
|
||||
@ -38,6 +38,7 @@ package org.jooq;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.DB2;
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.INGRES;
|
||||
@ -110,7 +111,7 @@ public interface SimpleSelectLimitStep<R extends Record> extends SimpleSelectFor
|
||||
* simulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
SimpleSelectForUpdateStep<R> limit(int offset, int numberOfRows);
|
||||
|
||||
/**
|
||||
|
||||
@ -38,6 +38,7 @@ package org.jooq;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.DB2;
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.SQLDialect.INGRES;
|
||||
@ -77,7 +78,7 @@ public interface SimpleSelectOffsetStep<R extends Record> extends SimpleSelectFo
|
||||
* simulated with a <code>ROW_NUMBER()</code> window function and nested
|
||||
* <code>SELECT</code> statements.
|
||||
*/
|
||||
@Support({ CUBRID, DB2, DERBY, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE })
|
||||
SimpleSelectForUpdateStep<R> offset(int offset);
|
||||
|
||||
/**
|
||||
|
||||
@ -216,8 +216,9 @@ implements
|
||||
break;
|
||||
}
|
||||
|
||||
// Sybase has TOP .. START AT support, but only without bind
|
||||
// variables
|
||||
// Sybase has TOP .. START AT support (no bind values)
|
||||
// Firebird has FIRST .. SKIP support (no bind values)
|
||||
case FIREBIRD:
|
||||
case SYBASE: {
|
||||
|
||||
// Native TOP support, without OFFSET and without bind values
|
||||
@ -462,6 +463,7 @@ implements
|
||||
break;
|
||||
}
|
||||
|
||||
case FIREBIRD:
|
||||
case SYBASE: {
|
||||
if (getLimit().isApplicable() && !getLimit().rendersParams()) {
|
||||
context.sql(getLimit()).sql(" ");
|
||||
|
||||
@ -54,11 +54,12 @@ class Limit extends AbstractQueryPart {
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 2053741242981425602L;
|
||||
|
||||
private Field<Integer> numberOfRows;
|
||||
private Field<Integer> offset;
|
||||
private Field<Integer> offsetOrZero = val(0);
|
||||
private Field<Integer> offsetPlusOne = val(1);
|
||||
private boolean rendersParams;;
|
||||
private boolean rendersParams;
|
||||
|
||||
@Override
|
||||
public final void toSQL(RenderContext context) {
|
||||
@ -143,6 +144,19 @@ class Limit extends AbstractQueryPart {
|
||||
break;
|
||||
}
|
||||
|
||||
// Nice FIRST .. SKIP support
|
||||
// --------------------------
|
||||
case FIREBIRD: {
|
||||
context.inline(true)
|
||||
.keyword("first ")
|
||||
.sql(numberOfRows)
|
||||
.keyword(" skip ")
|
||||
.sql(offsetOrZero)
|
||||
.inline(inline);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Only "TOP" support provided by the following dialects.
|
||||
// "OFFSET" support is simulated with nested selects
|
||||
// -----------------------------------------------------------------
|
||||
@ -247,6 +261,12 @@ class Limit extends AbstractQueryPart {
|
||||
break;
|
||||
}
|
||||
|
||||
// No bind variables in the FIRST .. SKIP clause
|
||||
// ---------------------------------------------
|
||||
case FIREBIRD: {
|
||||
break;
|
||||
}
|
||||
|
||||
// These dialects don't allow bind variables in their TOP clauses
|
||||
// --------------------------------------------------------------
|
||||
case DB2:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user