- Add SQLDialect.family() to group several SQLDialect versions of
the same RDBMS
- Add support for SQL Server 2012 native OFFSET .. FETCH clause
This commit is contained in:
Lukas Eder 2013-06-01 19:19:13 +02:00
parent 1ba458e18e
commit ec1b840cb5
82 changed files with 402 additions and 364 deletions

View File

@ -300,7 +300,7 @@ class LocalStatementExecutor implements QueryExecutor {
} else {
queryExecutionResult = new QueryExecutionMessageResult(Utils.formatDuration(executionDuration) + "> " + updateCount + " row(s) affected.", false);
}
if(executorContext.getSQLDialect() == SQLDialect.SQLSERVER) {
if(executorContext.getSQLDialect().family() == SQLDialect.SQLSERVER) {
try {
executeResult = stmt.getMoreResults(Statement.KEEP_CURRENT_RESULT);
} catch(Exception e) {

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/jOOQ-test/src/org/jooq/test/SQLServerTest.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.jooq.test.SQLServer2008Test"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="jOOQ-test"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.jooq.configuration=/org/jooq/configuration/${env_var:USERNAME}/sqlserver/library.xml&#13;&#10;-Djava.library.path=C:\sqljdbc_4.0\enu\auth\x64"/>
</launchConfiguration>

View File

@ -0,0 +1,53 @@
/**
* Copyright (c) 2009-2013, Lukas Eder, lukas.eder@gmail.com
* All rights reserved.
*
* This software is licensed to you under the Apache License, Version 2.0
* (the "License"); You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* . Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* . Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* . Neither the name "jOOQ" nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.jooq.test;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import org.jooq.conf.Settings;
import org.jooq.impl.DSL;
/**
* @author Lukas Eder
*/
public class SQLServer2008Test extends SQLServerTest {
@Override
protected DSLContext create0(Settings settings) {
return DSL.using(getConnection(), SQLDialect.SQLSERVER2008, settings);
}
}

View File

@ -130,7 +130,7 @@ public class SQLServerTest extends jOOQAbstractTest<
@Override
protected DSLContext create0(Settings settings) {
return DSL.using(getConnection(), SQLDialect.SQLSERVER, settings);
return DSL.using(getConnection(), SQLDialect.SQLSERVER2012, settings);
}
@Override

View File

@ -157,7 +157,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
// Some dialects don't support a median function or a simulation thereof
// Use AVG instead, as in this example the values of MEDIAN and AVG
// are the same
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DERBY:
@ -307,7 +307,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
// [#1728] COUNT(DISTINCT expr1, expr2, ...)
// -----------------------------------------
if (asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, INGRES, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE).contains(dialect())) {
if (asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, INGRES, ORACLE, POSTGRES, SQLITE, SQLSERVER, SYBASE).contains(dialect().family())) {
log.info("SKIPPING", "Multi-expression COUNT(DISTINCT) test");
}
else {
@ -320,7 +320,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testLinearRegressionFunctions() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DERBY:
@ -716,7 +716,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
assertEquals(Integer.valueOf(3), result.getValue(3, column));
}
switch (dialect()) {
switch (dialect().family()) {
case CUBRID:
case POSTGRES:
case SQLSERVER:
@ -893,7 +893,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testListAgg() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case DERBY:
case INGRES:

View File

@ -193,7 +193,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testAliasingDelete() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case SQLITE:
case SQLSERVER:
log.info("SKIPPING", "Aliasing DELETE tests");

View File

@ -564,7 +564,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
assertEquals("Amazon", store.getValue(TBookStore_NAME()));
assertEquals(null, create().fetchOne(TBookStore(), TBookStore_NAME().equal("Amazon")));
switch (dialect()) {
switch (dialect().family()) {
// Sybase ASE and SQL server do not allow for explicitly setting
// values on IDENTITY columns
case ASE:

View File

@ -1367,7 +1367,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
dialect() == H2 ||
dialect() == INGRES || // [#1285] TODO: Fix this for Ingres
dialect() == MYSQL ||
dialect() == SQLSERVER ||
dialect().family() == SQLSERVER ||
dialect() == SQLITE ||
dialect() == SYBASE) {
@ -1623,14 +1623,14 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
Result<Record4<Long, String, Short, String>> result =
create().select(
id1,
id2,
id1.as("id1"),
id2.as("id2"),
val("1").coerce(Short.class),
val(2).coerce(String.class))
.from(TBook())
.where(id1.in(val(1).coerce(Long.class), val(2).coerce(Long.class)))
.and(id2.in(val(1).coerce(String.class), val(2).coerce(String.class)))
.orderBy(id1, id2)
.orderBy(id1.as("id1"), id2.as("id2"))
.fetch();
assertEquals(2, result.size());

View File

@ -142,7 +142,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testPivotClause() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DB2:
@ -273,7 +273,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testAliasingPivot() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DB2:
@ -390,7 +390,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testConnectBySimple() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case DB2:
case DERBY:
@ -449,7 +449,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testConnectByDirectory() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case DB2:
case DERBY:

View File

@ -598,7 +598,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
public void testFunctionsOnStrings_HashFunctions() throws Exception {
// MD5
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DB2:
@ -1021,7 +1021,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
Field<Integer> bitCount = bitCount(3);
// TODO [#896] This somehow doesn't work on some dialects
if (asList(ASE, DB2, SQLSERVER).contains(dialect())) {
if (asList(ASE, DB2, SQLSERVER).contains(dialect().family())) {
bitCount = val(2);
}

View File

@ -190,7 +190,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
// TODO ... and then, think about Ingres, H2 and Derby as well
if (dialect() == CUBRID ||
dialect() == SYBASE ||
dialect() == SQLSERVER ||
dialect().family() == SQLSERVER ||
dialect() == INGRES ||
dialect() == H2 ||
dialect() == DERBY ||
@ -470,7 +470,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testUpdateWithRowValueExpression() throws Exception {
if (asList(ASE, CUBRID, DERBY, FIREBIRD, MYSQL, SQLSERVER, SQLITE, SYBASE).contains(dialect())) {
if (asList(ASE, CUBRID, DERBY, FIREBIRD, MYSQL, SQLSERVER, SQLITE, SYBASE).contains(dialect().family())) {
log.info("SKIPPING", "UPDATE with row value expression tests");
return;
}
@ -625,7 +625,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
assertNull(returned.getValue(TTriggers_ID()));
assertNull(returned.getValue(TTriggers_COUNTER()));
switch (dialect()) {
switch (dialect().family()) {
case ASE:
// TODO [#1260] This should work eventually, when CUBRID fixes this
// JDBC bug
@ -731,7 +731,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testUpdateReturning() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DB2:
@ -981,7 +981,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testMergeWithOracleSyntaxExtension() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case DB2:
case DERBY:
@ -1204,7 +1204,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testUpdateJoin() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case DB2:
case DERBY:
case FIREBIRD:

View File

@ -85,8 +85,8 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
Connection c = cp.acquire();
try {
assertEquals(create().configuration().dialect(), JDBCUtils.dialect(getConnection()));
assertEquals(create().configuration().dialect(), JDBCUtils.dialect(c));
assertEquals(create().configuration().dialect().family(), JDBCUtils.dialect(getConnection()).family());
assertEquals(create().configuration().dialect().family(), JDBCUtils.dialect(c).family());
}
finally {
cp.release(c);

View File

@ -333,7 +333,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
&& dialect() != SQLDialect.ORACLE
&& dialect() != SQLDialect.POSTGRES
&& dialect() != SQLDialect.SQLITE
&& dialect() != SQLDialect.SQLSERVER) {
&& dialect().family() != SQLDialect.SQLSERVER) {
assertEquals(BigDecimal.class, field.getType());
assertEquals(SQLDataType.DECIMAL.getType(), field.getDataType().getType());
@ -378,7 +378,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
// [#746] TODO: Fix this, too
else if ("DOUBLE".equalsIgnoreCase(field.getName())
&& dialect() != SQLDialect.SQLSERVER
&& dialect().family() != SQLDialect.SQLSERVER
&& dialect() != SQLDialect.ASE) {
assertEquals(Double.class, field.getType());

View File

@ -39,12 +39,8 @@ import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.jooq.SQLDialect.ASE;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.INGRES;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SYBASE;
import static org.jooq.impl.DSL.count;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.lower;
@ -278,9 +274,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
public void testLimit() throws Exception {
// Some dialects don't support LIMIT 0 / TOP 0
int lower = asList(DB2, DERBY, HSQLDB, INGRES, SYBASE).contains(dialect()) ? 1 : 0;
for (int i = lower; i < 6; i++) {
for (int i = 1; i < 6; i++) {
assertEquals(Math.min(i, 4),
create().selectFrom(TBook()).limit(i).fetch().size());
assertEquals(Math.min(i, 4),
@ -292,7 +286,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
return;
}
for (int i = lower; i < 6; i++) {
for (int i = 1; i < 6; i++) {
assertEquals(Math.min(i, 3),
create().selectFrom(TBook()).limit(1, i).fetch().size());
assertEquals(Math.min(i, 3),
@ -315,7 +309,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testLimitAliased() throws Exception {
if (asList(ASE, SQLSERVER).contains(dialect())) {
if (asList(ASE, SQLSERVER).contains(dialect().family())) {
log.info("SKIPPING", "LIMIT .. OFFSET tests");
return;
}
@ -387,9 +381,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
}
// Some dialects don't support LIMIT 0 / TOP 0
int lower = asList(DB2, DERBY, HSQLDB, SYBASE).contains(dialect()) ? 1 : 0;
for (int i = lower; i < 6; i++) {
for (int i = 1; i < 6; i++) {
Select<?> s1 = create().selectFrom(TBook()).limit(param("limit", i));
Select<?> s2 = create().select().from(TBook()).limit(param("limit", i));
@ -399,7 +391,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
assertEquals(Math.min(i + 1, 4), s2.bind("limit", i + 1).fetch().size());
}
for (int i = lower; i < 6; i++) {
for (int i = 1; i < 6; i++) {
Select<?> s1a = create().selectFrom(TBook()).limit(param("offset", 1), i);
Select<?> s1b = create().selectFrom(TBook()).limit(1, param("limit", i));
Select<?> s1c = create().selectFrom(TBook()).limit(param("offset", 1), param("limit", i));

View File

@ -314,7 +314,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testLikeRegex() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case DB2:
case DERBY:

View File

@ -163,7 +163,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
// Schema mapping is supported in many RDBMS. But maintaining several
// databases is non-trivial in some of them.
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DB2:

View File

@ -105,7 +105,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testTruncateCascade() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DB2:
@ -143,7 +143,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
@Test
public void testTruncateRestartIdentity() throws Exception {
switch (dialect()) {
switch (dialect().family()) {
case ASE:
case CUBRID:
case DB2:

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SQLSERVER2012;
import static org.jooq.SQLDialect.SYBASE;
import java.math.BigInteger;
@ -4554,7 +4555,7 @@ public interface DSLContext {
*
* @throws DataAccessException if something went wrong executing the query
*/
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, POSTGRES, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, POSTGRES, SQLSERVER2012, SYBASE })
<T extends Number> T nextval(Sequence<T> sequence) throws DataAccessException;
/**
@ -4563,7 +4564,7 @@ public interface DSLContext {
*
* @throws DataAccessException if something went wrong executing the query
*/
@Support({ CUBRID, DB2, FIREBIRD, H2, INGRES, ORACLE, POSTGRES, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, FIREBIRD, H2, INGRES, ORACLE, POSTGRES, SQLSERVER2012, SYBASE })
<T extends Number> T currval(Sequence<T> sequence) throws DataAccessException;
// -------------------------------------------------------------------------

View File

@ -37,14 +37,22 @@
package org.jooq;
/**
* This enumeration lists all supported dialects.
* Dialects and dialect families as supported by jOOQ.
* <p>
* jOOQ supports a variety of dialects, which are grouped into dialect families.
* For instance, the SQL Server dialect family {@link #SQLSERVER} is specialised
* by its dialects
* <ul>
* <li> {@link #SQLSERVER2008}</li>
* <li> {@link #SQLSERVER2012}</li>
* </ul>
*
* @author Lukas Eder
*/
public enum SQLDialect {
/**
* The standard SQL dialect.
* The standard SQL dialect family.
*
* @deprecated - Do not reference this pseudo-dialect. It is only used for
* unit testing
@ -53,79 +61,109 @@ public enum SQLDialect {
SQL99(null),
/**
* The Sybase Adaptive Server SQL dialect
* The Sybase Adaptive Server SQL dialect family.
*/
ASE("ASE"),
/**
* The CUBRID SQL dialect
* The CUBRID SQL dialect family.
*/
CUBRID("CUBRID"),
/**
* The IBM DB2 SQL dialect
* The IBM DB2 SQL dialect family.
*/
DB2("DB2"),
/**
* The Apache Derby SQL dialect
* The Apache Derby SQL dialect family.
*/
DERBY("Derby"),
/**
* The Firebird SQL dialect
* The Firebird SQL dialect family.
*/
FIREBIRD("Firebird"),
/**
* The H2 SQL dialect
* The H2 SQL dialect family.
*/
H2("H2"),
/**
* The Hypersonic SQL dialect
* The Hypersonic SQL dialect family.
*/
HSQLDB("HSQLDB"),
/**
* The Ingres dialect
* The Ingres dialect family.
*/
INGRES("Ingres"),
/**
* The MySQL dialect
* The MySQL dialect family.
*/
MYSQL("MySQL"),
/**
* The Oracle dialect
* The Oracle dialect family.
*/
ORACLE("Oracle"),
/**
* The PostGres dialect
* The PostgreSQL dialect family.
*/
POSTGRES("Postgres"),
/**
* The SQLite dialect
* The SQLite dialect family.
*/
SQLITE("SQLite"),
/**
* The SQL Server dialect
* The SQL Server dialect family.
*/
SQLSERVER("SQLServer"),
/**
* The Sybase dialect
* The SQL Server 2008 dialect.
*/
SQLSERVER2008("SQLServer", SQLSERVER),
/**
* The SQL Server 2012 dialect.
*/
SQLSERVER2012("SQLServer", SQLSERVER),
/**
* The Sybase SQL Anywhere dialect family.
*/
SYBASE("Sybase");
private final String name;
private final String name;
private final SQLDialect family;
private SQLDialect(String name) {
this(name, null);
}
private SQLDialect(String name, SQLDialect family) {
this.name = name;
this.family = family;
}
/**
* The dialect family.
* <p>
* This returns the dialect itself, if it has no "parent family". E.g.
* <code><pre>
* SQLSERVER == SQLSERVER2012.family();
* SQLSERVER == SQLSERVER2008.family();
* SQLSERVER == SQLSERVER.family();
* </pre></code>
*/
public final SQLDialect family() {
return family == null ? this : family;
}
/**
@ -143,7 +181,7 @@ public enum SQLDialect {
}
/**
* The name of this dialect as it appears in related enum values
* The name of this dialect as it appears in related enum values.
*/
public final String getNameUC() {
return name.toUpperCase();

View File

@ -44,7 +44,7 @@ import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.INGRES;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SQLSERVER2012;
import static org.jooq.SQLDialect.SYBASE;
import java.io.Serializable;
@ -74,12 +74,12 @@ public interface Sequence<T extends Number> extends Serializable {
/**
* Get the current value of this sequence
*/
@Support({ CUBRID, DB2, FIREBIRD, H2, INGRES, ORACLE, POSTGRES, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, FIREBIRD, H2, INGRES, ORACLE, POSTGRES, SQLSERVER2012, SYBASE })
Field<T> currval();
/**
* Increment the sequence and get the next value
*/
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, POSTGRES, SQLSERVER, SYBASE })
@Support({ CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, INGRES, ORACLE, POSTGRES, SQLSERVER2012, SYBASE })
Field<T> nextval();
}

View File

@ -38,7 +38,7 @@ package org.jooq;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SQLSERVER2012;
import static org.jooq.SQLDialect.SYBASE;
import org.jooq.api.annotation.State;
@ -56,9 +56,6 @@ import org.jooq.api.annotation.Transition;
* .rowsBetweenUnboundedPreceding()
* .andUnboundedFollowing()
* </pre></code>
* <p>
* Note, that the functionality provided by this interface is not supported in
* {@link SQLDialect#SQLSERVER}
*
* @param <T> The function return type
* @author Lukas Eder
@ -70,7 +67,7 @@ public interface WindowRowsAndStep<T> {
* Add a <code>... AND UNBOUNDED PRECEDING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "AND UNBOUNDED PRECEDING"
)
@ -80,7 +77,7 @@ public interface WindowRowsAndStep<T> {
* Add a <code>... AND [number] PRECEDING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "AND PRECEDING",
args = "Integer"
@ -91,7 +88,7 @@ public interface WindowRowsAndStep<T> {
* Add a <code>... AND CURRENT ROW</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "AND CURRENT ROW"
)
@ -101,7 +98,7 @@ public interface WindowRowsAndStep<T> {
* Add a <code>... AND UNBOUNDED FOLLOWING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "AND UNBOUNDED FOLLOWING"
)
@ -111,7 +108,7 @@ public interface WindowRowsAndStep<T> {
* Add a <code>... AND [number] FOLLOWING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "AND FOLLOWING",
args = "Integer"

View File

@ -38,7 +38,7 @@ package org.jooq;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SQLSERVER2012;
import static org.jooq.SQLDialect.SYBASE;
import org.jooq.api.annotation.State;
@ -56,9 +56,6 @@ import org.jooq.api.annotation.Transition;
* .rowsBetweenUnboundedPreceding()
* .andUnboundedFollowing()
* </pre></code>
* <p>
* Note, that the functionality provided by this interface is not supported in
* {@link SQLDialect#SQLSERVER}
*
* @param <T> The function return type
* @author Lukas Eder
@ -70,7 +67,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS UNBOUNDED PRECEDING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS UNBOUNDED PRECEDING"
)
@ -80,7 +77,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS [number] PRECEDING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS PRECEDING",
args = "Integer"
@ -90,7 +87,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
/**
* Add a <code>ROWS CURRENT ROW</code> frame clause to the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS CURRENT ROW"
)
@ -100,7 +97,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS UNBOUNDED FOLLOWING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS UNBOUNDED FOLLOWING"
)
@ -110,7 +107,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS [number] FOLLOWING</code> frame clause to the window
* function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS FOLLOWING",
args = "Integer"
@ -121,7 +118,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS BETWEEN UNBOUNDED PRECEDING ...</code> frame clause to
* the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS BETWEEN UNBOUNDED PRECEDING"
)
@ -131,7 +128,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS BETWEEN [number] PRECEDING ...</code> frame clause to
* the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS BETWEEN PRECEDING",
args = "Integer"
@ -142,7 +139,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS BETWEEN CURRENT ROW ...</code> frame clause to
* the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS BETWEEN CURRENT ROW"
)
@ -152,7 +149,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS BETWEEN UNBOUNDED FOLLOWING ...</code> frame clause to
* the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS BETWEEN UNBOUNDED FOLLOWING"
)
@ -162,7 +159,7 @@ public interface WindowRowsStep<T> extends WindowFinalStep<T> {
* Add a <code>ROWS BETWEEN [number] FOLLOWING ...</code> frame clause to
* the window function.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "ROWS BETWEEN FOLLOWING",
args = "Integer"

View File

@ -237,7 +237,7 @@ abstract class AbstractResultQuery<R extends Record> extends AbstractQuery imple
// [#1296] These dialects do not implement FOR UPDATE. But the same
// effect can be achieved using ResultSet.CONCUR_UPDATABLE
else if (isForUpdate() && asList(CUBRID, SQLSERVER).contains(ctx.configuration().dialect())) {
else if (isForUpdate() && asList(CUBRID, SQLSERVER).contains(ctx.configuration().dialect().family())) {
ctx.data(DATA_LOCK_ROWS_FOR_UPDATE, true);
ctx.statement(ctx.connection().prepareStatement(ctx.sql(), TYPE_SCROLL_SENSITIVE, CONCUR_UPDATABLE));
}

View File

@ -35,6 +35,7 @@
*/
package org.jooq.impl;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.DSL.val;
@ -66,7 +67,6 @@ import org.jooq.Parameter;
import org.jooq.RenderContext;
import org.jooq.Result;
import org.jooq.Routine;
import org.jooq.SQLDialect;
import org.jooq.Schema;
import org.jooq.UDTField;
import org.jooq.UDTRecord;
@ -353,7 +353,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
Field<?> value = getInValues().get(parameter);
// Disambiguate overloaded procedure signatures
if (SQLDialect.POSTGRES == context.configuration().dialect() && isOverloaded()) {
if (POSTGRES == context.configuration().dialect() && isOverloaded()) {
value = value.cast(parameter.getType());
}
@ -705,7 +705,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
for (Parameter<?> p : getInParameters()) {
// Disambiguate overloaded function signatures
if (SQLDialect.POSTGRES == c.dialect() && isOverloaded()) {
if (POSTGRES == c.dialect() && isOverloaded()) {
array[i] = getInValues().get(p).cast(p.getType());
}
else {

View File

@ -198,7 +198,7 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractQuery implem
// Values should be returned from the INSERT
else {
switch (ctx.configuration().dialect()) {
switch (ctx.configuration().dialect().family()) {
// Postgres uses the RETURNING clause in SQL
case FIREBIRD:
@ -249,7 +249,7 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractQuery implem
else {
int result = 1;
ResultSet rs;
switch (ctx.configuration().dialect()) {
switch (ctx.configuration().dialect().family()) {
// SQLite can select _rowid_ after the insert
case SQLITE: {

View File

@ -104,7 +104,7 @@ class Alias<Q extends QueryPart> extends AbstractQueryPart {
// [#1801] Some databases don't allow "derived column names" in
// "simple class specifications". Hence, wrap the table reference in
// a subselect
if (fieldAliases != null && asList(CUBRID, FIREBIRD, SQLSERVER, SYBASE).contains(dialect) && wrapped instanceof TableImpl) {
if (fieldAliases != null && asList(CUBRID, FIREBIRD, SQLSERVER, SYBASE).contains(dialect.family()) && wrapped instanceof TableImpl) {
@SuppressWarnings("unchecked")
Select<Record> select =

View File

@ -106,7 +106,7 @@ class BetweenCondition<T> extends AbstractCondition implements BetweenAndStep<T>
}
private final QueryPartInternal delegate(Configuration configuration) {
if (symmetric && asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, MYSQL, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect())) {
if (symmetric && asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, MYSQL, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect().family())) {
if (not) {
return (QueryPartInternal) field.notBetween(minValue, maxValue).and(field.notBetween(maxValue, minValue));
}

View File

@ -60,7 +60,7 @@ class Ceil<T extends Number> extends AbstractFunction<T> {
@Override
final Field<T> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// evaluate "ceil" if unavailable
case SQLITE:

View File

@ -35,10 +35,10 @@
*/
package org.jooq.impl;
import static org.jooq.impl.ExpressionOperator.ADD;
import static org.jooq.impl.ExpressionOperator.CONCAT;
import static org.jooq.impl.DSL.castAll;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.ExpressionOperator.ADD;
import static org.jooq.impl.ExpressionOperator.CONCAT;
import org.jooq.Configuration;
import org.jooq.Field;
@ -73,7 +73,7 @@ class Concat extends AbstractFunction<String> {
Field<String>[] others = new Field[cast.length - 1];
System.arraycopy(cast, 1, others, 0, others.length);
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case MYSQL:
return function("concat", SQLDataType.VARCHAR, cast);

View File

@ -60,7 +60,7 @@ class ConditionAsField extends AbstractFunction<Boolean> {
@Override
final QueryPart getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// Some databases don't accept predicates where column expressions
// are expected.

View File

@ -64,7 +64,7 @@ class Cosh extends AbstractFunction<BigDecimal> {
@Override
final Field<BigDecimal> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case CUBRID:
case HSQLDB:

View File

@ -59,7 +59,7 @@ class CurrentDate extends AbstractFunction<Date> {
@Override
final Field<Date> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ORACLE:
return field("sysdate", SQLDataType.DATE);

View File

@ -59,7 +59,7 @@ class CurrentTime extends AbstractFunction<Time> {
@Override
final Field<Time> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ORACLE:
return field("sysdate", SQLDataType.TIME);

View File

@ -59,7 +59,7 @@ class CurrentTimestamp extends AbstractFunction<Timestamp> {
@Override
final Field<Timestamp> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
return function("current_bigdatetime", SQLDataType.TIMESTAMP);

View File

@ -57,7 +57,7 @@ class CurrentUser extends AbstractFunction<String> {
@Override
final Field<String> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case ORACLE:
return field("user", SQLDataType.VARCHAR);

View File

@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SQLSERVER2012;
import static org.jooq.SQLDialect.SYBASE;
import static org.jooq.impl.Term.ROW_NUMBER;
import static org.jooq.impl.Utils.combine;
@ -8434,7 +8435,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "PERCENT_RANK"
)
@ -8477,7 +8478,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "FIRST_VALUE",
args = "Field"
@ -8492,7 +8493,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER, SYBASE })
@Support({ DB2, POSTGRES, ORACLE, SQLSERVER2012, SYBASE })
@Transition(
name = "LAST_VALUE",
args = "Field"
@ -8507,7 +8508,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LEAD",
args = "Field"
@ -8522,7 +8523,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LEAD",
args = {
@ -8542,7 +8543,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LEAD",
args = {
@ -8563,7 +8564,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LEAD",
args = {
@ -8582,7 +8583,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LAG",
args = "Field"
@ -8597,7 +8598,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LAG",
args = {
@ -8617,7 +8618,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LAG",
args = {
@ -8638,7 +8639,7 @@ public class DSL {
* Window functions are supported in CUBRID, DB2, Postgres, Oracle, SQL
* Server and Sybase.
*/
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER, ORACLE })
@Support({ CUBRID, DB2, POSTGRES, SQLSERVER2012, ORACLE })
@Transition(
name = "LAG",
args = {

View File

@ -66,7 +66,7 @@ class DateDiff extends AbstractFunction<Integer> {
@Override
final Field<Integer> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case SQLSERVER:
case SYBASE:

View File

@ -147,7 +147,7 @@ class DefaultBindContext extends AbstractBindContext {
// [#725] For SQL Server, unknown types should be set to null
// explicitly, too
else if (configuration.dialect() == SQLSERVER) {
else if (configuration.dialect().family() == SQLSERVER) {
stmt.setNull(nextIndex(), sqlType);
}
@ -268,7 +268,7 @@ class DefaultBindContext extends AbstractBindContext {
stmt.setBigDecimal(nextIndex(), new BigDecimal(value.toString()));
}
else if (type == UUID.class) {
switch (dialect) {
switch (dialect.family()) {
// [#1624] Some JDBC drivers natively support the
// java.util.UUID data type

View File

@ -37,13 +37,6 @@
package org.jooq.impl;
import static org.jooq.KeepResultSetMode.CLOSE_AFTER_FETCH;
import static org.jooq.SQLDialect.CUBRID;
import static org.jooq.SQLDialect.DB2;
import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.HSQLDB;
import static org.jooq.SQLDialect.ORACLE;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SYBASE;
import static org.jooq.conf.ParamType.INLINED;
import static org.jooq.conf.ParamType.NAMED;
import static org.jooq.impl.DSL.field;
@ -172,7 +165,6 @@ import org.jooq.SelectQuery;
import org.jooq.SelectSelectStep;
import org.jooq.SelectWhereStep;
import org.jooq.Sequence;
import org.jooq.Support;
import org.jooq.Table;
import org.jooq.TableLike;
import org.jooq.TableRecord;
@ -354,133 +346,111 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// -------------------------------------------------------------------------
@Override
@Support
public <R extends TableRecord<R>> LoaderOptionsStep<R> loadInto(Table<R> table) {
return new LoaderImpl<R>(configuration, table);
}
@Override
@Support
public Query query(String sql) {
return query(sql, new Object[0]);
}
@Override
@Support
public Query query(String sql, Object... bindings) {
return new SQLQuery(configuration, sql, bindings);
}
@Override
@Support
public Query query(String sql, QueryPart... parts) {
return new SQLQuery(configuration, sql, parts);
}
@Override
@Support
public Result<Record> fetch(String sql) throws DataAccessException {
return resultQuery(sql).fetch();
}
@Override
@Support
public Result<Record> fetch(String sql, Object... bindings) throws DataAccessException {
return resultQuery(sql, bindings).fetch();
}
@Override
@Support
public Result<Record> fetch(String sql, QueryPart... parts) throws DataAccessException {
return resultQuery(sql, parts).fetch();
}
@Override
@Support
public Cursor<Record> fetchLazy(String sql) throws DataAccessException {
return resultQuery(sql).fetchLazy();
}
@Override
@Support
public Cursor<Record> fetchLazy(String sql, Object... bindings) throws DataAccessException {
return resultQuery(sql, bindings).fetchLazy();
}
@Override
@Support
public Cursor<Record> fetchLazy(String sql, QueryPart... parts) throws DataAccessException {
return resultQuery(sql, parts).fetchLazy();
}
@Override
@Support
public List<Result<Record>> fetchMany(String sql) throws DataAccessException {
return resultQuery(sql).fetchMany();
}
@Override
@Support
public List<Result<Record>> fetchMany(String sql, Object... bindings) throws DataAccessException {
return resultQuery(sql, bindings).fetchMany();
}
@Override
@Support
public List<Result<Record>> fetchMany(String sql, QueryPart... parts) throws DataAccessException {
return resultQuery(sql, parts).fetchMany();
}
@Override
@Support
public Record fetchOne(String sql) throws DataAccessException, InvalidResultException {
return resultQuery(sql).fetchOne();
}
@Override
@Support
public Record fetchOne(String sql, Object... bindings) throws DataAccessException, InvalidResultException {
return resultQuery(sql, bindings).fetchOne();
}
@Override
@Support
public Record fetchOne(String sql, QueryPart... parts) throws DataAccessException, InvalidResultException {
return resultQuery(sql, parts).fetchOne();
}
@Override
@Support
public int execute(String sql) throws DataAccessException {
return query(sql).execute();
}
@Override
@Support
public int execute(String sql, Object... bindings) throws DataAccessException {
return query(sql, bindings).execute();
}
@Override
@Support
public int execute(String sql, QueryPart... parts) throws DataAccessException {
return query(sql, parts).execute();
}
@Override
@Support
public ResultQuery<Record> resultQuery(String sql) {
return resultQuery(sql, new Object[0]);
}
@Override
@Support
public ResultQuery<Record> resultQuery(String sql, Object... bindings) {
return new SQLResultQuery(configuration, sql, bindings);
}
@Override
@Support
public ResultQuery<Record> resultQuery(String sql, QueryPart... parts) {
return new SQLResultQuery(configuration, sql, parts);
}
@ -490,55 +460,46 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// -------------------------------------------------------------------------
@Override
@Support
public Result<Record> fetch(ResultSet rs) throws DataAccessException {
return fetchLazy(rs).fetch();
}
@Override
@Support
public Result<Record> fetch(ResultSet rs, Field<?>... fields) throws DataAccessException {
return fetchLazy(rs, fields).fetch();
}
@Override
@Support
public Result<Record> fetch(ResultSet rs, DataType<?>... types) throws DataAccessException {
return fetchLazy(rs, types).fetch();
}
@Override
@Support
public Result<Record> fetch(ResultSet rs, Class<?>... types) throws DataAccessException {
return fetchLazy(rs, types).fetch();
}
@Override
@Support
public Record fetchOne(ResultSet rs) throws DataAccessException, InvalidResultException {
return Utils.fetchOne(fetchLazy(rs));
}
@Override
@Support
public Record fetchOne(ResultSet rs, Field<?>... fields) throws DataAccessException, InvalidResultException {
return Utils.fetchOne(fetchLazy(rs, fields));
}
@Override
@Support
public Record fetchOne(ResultSet rs, DataType<?>... types) throws DataAccessException, InvalidResultException {
return Utils.fetchOne(fetchLazy(rs, types));
}
@Override
@Support
public Record fetchOne(ResultSet rs, Class<?>... types) throws DataAccessException, InvalidResultException {
return Utils.fetchOne(fetchLazy(rs, types));
}
@Override
@Support
public Cursor<Record> fetchLazy(ResultSet rs) throws DataAccessException {
try {
return fetchLazy(rs, new MetaDataFieldProvider(configuration, rs.getMetaData()).getFields());
@ -549,7 +510,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public Cursor<Record> fetchLazy(ResultSet rs, Field<?>... fields) throws DataAccessException {
ExecuteContext ctx = new DefaultExecuteContext(configuration);
ExecuteListener listener = new ExecuteListeners(ctx);
@ -559,7 +519,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public Cursor<Record> fetchLazy(ResultSet rs, DataType<?>... types) throws DataAccessException {
try {
Field<?>[] fields = new Field[types.length];
@ -578,31 +537,26 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public Cursor<Record> fetchLazy(ResultSet rs, Class<?>... types) throws DataAccessException {
return fetchLazy(rs, Utils.getDataTypes(types));
}
@Override
@Support
public Result<Record> fetchFromTXT(String string) throws DataAccessException {
return fetchFromTXT(string, "{null}");
}
@Override
@Support
public Result<Record> fetchFromTXT(String string, String nullLiteral) throws DataAccessException {
return fetchFromStringData(Utils.parseTXT(string, nullLiteral));
}
@Override
@Support
public Result<Record> fetchFromCSV(String string) throws DataAccessException {
return fetchFromCSV(string, ',');
}
@Override
@Support
public Result<Record> fetchFromCSV(String string, char delimiter) throws DataAccessException {
CSVReader reader = new CSVReader(new StringReader(string), delimiter);
List<String[]> data = null;
@ -663,7 +617,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// -------------------------------------------------------------------------
@Override
@Support
public <R extends Record> SelectWhereStep<R> selectFrom(Table<R> table) {
SelectWhereStep<R> result = DSL.selectFrom(table);
result.attach(configuration);
@ -671,7 +624,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public SelectSelectStep<Record> select(Collection<? extends Field<?>> fields) {
SelectSelectStep<Record> result = DSL.select(fields);
result.attach(configuration);
@ -679,7 +631,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public SelectSelectStep<Record> select(Field<?>... fields) {
SelectSelectStep<Record> result = DSL.select(fields);
result.attach(configuration);
@ -823,7 +774,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// [jooq-tools] END [select]
@Override
@Support
public SelectSelectStep<Record> selectDistinct(Collection<? extends Field<?>> fields) {
SelectSelectStep<Record> result = DSL.selectDistinct(fields);
result.attach(configuration);
@ -831,7 +781,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public SelectSelectStep<Record> selectDistinct(Field<?>... fields) {
SelectSelectStep<Record> result = DSL.selectDistinct(fields);
result.attach(configuration);
@ -975,7 +924,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// [jooq-tools] END [selectDistinct]
@Override
@Support
public SelectSelectStep<Record1<Integer>> selectZero() {
SelectSelectStep<Record1<Integer>> result = DSL.selectZero();
result.attach(configuration);
@ -983,7 +931,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public SelectSelectStep<Record1<Integer>> selectOne() {
SelectSelectStep<Record1<Integer>> result = DSL.selectOne();
result.attach(configuration);
@ -991,7 +938,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public SelectSelectStep<Record1<Integer>> selectCount() {
SelectSelectStep<Record1<Integer>> result = DSL.selectCount();
result.attach(configuration);
@ -999,25 +945,21 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public SelectQuery<Record> selectQuery() {
return new SelectQueryImpl(configuration);
}
@Override
@Support
public <R extends Record> SelectQuery<R> selectQuery(TableLike<R> table) {
return new SelectQueryImpl<R>(configuration, table);
}
@Override
@Support
public <R extends Record> InsertQuery<R> insertQuery(Table<R> into) {
return new InsertQueryImpl<R>(configuration, into);
}
@Override
@Support
public <R extends Record> InsertSetStep<R> insertInto(Table<R> into) {
return new InsertImpl(configuration, into, Collections.<Field<?>>emptyList());
}
@ -1159,31 +1101,26 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// [jooq-tools] END [insert]
@Override
@Support
public <R extends Record> InsertValuesStepN<R> insertInto(Table<R> into, Field<?>... fields) {
return new InsertImpl(configuration, into, Arrays.asList(fields));
}
@Override
@Support
public <R extends Record> InsertValuesStepN<R> insertInto(Table<R> into, Collection<? extends Field<?>> fields) {
return new InsertImpl(configuration, into, fields);
}
@Override
@Support
public <R extends Record> UpdateQuery<R> updateQuery(Table<R> table) {
return new UpdateQueryImpl<R>(configuration, table);
}
@Override
@Support
public <R extends Record> UpdateSetFirstStep<R> update(Table<R> table) {
return new UpdateImpl<R>(configuration, table);
}
@Override
@Support({ CUBRID, DB2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
public <R extends Record> MergeUsingStep<R> mergeInto(Table<R> table) {
return new MergeImpl(configuration, table);
}
@ -1325,25 +1262,21 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// [jooq-tools] END [merge]
@Override
@Support({ CUBRID, DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
public <R extends Record> MergeKeyStepN<R> mergeInto(Table<R> table, Field<?>... fields) {
return mergeInto(table, Arrays.asList(fields));
}
@Override
@Support({ CUBRID, DB2, H2, HSQLDB, ORACLE, SQLSERVER, SYBASE })
public <R extends Record> MergeKeyStepN<R> mergeInto(Table<R> table, Collection<? extends Field<?>> fields) {
return new MergeImpl(configuration, table, fields);
}
@Override
@Support
public <R extends Record> DeleteQuery<R> deleteQuery(Table<R> table) {
return new DeleteQueryImpl<R>(configuration, table);
}
@Override
@Support
public <R extends Record> DeleteWhereStep<R> delete(Table<R> table) {
return new DeleteImpl<R>(configuration, table);
}
@ -1353,13 +1286,11 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// -------------------------------------------------------------------------
@Override
@Support
public Batch batch(Query... queries) {
return new BatchMultiple(configuration, queries);
}
@Override
@Support
public Batch batch(String... queries) {
Query[] result = new Query[queries.length];
@ -1371,79 +1302,66 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public Batch batch(Collection<? extends Query> queries) {
return batch(queries.toArray(new Query[queries.size()]));
}
@Override
@Support
public BatchBindStep batch(Query query) {
return new BatchSingle(configuration, query);
}
@Override
@Support
public BatchBindStep batch(String sql) {
return batch(query(sql));
}
@Override
@Support
public Batch batch(Query query, Object[]... bindings) {
return batch(query).bind(bindings);
}
@Override
@Support
public Batch batch(String sql, Object[]... bindings) {
return batch(query(sql), bindings);
}
@Override
@Support
public Batch batchStore(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration, Action.STORE, records);
}
@Override
@Support
public Batch batchStore(Collection<? extends UpdatableRecord<?>> records) {
return batchStore(records.toArray(new UpdatableRecord[records.size()]));
}
@Override
@Support
public Batch batchInsert(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration, Action.INSERT, records);
}
@Override
@Support
public Batch batchInsert(Collection<? extends UpdatableRecord<?>> records) {
return batchInsert(records.toArray(new UpdatableRecord[records.size()]));
}
@Override
@Support
public Batch batchUpdate(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration, Action.UPDATE, records);
}
@Override
@Support
public Batch batchUpdate(Collection<? extends UpdatableRecord<?>> records) {
return batchUpdate(records.toArray(new UpdatableRecord[records.size()]));
}
@Override
@Support
public Batch batchDelete(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration, Action.DELETE, records);
}
@Override
@Support
public Batch batchDelete(Collection<? extends UpdatableRecord<?>> records) {
return batchDelete(records.toArray(new UpdatableRecord[records.size()]));
}
@ -1453,7 +1371,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// -------------------------------------------------------------------------
@Override
@Support
public <R extends Record> TruncateIdentityStep<R> truncate(Table<R> table) {
return new TruncateImpl<R>(configuration, table);
}
@ -1464,7 +1381,7 @@ public class DefaultDSLContext implements DSLContext, Serializable {
@Override
public BigInteger lastID() throws DataAccessException {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case DERBY: {
Field<BigInteger> field = field("identity_val_local()", BigInteger.class);
return select(field).fetchOne(field);
@ -1621,55 +1538,46 @@ public class DefaultDSLContext implements DSLContext, Serializable {
// -------------------------------------------------------------------------
@Override
@Support
public <R extends Record> Result<R> fetch(Table<R> table) throws DataAccessException {
return fetch(table, trueCondition());
}
@Override
@Support
public <R extends Record> Result<R> fetch(Table<R> table, Condition condition) throws DataAccessException {
return selectFrom(table).where(condition).fetch();
}
@Override
@Support
public <R extends Record> R fetchOne(Table<R> table) throws DataAccessException, InvalidResultException {
return Utils.fetchOne(fetchLazy(table));
}
@Override
@Support
public <R extends Record> R fetchOne(Table<R> table, Condition condition) throws DataAccessException, InvalidResultException {
return Utils.fetchOne(fetchLazy(table, condition));
}
@Override
@Support
public <R extends Record> R fetchAny(Table<R> table) throws DataAccessException {
return Utils.filterOne(selectFrom(table).limit(1).fetch());
}
@Override
@Support
public <R extends Record> R fetchAny(Table<R> table, Condition condition) throws DataAccessException {
return Utils.filterOne(selectFrom(table).where(condition).limit(1).fetch());
}
@Override
@Support
public <R extends Record> Cursor<R> fetchLazy(Table<R> table) throws DataAccessException {
return fetchLazy(table, trueCondition());
}
@Override
@Support
public <R extends Record> Cursor<R> fetchLazy(Table<R> table, Condition condition) throws DataAccessException {
return selectFrom(table).where(condition).fetchLazy();
}
@Override
@Support
public <R extends TableRecord<R>> int executeInsert(R record) throws DataAccessException {
InsertQuery<R> insert = insertQuery(record.getTable());
insert.setRecord(record);
@ -1677,7 +1585,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public <R extends UpdatableRecord<R>> int executeUpdate(R record) throws DataAccessException {
UpdateQuery<R> update = updateQuery(record.getTable());
Utils.addConditions(update, record, record.getTable().getPrimaryKey().getFieldsArray());
@ -1686,7 +1593,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public <R extends TableRecord<R>, T> int executeUpdate(R record, Condition condition) throws DataAccessException {
UpdateQuery<R> update = updateQuery(record.getTable());
update.addConditions(condition);
@ -1695,7 +1601,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public <R extends UpdatableRecord<R>> int executeDelete(R record) throws DataAccessException {
DeleteQuery<R> delete = deleteQuery(record.getTable());
Utils.addConditions(delete, record, record.getTable().getPrimaryKey().getFieldsArray());
@ -1703,7 +1608,6 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
@Support
public <R extends TableRecord<R>, T> int executeDelete(R record, Condition condition) throws DataAccessException {
DeleteQuery<R> delete = deleteQuery(record.getTable());
delete.addConditions(condition);

View File

@ -309,7 +309,7 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
sql(literal);
}
else {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// MySQL supports backticks and double quotes
case MYSQL:
@ -383,7 +383,7 @@ class DefaultRenderContext extends AbstractContext<RenderContext> implements Ren
if (((Param<?>) part).isInline())
return;
switch (configuration().dialect()) {
switch (configuration().dialect().family()) {
case ASE:
checkForceInline(2000);
return;

View File

@ -70,7 +70,7 @@ class Dual extends AbstractTable<Record> {
@Override
public final void toSQL(RenderContext context) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
case ASE:
case POSTGRES:
case SQLITE:

View File

@ -60,7 +60,7 @@ class Euler extends AbstractFunction<BigDecimal> {
@Override
final Field<BigDecimal> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case CUBRID:
case DB2:

View File

@ -48,6 +48,15 @@ import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SYBASE;
import static org.jooq.impl.DSL.bitAnd;
import static org.jooq.impl.DSL.bitNot;
import static org.jooq.impl.DSL.bitOr;
import static org.jooq.impl.DSL.bitXor;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.two;
import static org.jooq.impl.DSL.val;
import static org.jooq.impl.ExpressionOperator.ADD;
import static org.jooq.impl.ExpressionOperator.BIT_AND;
import static org.jooq.impl.ExpressionOperator.BIT_NAND;
@ -58,15 +67,6 @@ import static org.jooq.impl.ExpressionOperator.BIT_XOR;
import static org.jooq.impl.ExpressionOperator.SHL;
import static org.jooq.impl.ExpressionOperator.SHR;
import static org.jooq.impl.ExpressionOperator.SUBTRACT;
import static org.jooq.impl.DSL.bitAnd;
import static org.jooq.impl.DSL.bitNot;
import static org.jooq.impl.DSL.bitOr;
import static org.jooq.impl.DSL.bitXor;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.two;
import static org.jooq.impl.DSL.val;
import java.sql.Timestamp;
@ -165,10 +165,10 @@ class Expression<T> extends AbstractFunction<T> {
}
// Many dialects don't support shifts. Use multiplication/division instead
else if (SHL == operator && asList(ASE, DB2, H2, HSQLDB, INGRES, ORACLE, SQLSERVER, SYBASE).contains(dialect)) {
else if (SHL == operator && asList(ASE, DB2, H2, HSQLDB, INGRES, ORACLE, SQLSERVER, SYBASE).contains(dialect.family())) {
return lhs.mul(DSL.power(two(), rhsAsNumber()));
}
else if (SHR == operator && asList(ASE, DB2, H2, HSQLDB, INGRES, ORACLE, SQLSERVER, SYBASE).contains(dialect)) {
else if (SHR == operator && asList(ASE, DB2, H2, HSQLDB, INGRES, ORACLE, SQLSERVER, SYBASE).contains(dialect.family())) {
return lhs.div(DSL.power(two(), rhsAsNumber()));
}
@ -288,7 +288,7 @@ class Expression<T> extends AbstractFunction<T> {
SQLDialect dialect = configuration.dialect();
int sign = (operator == ADD) ? 1 : -1;
switch (dialect) {
switch (dialect.family()) {
case ASE:
case SYBASE:
case SQLSERVER: {
@ -436,7 +436,7 @@ class Expression<T> extends AbstractFunction<T> {
* Return the expression to be rendered when the RHS is a number type
*/
private final Field<T> getNumberExpression(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case FIREBIRD:
case SQLSERVER:

View File

@ -63,7 +63,7 @@ class Extract extends AbstractFunction<Integer> {
@Override
final Field<Integer> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case SQLITE:
switch (datePart) {
case YEAR:

View File

@ -70,7 +70,7 @@ class FieldCondition extends AbstractCondition {
}
private final QueryPartInternal delegate(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// [#2485] These don't work nicely, yet
case CUBRID:

View File

@ -64,7 +64,7 @@ class Greatest<T> extends AbstractFunction<T> {
return (Field<T>) getArguments()[0];
}
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// This implementation has O(2^n) complexity. Better implementations
// are very welcome
// [#1049] TODO Fix this!

View File

@ -74,7 +74,7 @@ class InCondition<T> extends AbstractCondition {
if (list.size() > IN_LIMIT) {
// [#798] Oracle and some other dialects can only hold 1000 values
// in an IN (...) clause
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
case FIREBIRD:
case INGRES:
case ORACLE:

View File

@ -135,7 +135,7 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
// ON DUPLICATE KEY UPDATE clause
// ------------------------------
if (onDuplicateKeyUpdate) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
// MySQL has a nice syntax for this
case CUBRID:
@ -173,7 +173,7 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
// ON DUPLICATE KEY IGNORE clause
// ------------------------------
else if (onDuplicateKeyIgnore) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
// MySQL has a nice, native syntax for this
case MYSQL: {
@ -230,7 +230,7 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
// ON DUPLICATE KEY UPDATE clause
// ------------------------------
if (onDuplicateKeyUpdate) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
// MySQL has a nice syntax for this
case CUBRID:
@ -264,7 +264,7 @@ class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> implements
// ON DUPLICATE KEY IGNORE clause
// ------------------------------
else if (onDuplicateKeyIgnore) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
// MySQL has a nice, native syntax for this
case MYSQL: {

View File

@ -101,7 +101,7 @@ class IsDistinctFrom<T> extends AbstractCondition {
private final QueryPartInternal delegate(Configuration configuration) {
// These dialects need to simulate the IS DISTINCT FROM operator
if (asList(ASE, CUBRID, DB2, DERBY, INGRES, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect())) {
if (asList(ASE, CUBRID, DB2, DERBY, INGRES, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect().family())) {
if (caseExpression == null) {
if (comparator == Comparator.IS_DISTINCT_FROM) {
caseExpression = (QueryPartInternal) decode()

View File

@ -193,15 +193,15 @@ class JoinTable extends AbstractTable<Record> implements TableOptionalOnStep, Ta
}
private final boolean simulateNaturalJoin(RenderContext context) {
return type == NATURAL_JOIN && asList(ASE, CUBRID, DB2, INGRES, SQLSERVER).contains(context.configuration().dialect());
return type == NATURAL_JOIN && asList(ASE, CUBRID, DB2, INGRES, SQLSERVER).contains(context.configuration().dialect().family());
}
private final boolean simulateNaturalLeftOuterJoin(RenderContext context) {
return type == NATURAL_LEFT_OUTER_JOIN && asList(ASE, CUBRID, DB2, H2, INGRES, SQLSERVER).contains(context.configuration().dialect());
return type == NATURAL_LEFT_OUTER_JOIN && asList(ASE, CUBRID, DB2, H2, INGRES, SQLSERVER).contains(context.configuration().dialect().family());
}
private final boolean simulateNaturalRightOuterJoin(RenderContext context) {
return type == NATURAL_RIGHT_OUTER_JOIN && asList(ASE, CUBRID, DB2, H2, INGRES, SQLSERVER).contains(context.configuration().dialect());
return type == NATURAL_RIGHT_OUTER_JOIN && asList(ASE, CUBRID, DB2, H2, INGRES, SQLSERVER).contains(context.configuration().dialect().family());
}
private final void toSQLJoinCondition(RenderContext context) {
@ -209,7 +209,7 @@ class JoinTable extends AbstractTable<Record> implements TableOptionalOnStep, Ta
// [#582] Some dialects don't explicitly support a JOIN .. USING
// syntax. This can be simulated with JOIN .. ON
if (asList(ASE, CUBRID, DB2, H2, SQLSERVER, SYBASE).contains(context.configuration().dialect())) {
if (asList(ASE, CUBRID, DB2, H2, SQLSERVER, SYBASE).contains(context.configuration().dialect().family())) {
String glue = "on ";
for (Field<?> field : using) {
context.formatSeparator()

View File

@ -64,7 +64,7 @@ class Least<T> extends AbstractFunction<T> {
return (Field<T>) getArguments()[0];
}
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// This implementation has O(2^n) complexity. Better implementations
// are very welcome

View File

@ -117,7 +117,9 @@ class Limit extends AbstractQueryPart {
break;
}
case DERBY: {
case DERBY:
case SQLSERVER:
case SQLSERVER2012: {
// Casts are not supported here...
context.castMode(NEVER)
@ -181,7 +183,7 @@ class Limit extends AbstractQueryPart {
}
case ASE:
case SQLSERVER: {
case SQLSERVER2008: {
if (offset != null) {
throw new DataAccessException("Offsets in TOP clause not supported");
}
@ -216,7 +218,9 @@ class Limit extends AbstractQueryPart {
// OFFSET .. LIMIT support provided by the following dialects
// ----------------------------------------------------------
case DERBY: {
case DERBY:
case SQLSERVER:
case SQLSERVER2012: {
context.bind(offsetOrZero);
context.bind(numberOfRows);
break;
@ -276,7 +280,7 @@ class Limit extends AbstractQueryPart {
// These dialects don't allow bind variables in their TOP clauses
// --------------------------------------------------------------
case DB2:
case SQLSERVER: {
case SQLSERVER2008: {
// TOP clauses without bind variables
if (offset == null && !rendersParams) {

View File

@ -70,7 +70,7 @@ class Ln extends AbstractFunction<BigDecimal> {
@Override
final Field<BigDecimal> getFunction0(Configuration configuration) {
if (base == null) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case H2:
case SQLSERVER:
@ -81,7 +81,7 @@ class Ln extends AbstractFunction<BigDecimal> {
}
}
else {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case DB2:
case DERBY:

View File

@ -70,7 +70,7 @@ class Lpad extends AbstractFunction<String> {
@Override
final Field<String> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case SQLSERVER:
case SYBASE: {

View File

@ -919,7 +919,7 @@ implements
* Return a standard MERGE statement simulating the H2-specific syntax
*/
private final QueryPart getStandardMerge(Configuration config) {
switch (config.dialect()) {
switch (config.dialect().family()) {
case CUBRID:
case DB2:
case HSQLDB:
@ -1080,7 +1080,7 @@ implements
.formatIndentEnd()
.declareTables(false);
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
case SQLSERVER:
case SYBASE: {
if (using instanceof Select) {
@ -1150,7 +1150,7 @@ implements
.sql(notMatchedWhere);
}
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
case SQLSERVER:
context.sql(";");
break;

View File

@ -35,8 +35,8 @@
*/
package org.jooq.impl;
import static org.jooq.impl.ExpressionOperator.MODULO;
import static org.jooq.impl.DSL.function;
import static org.jooq.impl.ExpressionOperator.MODULO;
import org.jooq.Configuration;
import org.jooq.Field;
@ -63,7 +63,7 @@ class Mod<T> extends AbstractFunction<T> {
@Override
final Field<T> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case SQLITE:
case SQLSERVER:

View File

@ -61,7 +61,7 @@ class Position extends AbstractFunction<Integer> {
@Override
final Field<Integer> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case DB2: // No break
case DERBY:
return function("locate", SQLDataType.INTEGER, search, in);

View File

@ -59,7 +59,7 @@ class RegexpLike extends AbstractCondition {
@Override
public final void toSQL(RenderContext context) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
// [#620] These databases are compatible with the MySQL syntax
case CUBRID:

View File

@ -62,7 +62,7 @@ class Repeat extends AbstractFunction<String> {
@Override
final Field<String> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case FIREBIRD:
case INGRES:
case ORACLE:

View File

@ -61,7 +61,7 @@ class Replace extends AbstractFunction<String> {
Field<?>[] args = getArguments();
// [#861] Most dialects don't ship with a two-argument replace function:
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE: {
if (args.length == 2) {
return function("str_replace", VARCHAR, args[0], args[1], val(null));

View File

@ -70,7 +70,7 @@ class Round<T extends Number> extends AbstractFunction<T> {
@SuppressWarnings("unchecked")
@Override
final Field<T> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// evaluate "round" if unavailable
case DERBY: {

View File

@ -52,14 +52,6 @@ import static org.jooq.impl.DSL.row;
import javax.annotation.Generated;
import org.jooq.BetweenAndStep1;
import org.jooq.BetweenAndStep2;
import org.jooq.BetweenAndStep3;
import org.jooq.BetweenAndStep4;
import org.jooq.BetweenAndStep5;
import org.jooq.BetweenAndStep6;
import org.jooq.BetweenAndStep7;
import org.jooq.BetweenAndStep8;
import org.jooq.BetweenAndStep9;
import org.jooq.BetweenAndStep10;
import org.jooq.BetweenAndStep11;
import org.jooq.BetweenAndStep12;
@ -70,9 +62,17 @@ import org.jooq.BetweenAndStep16;
import org.jooq.BetweenAndStep17;
import org.jooq.BetweenAndStep18;
import org.jooq.BetweenAndStep19;
import org.jooq.BetweenAndStep2;
import org.jooq.BetweenAndStep20;
import org.jooq.BetweenAndStep21;
import org.jooq.BetweenAndStep22;
import org.jooq.BetweenAndStep3;
import org.jooq.BetweenAndStep4;
import org.jooq.BetweenAndStep5;
import org.jooq.BetweenAndStep6;
import org.jooq.BetweenAndStep7;
import org.jooq.BetweenAndStep8;
import org.jooq.BetweenAndStep9;
import org.jooq.BetweenAndStepN;
import org.jooq.BindContext;
import org.jooq.Condition;
@ -81,14 +81,6 @@ import org.jooq.Field;
import org.jooq.QueryPartInternal;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record2;
import org.jooq.Record3;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.Record9;
import org.jooq.Record10;
import org.jooq.Record11;
import org.jooq.Record12;
@ -99,20 +91,20 @@ import org.jooq.Record16;
import org.jooq.Record17;
import org.jooq.Record18;
import org.jooq.Record19;
import org.jooq.Record2;
import org.jooq.Record20;
import org.jooq.Record21;
import org.jooq.Record22;
import org.jooq.Record3;
import org.jooq.Record4;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Record7;
import org.jooq.Record8;
import org.jooq.Record9;
import org.jooq.RenderContext;
import org.jooq.Row;
import org.jooq.Row1;
import org.jooq.Row2;
import org.jooq.Row3;
import org.jooq.Row4;
import org.jooq.Row5;
import org.jooq.Row6;
import org.jooq.Row7;
import org.jooq.Row8;
import org.jooq.Row9;
import org.jooq.Row10;
import org.jooq.Row11;
import org.jooq.Row12;
@ -123,9 +115,17 @@ import org.jooq.Row16;
import org.jooq.Row17;
import org.jooq.Row18;
import org.jooq.Row19;
import org.jooq.Row2;
import org.jooq.Row20;
import org.jooq.Row21;
import org.jooq.Row22;
import org.jooq.Row3;
import org.jooq.Row4;
import org.jooq.Row5;
import org.jooq.Row6;
import org.jooq.Row7;
import org.jooq.Row8;
import org.jooq.Row9;
import org.jooq.RowN;
/**
@ -180,7 +180,7 @@ implements
// ------------------------------------------------------------------------
// XXX: BetweenAndStep API
// ------------------------------------------------------------------------
@Override
public final Condition and(Field f) {
if (maxValue == null) {
@ -669,11 +669,11 @@ implements
RowN r = new RowImpl(Utils.fields(record.intoArray(), record.fields()));
return and(r);
}
// ------------------------------------------------------------------------
// XXX: QueryPart API
// ------------------------------------------------------------------------
@Override
public final void bind(BindContext context) {
delegate(context.configuration()).bind(context);
@ -691,7 +691,7 @@ implements
RowN max = (RowN) maxValue;
// These dialects don't support the SYMMETRIC keyword at all
if (symmetric && asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE).contains(configuration.dialect())) {
if (symmetric && asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE).contains(configuration.dialect().family())) {
if (not) {
return (QueryPartInternal) r.notBetween(min, max).and(r.notBetween(max, min));
}
@ -702,7 +702,7 @@ implements
// These dialects either don't support row value expressions, or they
// Can't handle row value expressions with the BETWEEN predicate
else if (row.size() > 1 && asList(CUBRID, DERBY, FIREBIRD, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE).contains(configuration.dialect())) {
else if (row.size() > 1 && asList(CUBRID, DERBY, FIREBIRD, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE).contains(configuration.dialect().family())) {
Condition result = r.ge(min).and(r.le(max));
if (not) {

View File

@ -103,7 +103,7 @@ class RowCondition extends AbstractCondition {
// Regular comparison predicate simulation
if (asList(EQUALS, NOT_EQUALS).contains(comparator) &&
asList(ASE, DERBY, FIREBIRD, INGRES, SQLSERVER, SQLITE, SYBASE).contains(dialect)) {
asList(ASE, DERBY, FIREBIRD, INGRES, SQLSERVER, SQLITE, SYBASE).contains(dialect.family())) {
List<Condition> conditions = new ArrayList<Condition>();
Field<?>[] leftFields = left.fields();
@ -124,7 +124,7 @@ class RowCondition extends AbstractCondition {
// Ordering comparison predicate simulation
else if (asList(GREATER, GREATER_OR_EQUAL, LESS, LESS_OR_EQUAL).contains(comparator) &&
asList(DERBY, CUBRID, FIREBIRD, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(dialect)) {
asList(DERBY, CUBRID, FIREBIRD, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(dialect.family())) {
// The order component of the comparator (stripping the equal component)
Comparator order

View File

@ -91,7 +91,7 @@ class RowInCondition extends AbstractCondition {
}
private final QueryPartInternal delegate(Configuration configuration) {
if (asList(ASE, DB2, DERBY, FIREBIRD, INGRES, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect())) {
if (asList(ASE, DB2, DERBY, FIREBIRD, INGRES, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect().family())) {
List<Condition> conditions = new ArrayList<Condition>();
for (Row row : right) {

View File

@ -92,7 +92,7 @@ class RowIsNull extends AbstractCondition {
// CUBRID 9.0.0 and HSQLDB have buggy implementations of the NULL predicate.
// Let's wait for them to be fixed
if (asList(CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE).contains(configuration.dialect())) {
if (asList(CUBRID, DB2, DERBY, FIREBIRD, H2, HSQLDB, MYSQL, ORACLE, SQLITE, SQLSERVER, SYBASE).contains(configuration.dialect().family())) {
List<Condition> conditions = new ArrayList<Condition>();
for (Field<?> field : row.fields()) {

View File

@ -101,7 +101,7 @@ class RowOverlapsCondition<T1, T2> extends AbstractCondition {
boolean intervalOverlaps = type0.isDateTime() && (type1.isInterval() || type1.isNumeric());
// The non-standard OVERLAPS predicate is always simulated
if (!standardOverlaps || asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, INGRES, MYSQL, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect())) {
if (!standardOverlaps || asList(ASE, CUBRID, DB2, DERBY, FIREBIRD, H2, INGRES, MYSQL, SQLSERVER, SQLITE, SYBASE).contains(configuration.dialect().family())) {
// Interval OVERLAPS predicates need some additional arithmetic
if (intervalOverlaps) {

View File

@ -70,7 +70,7 @@ class Rpad extends AbstractFunction<String> {
@Override
final Field<String> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case SQLSERVER:
case SYBASE: {

View File

@ -47,6 +47,8 @@ import static org.jooq.SQLDialect.MYSQL;
import static org.jooq.SQLDialect.POSTGRES;
import static org.jooq.SQLDialect.SQLITE;
import static org.jooq.SQLDialect.SQLSERVER;
import static org.jooq.SQLDialect.SQLSERVER2008;
import static org.jooq.SQLDialect.SQLSERVER2012;
import static org.jooq.conf.ParamType.INLINED;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.name;
@ -197,7 +199,7 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
// "OFFSET" has to be simulated
else {
toSQLReferenceLimitDB2SQLServerSybase(context);
toSQLReferenceLimitDB2SQLServer2008Sybase(context);
}
break;
@ -206,7 +208,7 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
// Sybase ASE and SQL Server support a TOP clause without OFFSET
// OFFSET can be simulated in SQL Server, not in ASE
case ASE:
case SQLSERVER: {
case SQLSERVER2008: {
// Native TOP support, without OFFSET and without bind values
if (getLimit().offsetZero() && !getLimit().rendersParams()) {
@ -215,7 +217,7 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
// OFFSET simulation
else {
toSQLReferenceLimitDB2SQLServerSybase(context);
toSQLReferenceLimitDB2SQLServer2008Sybase(context);
}
break;
@ -232,7 +234,7 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
// OFFSET simulation
else {
toSQLReferenceLimitDB2SQLServerSybase(context);
toSQLReferenceLimitDB2SQLServer2008Sybase(context);
}
break;
@ -252,7 +254,7 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
}
// [#1296] FOR UPDATE is simulated in some dialects using ResultSet.CONCUR_UPDATABLE
if (forUpdate && !asList(CUBRID, SQLSERVER).contains(context.configuration().dialect())) {
if (forUpdate && !asList(CUBRID, SQLSERVER).contains(context.configuration().dialect().family())) {
context.formatSeparator()
.keyword("for update");
@ -320,12 +322,13 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
/**
* Simulate the LIMIT / OFFSET clause in the {@link SQLDialect#DB2},
* {@link SQLDialect#SQLSERVER} and {@link SQLDialect#SYBASE} dialects
* {@link SQLDialect#SQLSERVER2008} and {@link SQLDialect#SYBASE} dialects
*/
private final void toSQLReferenceLimitDB2SQLServerSybase(RenderContext context) {
private final void toSQLReferenceLimitDB2SQLServer2008Sybase(RenderContext context) {
// [#1954] Render enclosed SELECT first to obtain a "unique" hash code
RenderContext tmpLocal = new DefaultRenderContext(context);
tmpLocal.subquery(true);
toSQLReference0(tmpLocal);
String tmpEnclosed = tmpLocal.render();
@ -335,6 +338,7 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
// Render enclosed SELECT again, adding an additional ROW_NUMBER() OVER()
// window function, calculating row numbers for the LIMIT .. OFFSET clause
RenderContext local = new DefaultRenderContext(context);
local.subquery(true);
toSQLReference0(local, rowNumber().over().orderBy(getNonEmptyOrderBy()).as(rownumName));
String enclosed = local.render();
@ -428,20 +432,27 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
}
// Sybase and SQL Server have leading TOP clauses
switch (dialect) {
switch (dialect.family()) {
case ASE:
case SQLSERVER: {
// If we have a TOP clause, it needs to be rendered here
if (getLimit().isApplicable() && getLimit().offsetZero() && !getLimit().rendersParams()) {
if (asList(ASE, SQLSERVER2008).contains(dialect)
&& getLimit().isApplicable()
&& getLimit().offsetZero()
&& !getLimit().rendersParams()) {
context.sql(getLimit()).sql(" ");
}
// If we don't have a limit, some subqueries still need a "TOP" clause
else if (dialect == SQLSERVER && !getOrderBy().isEmpty()) {
// [#759] SQL Server needs a TOP clause in ordered subqueries
else if (dialect.family() == SQLSERVER
&& context.subquery()
&& !getOrderBy().isEmpty()) {
// [#759] The TOP 100% is only rendered in subqueries
if (context.subquery() || getLimit().isApplicable()) {
// [#2423] SQL Server 2012 will render an OFFSET .. FETCH
// clause if there is an applicable limit
if (dialect == SQLSERVER2008 || !getLimit().isApplicable()) {
context.keyword("top 100 percent ");
}
}
@ -585,6 +596,13 @@ class SelectQueryImpl<R extends Record> extends AbstractSelect<R> implements Sel
.keyword("by ")
.sql(getOrderBy());
}
// [#2423] SQL Server 2012 requires an ORDER BY clause, along with
// OFFSET .. FETCH
else if (getLimit().isApplicable() && asList(SQLSERVER, SQLSERVER2012).contains(dialect)){
context.formatSeparator()
.keyword("order by 1");
}
}
private void toSQLStartWith(RenderContext context) {

View File

@ -120,9 +120,9 @@ public class SequenceImpl<T extends Number> implements Sequence<T> {
@Override
final Field<T> getFunction0(Configuration configuration) {
SQLDialect dialect = configuration.dialect();
SQLDialect family = configuration.dialect().family();
switch (dialect) {
switch (family) {
case DB2:
case INGRES:
case ORACLE:
@ -145,10 +145,10 @@ public class SequenceImpl<T extends Number> implements Sequence<T> {
String field = "next value for " + getQualifiedName(configuration);
return field(field, getDataType());
}
else if (dialect == FIREBIRD) {
else if (family == FIREBIRD) {
return field("gen_id(" + getQualifiedName(configuration) + ", 0)", getDataType());
}
else if (dialect == SQLSERVER) {
else if (family == SQLSERVER) {
return select(field("current_value"))
.from("sys.sequences sq")
.join("sys.schemas sc")
@ -159,7 +159,7 @@ public class SequenceImpl<T extends Number> implements Sequence<T> {
.cast(type);
}
else {
throw new SQLDialectNotSupportedException("The sequence's current value functionality is not supported for the " + dialect + " dialect.");
throw new SQLDialectNotSupportedException("The sequence's current value functionality is not supported for the " + family + " dialect.");
}
}

View File

@ -64,7 +64,7 @@ class Sinh extends AbstractFunction<BigDecimal> {
@Override
final Field<BigDecimal> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case CUBRID:
case HSQLDB:

View File

@ -89,7 +89,7 @@ class SortFieldImpl<T> extends AbstractQueryPart implements SortField<T> {
@Override
public final void toSQL(RenderContext context) {
if (nullsFirst || nullsLast) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
// DB2 supports NULLS FIRST/LAST only in OLAP (window) functions
case DB2:
@ -144,7 +144,7 @@ class SortFieldImpl<T> extends AbstractQueryPart implements SortField<T> {
// [#1667] Some dialects simulate NULLS { FIRST | LAST } clauses. They
// will need to bind the sort field twice
if (nullsFirst || nullsLast) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
case DB2:
case ASE:
case CUBRID:

View File

@ -60,7 +60,7 @@ class Substring extends AbstractFunction<String> {
final Field<String> getFunction0(Configuration configuration) {
String functionName = "substring";
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// Sybase ASE and SQL Server requires 3 arguments
case ASE:

View File

@ -64,7 +64,7 @@ class Tanh extends AbstractFunction<BigDecimal> {
@Override
final Field<BigDecimal> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case CUBRID:
case HSQLDB:

View File

@ -48,7 +48,7 @@ enum Term {
ATAN2 {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case ASE:
case SQLSERVER:
return "atn2";
@ -60,7 +60,7 @@ enum Term {
BIT_LENGTH {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case ASE:
return "8 * datalength";
@ -84,7 +84,7 @@ enum Term {
CHAR_LENGTH {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case DB2:
case DERBY:
case INGRES:
@ -103,7 +103,7 @@ enum Term {
LIST_AGG {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case CUBRID:
case H2:
case HSQLDB:
@ -131,7 +131,7 @@ enum Term {
OCTET_LENGTH {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case DB2:
case DERBY:
case INGRES:
@ -152,7 +152,7 @@ enum Term {
ROW_NUMBER {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case HSQLDB:
return "rownum";
}
@ -163,7 +163,7 @@ enum Term {
STDDEV_POP {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case DB2:
return "stddev";
@ -177,7 +177,7 @@ enum Term {
STDDEV_SAMP {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case DB2:
return "stddev";
@ -191,7 +191,7 @@ enum Term {
VAR_POP {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case DB2:
return "variance";
@ -205,7 +205,7 @@ enum Term {
VAR_SAMP {
@Override
public String translate(SQLDialect dialect) {
switch (dialect) {
switch (dialect.family()) {
case DB2:
return "variance";

View File

@ -69,7 +69,7 @@ class TimestampDiff extends AbstractFunction<DayToSecond> {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
final Field<DayToSecond> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
// Sybase ASE's datediff incredibly overflows on 3 days' worth of
// microseconds. That's why the days have to be leveled at first

View File

@ -60,7 +60,7 @@ class Trim extends AbstractFunction<String> {
@Override
final Field<String> getFunction0(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case INGRES:
case SQLSERVER:

View File

@ -84,7 +84,7 @@ class Trunc<T> extends AbstractFunction<T> {
}
private final Field<T> getNumericFunction(Configuration configuration) {
switch (configuration.dialect()) {
switch (configuration.dialect().family()) {
case ASE:
case DERBY: {
Field<BigDecimal> power;

View File

@ -1889,7 +1889,7 @@ final class Utils {
return (T) (string == null ? null : ULong.valueOf(string));
}
else if (type == UUID.class) {
switch (ctx.configuration().dialect()) {
switch (ctx.configuration().dialect().family()) {
// [#1624] Some JDBC drivers natively support the
// java.util.UUID data type
@ -2190,7 +2190,7 @@ final class Utils {
return (T) (string == null ? null : ULong.valueOf(string));
}
else if (type == UUID.class) {
switch (ctx.configuration().dialect()) {
switch (ctx.configuration().dialect().family()) {
// [#1624] Some JDBC drivers natively support the
// java.util.UUID data type

View File

@ -309,7 +309,7 @@ class Val<T> extends AbstractParam<T> {
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private final void toSQL(RenderContext context, Object val, Class<?> type) {
SQLDialect dialect = context.configuration().dialect();
SQLDialect family = context.configuration().dialect().family();
// [#650] Check first, if we have a converter for the supplied type
Converter<?, ?> converter = DataTypes.converter(type);
@ -331,7 +331,7 @@ class Val<T> extends AbstractParam<T> {
// [#1153] Some dialects don't support boolean literals
// TRUE and FALSE
if (asList(ASE, DB2, FIREBIRD, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(dialect)) {
if (asList(ASE, DB2, FIREBIRD, ORACLE, SQLSERVER, SQLITE, SYBASE).contains(family)) {
context.sql(((Boolean) val) ? "1" : "0");
}
else {
@ -343,27 +343,27 @@ class Val<T> extends AbstractParam<T> {
else if (type == byte[].class) {
byte[] binary = (byte[]) val;
if (asList(ASE, SQLSERVER, SYBASE).contains(dialect)) {
if (asList(ASE, SQLSERVER, SYBASE).contains(family)) {
context.sql("0x")
.sql(convertBytesToHex(binary));
}
else if (dialect == DB2) {
else if (family == DB2) {
context.keyword("blob")
.sql("(X'")
.sql(convertBytesToHex(binary))
.sql("')");
}
else if (asList(DERBY, H2, HSQLDB, INGRES, MYSQL, SQLITE).contains(dialect)) {
else if (asList(DERBY, H2, HSQLDB, INGRES, MYSQL, SQLITE).contains(family)) {
context.sql("X'")
.sql(convertBytesToHex(binary))
.sql("'");
}
else if (asList(ORACLE).contains(dialect)) {
else if (asList(ORACLE).contains(family)) {
context.keyword("hextoraw('")
.sql(convertBytesToHex(binary))
.sql("')");
}
else if (dialect == POSTGRES) {
else if (family == POSTGRES) {
context.sql("E'")
.sql(convertBytesToPostgresOctal(binary))
.keyword("'::bytea");
@ -395,12 +395,12 @@ class Val<T> extends AbstractParam<T> {
// The SQLite JDBC driver does not implement the escape syntax
// [#1253] SQL Server and Sybase do not implement date literals
if (asList(ASE, SQLITE, SQLSERVER, SYBASE).contains(dialect)) {
if (asList(ASE, SQLITE, SQLSERVER, SYBASE).contains(family)) {
context.sql("'").sql(escape(val)).sql("'");
}
// [#1253] Derby doesn't support the standard literal
else if (dialect == DERBY) {
else if (family == DERBY) {
context.keyword("date('").sql(escape(val)).sql("')");
}
@ -413,17 +413,17 @@ class Val<T> extends AbstractParam<T> {
// The SQLite JDBC driver does not implement the escape syntax
// [#1253] SQL Server and Sybase do not implement timestamp literals
if (asList(ASE, SQLITE, SQLSERVER, SYBASE).contains(dialect)) {
if (asList(ASE, SQLITE, SQLSERVER, SYBASE).contains(family)) {
context.sql("'").sql(escape(val)).sql("'");
}
// [#1253] Derby doesn't support the standard literal
else if (dialect == DERBY) {
else if (family == DERBY) {
context.keyword("timestamp('").sql(escape(val)).sql("')");
}
// CUBRID timestamps have no fractional seconds
else if (dialect == CUBRID) {
else if (family == CUBRID) {
context.keyword("datetime '").sql(escape(val)).sql("'");
}
@ -436,17 +436,17 @@ class Val<T> extends AbstractParam<T> {
// The SQLite JDBC driver does not implement the escape syntax
// [#1253] SQL Server and Sybase do not implement time literals
if (asList(ASE, SQLITE, SQLSERVER, SYBASE).contains(dialect)) {
if (asList(ASE, SQLITE, SQLSERVER, SYBASE).contains(family)) {
context.sql("'").sql(escape(val)).sql("'");
}
// [#1253] Derby doesn't support the standard literal
else if (dialect == DERBY) {
else if (family == DERBY) {
context.keyword("time('").sql(escape(val)).sql("')");
}
// [#1253] Oracle doesn't know time literals
else if (dialect == ORACLE) {
else if (family == ORACLE) {
context.keyword("timestamp '1970-01-01 ").sql(escape(val)).sql("'");
}
@ -459,7 +459,7 @@ class Val<T> extends AbstractParam<T> {
String separator = "";
// H2 renders arrays as rows
if (dialect == H2) {
if (family == H2) {
context.sql("(");
for (Object o : ((Object[]) val)) {
@ -508,13 +508,13 @@ class Val<T> extends AbstractParam<T> {
// In Postgres, some additional casting must be done in some cases...
// TODO: Improve this implementation with [#215] (cast support)
else if (dialect == SQLDialect.POSTGRES) {
else if (family == SQLDialect.POSTGRES) {
// Postgres needs explicit casting for array types
if (type.isArray() && byte[].class != type) {
context.sql(getBindVariable(context));
context.sql("::");
context.keyword(DefaultDataType.getDataType(dialect, type).getCastTypeName(context.configuration()));
context.keyword(DefaultDataType.getDataType(family, type).getCastTypeName(context.configuration()));
}
// ... and also for enum types

View File

@ -83,7 +83,7 @@ class Values<R extends Record> extends AbstractTable<R> {
@Override
public final void toSQL(RenderContext context) {
switch (context.configuration().dialect()) {
switch (context.configuration().dialect().family()) {
// [#915] Simulate VALUES(..) with SELECT .. UNION ALL SELECT ..
// for those dialects that do not support a VALUES() constructor

View File

@ -52,10 +52,17 @@ import org.jooq.types.ULong;
import org.jooq.types.UShort;
/**
* Supported data types for the {@link SQLDialect#SQLSERVER} dialect
* Supported data types for the {@link SQLDialect#SQLSERVER} dialect family.
* <p>
* This includes the
* <ul>
* <li>{@link org.jooq.SQLDialect#SQLSERVER2008} dialect</li>
* <li>{@link org.jooq.SQLDialect#SQLSERVER2012} dialect</li>
* </ul>
*
* @author Lukas Eder
* @see <a href="http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx">http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx</a>
* @see <a
* href="http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx">http://msdn.microsoft.com/en-us/library/aa258271%28v=sql.80%29.aspx</a>
*/
public class SQLServerDataType {

View File

@ -1,5 +1,11 @@
/**
* The <code>org.jooq.util.ase</code> package contains classes related to the
* {@link org.jooq.SQLDialect#SQLSERVER} dialect.
* {@link org.jooq.SQLDialect#SQLSERVER} dialect family.
* <p>
* This includes the
* <ul>
* <li>{@link org.jooq.SQLDialect#SQLSERVER2008} dialect</li>
* <li>{@link org.jooq.SQLDialect#SQLSERVER2012} dialect</li>
* </ul>
*/
package org.jooq.util.sqlserver;