[#2919] Distinguish various PostgreSQL versions in the PostgreSQL
family: 9.3, 9.4
This commit is contained in:
parent
83a7de8f61
commit
6db5568fb9
@ -171,7 +171,7 @@ class GenerationUtil {
|
||||
* Gets the base type for an array type, depending on the RDBMS dialect
|
||||
*/
|
||||
static String getArrayBaseType(SQLDialect dialect, String t, String u) {
|
||||
switch (dialect) {
|
||||
switch (dialect.family()) {
|
||||
case POSTGRES: {
|
||||
|
||||
// The convention is to prepend a "_" to a type to get an array type
|
||||
|
||||
@ -1078,7 +1078,7 @@ public abstract class AbstractDatabase implements Database {
|
||||
|
||||
@Override
|
||||
public final boolean isArrayType(String dataType) {
|
||||
switch (getDialect()) {
|
||||
switch (getDialect().family()) {
|
||||
case POSTGRES:
|
||||
case H2:
|
||||
return "ARRAY".equals(dataType);
|
||||
|
||||
@ -48,11 +48,11 @@ import java.util.Set;
|
||||
* 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
|
||||
* For instance, the SQL Server dialect family {@link #POSTGRES} is specialised
|
||||
* by its dialects
|
||||
* <ul>
|
||||
* <li> {@link #SQLSERVER2008}</li>
|
||||
* <li> {@link #SQLSERVER2012}</li>
|
||||
* <li> {@link #POSTGRES_9_3}</li>
|
||||
* <li> {@link #POSTGRES_9_4}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
|
||||
@ -69,7 +69,21 @@ import org.jooq.exception.SQLDialectNotSupportedException;
|
||||
* annotated in such a way should be used only along with any of the dialects
|
||||
* specified by the annotation. This is typically the case with jOOQ's SQL
|
||||
* construction API for less common clauses, such as the creation of
|
||||
* <code>MERGE</code>, etc.</li>
|
||||
* <code>MERGE</code>, etc.
|
||||
* <p>
|
||||
* There listed dialects can be either a:
|
||||
* <ul>
|
||||
* <li>A dialect family, in case of which all versions of the family support the
|
||||
* feature. E.g. when {@link SQLDialect#POSTGRES} is referenced, then
|
||||
* {@link SQLDialect#POSTGRES_9_3}, {@link SQLDialect#POSTGRES_9_4}, etc.
|
||||
* support the feature as well</li>
|
||||
* <li>A dialect version, in case of which all versions larger or equal than the
|
||||
* referenced version support the feature. E.g. when
|
||||
* {@link SQLDialect#POSTGRES_9_4} is referenced, then
|
||||
* {@link SQLDialect#POSTGRES_9_5} would support the feature as well, but not
|
||||
* {@link SQLDialect#POSTGRES_9_3}</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Future versions of jOOQ may use these annotations for throwing
|
||||
|
||||
@ -468,7 +468,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
|
||||
Field<?> value = getInValues().get(parameter);
|
||||
|
||||
// Disambiguate overloaded procedure signatures
|
||||
if (POSTGRES == context.configuration().dialect() && isOverloaded()) {
|
||||
if (POSTGRES == context.family() && isOverloaded()) {
|
||||
value = value.cast(parameter.getType());
|
||||
}
|
||||
|
||||
@ -864,7 +864,7 @@ public abstract class AbstractRoutine<T> extends AbstractQueryPart implements Ro
|
||||
for (Parameter<?> p : getInParameters()) {
|
||||
|
||||
// Disambiguate overloaded function signatures
|
||||
if (POSTGRES == ctx.dialect() && isOverloaded()) {
|
||||
if (POSTGRES == ctx.family() && isOverloaded()) {
|
||||
array[i] = getInValues().get(p).cast(p.getType());
|
||||
}
|
||||
else {
|
||||
|
||||
@ -210,7 +210,7 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractQuery implem
|
||||
|
||||
final void toSQLReturning(Context<?> ctx) {
|
||||
if (!returning.isEmpty()) {
|
||||
switch (ctx.configuration().dialect()) {
|
||||
switch (ctx.family()) {
|
||||
case FIREBIRD:
|
||||
case POSTGRES:
|
||||
ctx.formatSeparator()
|
||||
@ -247,7 +247,7 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractQuery implem
|
||||
|
||||
// Values should be returned from the INSERT
|
||||
else {
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
@ -322,7 +322,7 @@ abstract class AbstractStoreQuery<R extends Record> extends AbstractQuery implem
|
||||
else {
|
||||
int result = 1;
|
||||
ResultSet rs;
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
// SQLite can select _rowid_ after the insert
|
||||
case SQLITE: {
|
||||
|
||||
@ -121,14 +121,14 @@ class Alias<Q extends QueryPart> extends AbstractQueryPart {
|
||||
@Override
|
||||
public final void accept(Context<?> context) {
|
||||
if (context.declareFields() || context.declareTables()) {
|
||||
SQLDialect dialect = context.configuration().dialect();
|
||||
SQLDialect family = context.family();
|
||||
boolean simulateDerivedColumnList = false;
|
||||
|
||||
// [#454] [#1801] Some databases don't allow "derived column names" in
|
||||
// "simple class specifications", or "common table expression references".
|
||||
// Hence, wrap the table reference in a subselect
|
||||
if (fieldAliases != null
|
||||
&& asList(CUBRID, FIREBIRD).contains(dialect.family())
|
||||
&& asList(CUBRID, FIREBIRD).contains(family)
|
||||
&& (wrapped instanceof TableImpl || wrapped instanceof CommonTableExpressionImpl)) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -143,13 +143,13 @@ class Alias<Q extends QueryPart> extends AbstractQueryPart {
|
||||
// [#1801] Some databases do not support "derived column names".
|
||||
// They can be simulated by concatenating a dummy SELECT with no
|
||||
// results using UNION ALL
|
||||
else if (fieldAliases != null && asList(H2, MARIADB, MYSQL, SQLITE).contains(dialect.family())) {
|
||||
else if (fieldAliases != null && asList(H2, MARIADB, MYSQL, SQLITE).contains(family)) {
|
||||
simulateDerivedColumnList = true;
|
||||
|
||||
SelectFieldList fields = new SelectFieldList();
|
||||
for (String fieldAlias : fieldAliases) {
|
||||
|
||||
switch (dialect.family()) {
|
||||
switch (family) {
|
||||
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx x
|
||||
@ -209,7 +209,7 @@ class Alias<Q extends QueryPart> extends AbstractQueryPart {
|
||||
// SELECT t.column_value FROM UNNEST(ARRAY[1, 2]) AS t(column_value)
|
||||
|
||||
// TODO: Is this still needed?
|
||||
switch (dialect) {
|
||||
switch (family) {
|
||||
case HSQLDB:
|
||||
case POSTGRES: {
|
||||
// The javac compiler doesn't like casting of generics
|
||||
@ -241,7 +241,7 @@ class Alias<Q extends QueryPart> extends AbstractQueryPart {
|
||||
}
|
||||
|
||||
static void toSQLAs(Context<?> context) {
|
||||
if (asList(DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES).contains(context.configuration().dialect())) {
|
||||
if (asList(DERBY, HSQLDB, MARIADB, MYSQL, POSTGRES).contains(context.family())) {
|
||||
context.sql(" ").keyword("as");
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ class ArrayDataType<T> extends DefaultDataType<T[]> {
|
||||
}
|
||||
|
||||
private static String getArrayType(Configuration configuration, String dataType) {
|
||||
switch (configuration.dialect()) {
|
||||
switch (configuration.family()) {
|
||||
case HSQLDB:
|
||||
return dataType + " array";
|
||||
case POSTGRES:
|
||||
|
||||
@ -174,7 +174,7 @@ class ArrayTable extends AbstractTable<Record> {
|
||||
}
|
||||
|
||||
private final Table<Record> table(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx x
|
||||
xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
|
||||
|
||||
@ -86,7 +86,7 @@ class CompareCondition extends AbstractCondition {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
SQLDialect family = ctx.configuration().dialect().family();
|
||||
SQLDialect family = ctx.family();
|
||||
Field<?> lhs = field1;
|
||||
Field<?> rhs = field2;
|
||||
Comparator op = comparator;
|
||||
|
||||
@ -66,7 +66,7 @@ class ConditionAsField extends AbstractFunction<Boolean> {
|
||||
|
||||
@Override
|
||||
final QueryPart getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
|
||||
// Some databases don't accept predicates where column expressions
|
||||
// are expected.
|
||||
|
||||
@ -69,7 +69,7 @@ class Cosh extends AbstractFunction<BigDecimal> {
|
||||
|
||||
@Override
|
||||
final Field<BigDecimal> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxx xxxx
|
||||
|
||||
@ -64,7 +64,7 @@ class CurrentDate extends AbstractFunction<Date> {
|
||||
|
||||
@Override
|
||||
final Field<Date> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
|
||||
|
||||
@ -64,7 +64,7 @@ class CurrentTime extends AbstractFunction<Time> {
|
||||
|
||||
@Override
|
||||
final Field<Time> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
|
||||
|
||||
@ -64,7 +64,7 @@ class CurrentTimestamp extends AbstractFunction<Timestamp> {
|
||||
|
||||
@Override
|
||||
final Field<Timestamp> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
@ -62,7 +62,7 @@ class CurrentUser extends AbstractFunction<String> {
|
||||
|
||||
@Override
|
||||
final Field<String> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
@ -57,6 +57,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.POSTGRES_9_3;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
@ -4936,7 +4937,7 @@ public class DSL {
|
||||
* WHERE e.department_id = d.department_id);
|
||||
* </pre></code>
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
@Support({ POSTGRES_9_3 })
|
||||
public static <R extends Record> Table<R> lateral(TableLike<R> table) {
|
||||
return new Lateral<R>(table.asTable());
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class DateAdd<T extends java.util.Date> extends AbstractFunction<T> {
|
||||
String keyword = null;
|
||||
String function = null;
|
||||
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
case CUBRID:
|
||||
case MARIADB:
|
||||
case MYSQL: {
|
||||
@ -150,7 +150,7 @@ class DateAdd<T extends java.util.Date> extends AbstractFunction<T> {
|
||||
default: throwUnsupported();
|
||||
}
|
||||
|
||||
// [#3824] Ensure that the output for DATE arithmetic will also
|
||||
// [#3824] Ensure that the output for DATE arithmetic will also
|
||||
// be of type DATE, not TIMESTAMP
|
||||
if (getDataType().getType() == Date.class)
|
||||
return field("({0} + ({1} || {2})::interval)::date", getDataType(), date, interval, inline(keyword));
|
||||
|
||||
@ -70,7 +70,7 @@ class DateDiff extends AbstractFunction<Integer> {
|
||||
|
||||
@Override
|
||||
final Field<Integer> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
return function("datediff", getDataType(), date1, date2);
|
||||
|
||||
@ -852,7 +852,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
// [#1225] [#1227] TODO Put this logic into DataType
|
||||
// Some dialects have trouble binding binary data as BLOB
|
||||
else if (asList(POSTGRES).contains(configuration.dialect()) && sqlType == Types.BLOB) {
|
||||
else if (asList(POSTGRES).contains(configuration.family()) && sqlType == Types.BLOB) {
|
||||
ctx.statement().setNull(ctx.index(), Types.BINARY);
|
||||
}
|
||||
|
||||
@ -1004,7 +1004,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
// [#566] Interval data types are best bound as Strings
|
||||
else if (actualType == YearToMonth.class) {
|
||||
if (dialect == POSTGRES) {
|
||||
if (dialect.family() == POSTGRES) {
|
||||
ctx.statement().setObject(ctx.index(), toPGInterval((YearToMonth) value));
|
||||
}
|
||||
else {
|
||||
@ -1012,7 +1012,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
else if (actualType == DayToSecond.class) {
|
||||
if (dialect == POSTGRES) {
|
||||
if (dialect.family() == POSTGRES) {
|
||||
ctx.statement().setObject(ctx.index(), toPGInterval((DayToSecond) value));
|
||||
}
|
||||
else {
|
||||
@ -1070,7 +1070,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
// The type byte[] is handled earlier. byte[][] can be handled here
|
||||
else if (actualType.isArray()) {
|
||||
switch (dialect) {
|
||||
switch (dialect.family()) {
|
||||
case POSTGRES: {
|
||||
ctx.statement().setString(ctx.index(), toPGArrayString((Object[]) value));
|
||||
break;
|
||||
@ -1322,7 +1322,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
result = (T) getTimestamp(ctx.configuration().dialect(), ctx.resultSet(), ctx.index());
|
||||
}
|
||||
else if (type == YearToMonth.class) {
|
||||
if (ctx.configuration().dialect() == POSTGRES) {
|
||||
if (ctx.family() == POSTGRES) {
|
||||
Object object = ctx.resultSet().getObject(ctx.index());
|
||||
result = (T) (object == null ? null : PostgresUtils.toYearToMonth(object));
|
||||
}
|
||||
@ -1332,7 +1332,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
else if (type == DayToSecond.class) {
|
||||
if (ctx.configuration().dialect() == POSTGRES) {
|
||||
if (ctx.family() == POSTGRES) {
|
||||
Object object = ctx.resultSet().getObject(ctx.index());
|
||||
result = (T) (object == null ? null : PostgresUtils.toDayToSecond(object));
|
||||
}
|
||||
@ -1354,7 +1354,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
result = (T) Convert.convert(ctx.resultSet().getString(ctx.index()), ULong.class);
|
||||
}
|
||||
else if (type == UUID.class) {
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
// [#1624] Some JDBC drivers natively support the
|
||||
// java.util.UUID data type
|
||||
@ -1382,7 +1382,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
// The type byte[] is handled earlier. byte[][] can be handled here
|
||||
else if (type.isArray()) {
|
||||
switch (ctx.configuration().dialect()) {
|
||||
switch (ctx.family()) {
|
||||
case POSTGRES: {
|
||||
result = pgGetArray(ctx, ctx.resultSet(), type, ctx.index());
|
||||
break;
|
||||
@ -1404,7 +1404,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
result = getEnumType(type, ctx.resultSet().getString(ctx.index()));
|
||||
}
|
||||
else if (UDTRecord.class.isAssignableFrom(type)) {
|
||||
switch (ctx.configuration().dialect()) {
|
||||
switch (ctx.family()) {
|
||||
case POSTGRES:
|
||||
result = (T) pgNewUDTRecord(type, ctx.resultSet().getObject(ctx.index()));
|
||||
break;
|
||||
@ -1481,7 +1481,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
result = (T) ctx.statement().getTimestamp(ctx.index());
|
||||
}
|
||||
else if (type == YearToMonth.class) {
|
||||
if (ctx.configuration().dialect() == POSTGRES) {
|
||||
if (ctx.family() == POSTGRES) {
|
||||
Object object = ctx.statement().getObject(ctx.index());
|
||||
result = (T) (object == null ? null : PostgresUtils.toYearToMonth(object));
|
||||
}
|
||||
@ -1491,7 +1491,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
}
|
||||
}
|
||||
else if (type == DayToSecond.class) {
|
||||
if (ctx.configuration().dialect() == POSTGRES) {
|
||||
if (ctx.family() == POSTGRES) {
|
||||
Object object = ctx.statement().getObject(ctx.index());
|
||||
result = (T) (object == null ? null : PostgresUtils.toDayToSecond(object));
|
||||
}
|
||||
@ -1517,7 +1517,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
result = (T) (string == null ? null : ULong.valueOf(string));
|
||||
}
|
||||
else if (type == UUID.class) {
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
// [#1624] Some JDBC drivers natively support the
|
||||
// java.util.UUID data type
|
||||
@ -1556,7 +1556,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
result = getEnumType(type, ctx.statement().getString(ctx.index()));
|
||||
}
|
||||
else if (UDTRecord.class.isAssignableFrom(type)) {
|
||||
switch (ctx.configuration().dialect()) {
|
||||
switch (ctx.family()) {
|
||||
case POSTGRES:
|
||||
result = (T) pgNewUDTRecord(type, ctx.statement().getObject(ctx.index()));
|
||||
break;
|
||||
|
||||
@ -111,7 +111,7 @@ class Dual extends AbstractTable<Record> {
|
||||
ctx.visit(FORCED_DUAL);
|
||||
}
|
||||
else {
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (ctx.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxx
|
||||
xxxx xxxxxxxxxx
|
||||
|
||||
@ -65,7 +65,7 @@ class Euler extends AbstractFunction<BigDecimal> {
|
||||
|
||||
@Override
|
||||
final Field<BigDecimal> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxx xxxx
|
||||
|
||||
@ -481,7 +481,7 @@ class Expression<T> extends AbstractFunction<T> {
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private final Field<T> getNumberExpression(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx x
|
||||
xx xxxxxxxxx xx xxxx x
|
||||
@ -611,7 +611,7 @@ class Expression<T> extends AbstractFunction<T> {
|
||||
public final void accept(Context<?> ctx) {
|
||||
String op = operator.toSQL();
|
||||
|
||||
if (operator == BIT_XOR && ctx.configuration().dialect() == POSTGRES) {
|
||||
if (operator == BIT_XOR && ctx.family() == POSTGRES) {
|
||||
op = "#";
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ class Extract extends AbstractFunction<Integer> {
|
||||
|
||||
@Override
|
||||
final Field<Integer> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
case SQLITE:
|
||||
switch (datePart) {
|
||||
case YEAR:
|
||||
|
||||
@ -69,7 +69,7 @@ class FieldCondition extends AbstractCondition {
|
||||
}
|
||||
|
||||
private final QueryPartInternal delegate(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
|
||||
// [#2485] These don't work nicely, yet
|
||||
case CUBRID:
|
||||
|
||||
@ -78,7 +78,7 @@ class FieldMapForUpdate extends AbstractQueryPartMap<Field<?>, Field<?>> {
|
||||
// disambiguated columns in queries like
|
||||
// UPDATE t1 JOIN t2 .. SET t1.val = ..., t2.val = ...
|
||||
boolean restoreQualify = ctx.qualify();
|
||||
boolean supportsQualify = asList(POSTGRES, SQLITE).contains(ctx.configuration().dialect()) ? false : restoreQualify;
|
||||
boolean supportsQualify = asList(POSTGRES, SQLITE).contains(ctx.family()) ? false : restoreQualify;
|
||||
|
||||
for (Entry<Field<?>, Field<?>> entry : entrySet()) {
|
||||
ctx.sql(separator);
|
||||
|
||||
@ -183,15 +183,15 @@ class Function<T> extends AbstractField<T> implements
|
||||
|
||||
@Override
|
||||
public /* final */ void accept(Context<?> ctx) {
|
||||
if (term == LIST_AGG && asList(CUBRID, H2, HSQLDB, MARIADB, MYSQL).contains(ctx.configuration().dialect())) {
|
||||
if (term == LIST_AGG && asList(CUBRID, H2, HSQLDB, MARIADB, MYSQL).contains(ctx.family())) {
|
||||
toSQLGroupConcat(ctx);
|
||||
}
|
||||
else if (term == LIST_AGG && asList(POSTGRES).contains(ctx.configuration().dialect())) {
|
||||
else if (term == LIST_AGG && asList(POSTGRES).contains(ctx.family())) {
|
||||
toSQLStringAgg(ctx);
|
||||
toSQLOverClause(ctx);
|
||||
}
|
||||
/* [pro] xx
|
||||
xxxx xx xxxxx xx xxxxxxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
|
||||
xxxx xx xxxxx xx xxxxxxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x
|
||||
xxxxxxxxxxxxxxxxx
|
||||
x
|
||||
xx [/pro] */
|
||||
@ -337,7 +337,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
|
||||
// [#531] Inline window specifications if the WINDOW clause is not supported
|
||||
if (windowName != null) {
|
||||
if (asList(POSTGRES).contains(ctx.configuration().dialect().family())) {
|
||||
if (asList(POSTGRES).contains(ctx.family())) {
|
||||
return windowName;
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
ctx.keyword("distinct");
|
||||
|
||||
// [#2883] PostgreSQL can use the DISTINCT keyword with formal row value expressions.
|
||||
if (ctx.configuration().dialect().family() == POSTGRES && arguments.size() > 1) {
|
||||
if (ctx.family() == POSTGRES && arguments.size() > 1) {
|
||||
ctx.sql("(");
|
||||
}
|
||||
else {
|
||||
@ -412,14 +412,14 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
|
||||
if (distinct) {
|
||||
if (ctx.configuration().dialect().family() == POSTGRES && arguments.size() > 1) {
|
||||
if (ctx.family() == POSTGRES && arguments.size() > 1) {
|
||||
ctx.sql(")");
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreNulls) {
|
||||
/* [pro] xx
|
||||
xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxxxxxxxxxx x
|
||||
xx xxxxxxxxxxxxx xx xxxxxxxxxxxxxxx x
|
||||
xxxxxxxxxx xxxxxxx xxxxxxxxx
|
||||
x
|
||||
xxxx
|
||||
@ -430,7 +430,7 @@ class Function<T> extends AbstractField<T> implements
|
||||
}
|
||||
else if (respectNulls) {
|
||||
/* [pro] xx
|
||||
xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxxxxxxxxxx x
|
||||
xx xxxxxxxxxxxxx xx xxxxxxxxxxxxxxx x
|
||||
xxxxxxxxxx xxxxxxxx xxxxxxxxx
|
||||
x
|
||||
xxxx
|
||||
|
||||
@ -78,7 +78,7 @@ class GenerateSeries extends AbstractTable<Record1<Integer>> {
|
||||
}
|
||||
|
||||
private final QueryPart delegate(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
case CUBRID:
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
|
||||
@ -69,7 +69,7 @@ class Left extends AbstractFunction<String> {
|
||||
|
||||
@Override
|
||||
final QueryPart getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xx [/pro] */
|
||||
|
||||
@ -74,15 +74,17 @@ class Limit extends AbstractQueryPart {
|
||||
ParamType paramType = context.paramType();
|
||||
CastMode castMode = context.castMode();
|
||||
|
||||
switch (context.configuration().dialect()) {
|
||||
switch (context.dialect()) {
|
||||
|
||||
// True LIMIT / OFFSET support provided by the following dialects
|
||||
// -----------------------------------------------------------------
|
||||
case MARIADB:
|
||||
case MYSQL: // No break
|
||||
case H2: // No break
|
||||
case HSQLDB: // No break
|
||||
case POSTGRES: // No break
|
||||
case MYSQL:
|
||||
case H2:
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
case POSTGRES_9_3:
|
||||
case POSTGRES_9_4:
|
||||
case SQLITE: {
|
||||
context.castMode(NEVER)
|
||||
.formatSeparator()
|
||||
|
||||
@ -67,7 +67,7 @@ class Nvl<T> extends AbstractFunction<T> {
|
||||
|
||||
@Override
|
||||
final Field<T> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxx xx xxxxx xxxx xxxxxx xxxxxxxxxxxxxx xxxxx xxxxxx
|
||||
|
||||
@ -119,7 +119,7 @@ class QuantifiedSelectImpl<R extends Record> extends AbstractQueryPart implement
|
||||
return (QueryPartInternal) query;
|
||||
}
|
||||
else {
|
||||
switch (ctx.dialect()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
// [#869] Postgres supports this syntax natively
|
||||
case POSTGRES: {
|
||||
|
||||
@ -64,7 +64,7 @@ class Rand extends AbstractFunction<BigDecimal> {
|
||||
|
||||
@Override
|
||||
final Field<BigDecimal> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxx
|
||||
|
||||
@ -68,7 +68,7 @@ class RegexpLike extends AbstractCondition {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
// [#620] These databases are compatible with the MySQL syntax
|
||||
/* [pro] xx
|
||||
|
||||
@ -66,7 +66,7 @@ class Replace extends AbstractFunction<String> {
|
||||
Field<?>[] args = getArguments();
|
||||
|
||||
// [#861] Most dialects don't ship with a two-argument replace function:
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxx x
|
||||
xx xxxxxxxxxxxx xx xx x
|
||||
|
||||
@ -63,7 +63,7 @@ class Reverse extends AbstractFunction<String> {
|
||||
|
||||
@Override
|
||||
QueryPart getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx xxxxxxx
|
||||
|
||||
@ -69,7 +69,7 @@ class Right extends AbstractFunction<String> {
|
||||
|
||||
@Override
|
||||
final QueryPart getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
case DERBY:
|
||||
return DSL.substring(field, field.length().add(one()).sub(length));
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ class Round<T extends Number> extends AbstractFunction<T> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
final Field<T> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
|
||||
// evaluate "round" if unavailable
|
||||
case DERBY: {
|
||||
|
||||
@ -133,7 +133,7 @@ public class SequenceImpl<T extends Number> extends AbstractQueryPart implements
|
||||
|
||||
@Override
|
||||
final Field<T> getFunction0(Configuration configuration) {
|
||||
SQLDialect family = configuration.dialect().family();
|
||||
SQLDialect family = configuration.family();
|
||||
|
||||
switch (family) {
|
||||
/* [pro] xx
|
||||
|
||||
@ -69,7 +69,7 @@ class Sinh extends AbstractFunction<BigDecimal> {
|
||||
|
||||
@Override
|
||||
final Field<BigDecimal> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxx xxxx
|
||||
|
||||
@ -61,7 +61,7 @@ class Space extends AbstractFunction<String> {
|
||||
|
||||
@Override
|
||||
final QueryPart getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxx
|
||||
xxxx xxxxxxx
|
||||
|
||||
@ -69,7 +69,7 @@ class Tanh extends AbstractFunction<BigDecimal> {
|
||||
|
||||
@Override
|
||||
final Field<BigDecimal> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxx xxxx
|
||||
|
||||
@ -73,7 +73,7 @@ class TimestampDiff extends AbstractFunction<DayToSecond> {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
final Field<DayToSecond> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
|
||||
xx xx xxxxxx xxxx xxx xxxxxxx xxxxxxxxxxxx xx xxxxxxxxxx
|
||||
|
||||
@ -75,7 +75,7 @@ class Trunc<T> extends AbstractFunction<T> {
|
||||
|
||||
@Override
|
||||
final Field<T> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
/* [pro] xx
|
||||
xxxx xxxxxxx
|
||||
xxxx xxxx
|
||||
|
||||
@ -75,7 +75,7 @@ class TruncDate<T extends java.util.Date> extends AbstractFunction<T> {
|
||||
String keyword = null;
|
||||
String format = null;
|
||||
|
||||
switch (configuration.dialect().family()) {
|
||||
switch (configuration.family()) {
|
||||
|
||||
// [http://jira.cubrid.org/browse/ENGINE-120] This currently doesn't work for all date parts in CUBRID
|
||||
case CUBRID:
|
||||
|
||||
@ -73,7 +73,7 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
}
|
||||
|
||||
final void toSQL0(RenderContext context) {
|
||||
switch (context.configuration().dialect().family()) {
|
||||
switch (context.family()) {
|
||||
|
||||
/* [pro] xx
|
||||
xx xxxxxx xxxxxxxx xxxxxxxxxxxxxxxxx xxxxx xxx xxxxxx xxx xx xxxxx
|
||||
@ -138,7 +138,7 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
|
||||
private String getInlineConstructor(RenderContext context) {
|
||||
// TODO [#884] Fix this with a local render context (using ctx.literal)
|
||||
switch (context.configuration().dialect().family()) {
|
||||
switch (context.family()) {
|
||||
case POSTGRES:
|
||||
return "ROW";
|
||||
|
||||
@ -163,7 +163,7 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
}
|
||||
|
||||
final void bind0(BindContext context) {
|
||||
switch (context.configuration().dialect().family()) {
|
||||
switch (context.family()) {
|
||||
|
||||
/* [pro] xx
|
||||
xx xxxxxx xxxxxxxx xxxxxxxxxxxxxxxxx xxxxx xxx xxxxxx xxx xx xxxxx
|
||||
@ -187,7 +187,7 @@ class UDTConstant<R extends UDTRecord<R>> extends AbstractParam<R> {
|
||||
}
|
||||
|
||||
default:
|
||||
throw new SQLDialectNotSupportedException("UDTs not supported in dialect " + context.configuration().dialect());
|
||||
throw new SQLDialectNotSupportedException("UDTs not supported in dialect " + context.dialect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class Values<R extends Record> extends AbstractTable<R> {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.configuration().dialect().family()) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
// [#915] Simulate VALUES(..) with SELECT .. UNION ALL SELECT ..
|
||||
// for those dialects that do not support a VALUES() constructor
|
||||
|
||||
@ -86,7 +86,7 @@ class WindowDefinitionImpl extends AbstractQueryPart implements WindowDefinition
|
||||
|
||||
// Outside the WINDOW clause, only few dialects actually support
|
||||
// referencing WINDOW definitions
|
||||
else if (asList(ctx.configuration().dialect()).contains(POSTGRES)) {
|
||||
else if (asList(ctx.family()).contains(POSTGRES)) {
|
||||
ctx.visit(name);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user