[jOOQ/jOOQ#10313] SQLDialect.supportedBy() sets should be used with
contains(dialect), not contains(family)
This commit is contained in:
parent
aa2afc3b23
commit
8043e3577d
@ -176,8 +176,8 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart {
|
||||
// They can be emulated by concatenating a dummy SELECT with no
|
||||
// results using UNION ALL
|
||||
else if (fieldAliases != null && (
|
||||
SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL2.contains(family)
|
||||
|| SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL3.contains(family))) {
|
||||
SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL2.contains(dialect)
|
||||
|| SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL3.contains(dialect))) {
|
||||
|
||||
emulatedDerivedColumnList = true;
|
||||
|
||||
@ -194,7 +194,7 @@ final class Alias<Q extends QueryPart> extends AbstractQueryPart {
|
||||
|
||||
// [#9486] H2 cannot handle duplicate column names in derived tables, despite derived column lists
|
||||
// See: https://github.com/h2database/h2database/issues/2532
|
||||
if (SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL3.contains(family)) {
|
||||
if (SUPPORT_DERIVED_COLUMN_NAMES_SPECIAL3.contains(dialect)) {
|
||||
List<Name> names = fieldNames(select);
|
||||
|
||||
if (names.size() > 0 && names.size() == new HashSet<>(names).size()) {
|
||||
|
||||
@ -1143,8 +1143,8 @@ final class AlterTableImpl extends AbstractRowCountQuery implements
|
||||
|
||||
boolean omitAlterTable =
|
||||
(renameConstraint != null && family == HSQLDB)
|
||||
|| (renameColumn != null && SUPPORT_RENAME_COLUMN.contains(family));
|
||||
boolean renameTable = renameTo != null && SUPPORT_RENAME_TABLE.contains(family);
|
||||
|| (renameColumn != null && SUPPORT_RENAME_COLUMN.contains(ctx.dialect()));
|
||||
boolean renameTable = renameTo != null && SUPPORT_RENAME_TABLE.contains(ctx.dialect());
|
||||
boolean renameObject = renameTo != null && (false );
|
||||
|
||||
if (!omitAlterTable) {
|
||||
@ -1504,7 +1504,7 @@ final class AlterTableImpl extends AbstractRowCountQuery implements
|
||||
toSQLDDLTypeDeclarationIdentityBeforeNull(ctx, alterColumnType);
|
||||
|
||||
// [#3805] Some databases cannot change the type and the NOT NULL constraint in a single statement
|
||||
if (!NO_SUPPORT_ALTER_TYPE_AND_NULL.contains(family)) {
|
||||
if (!NO_SUPPORT_ALTER_TYPE_AND_NULL.contains(ctx.dialect())) {
|
||||
switch (alterColumnType.nullability()) {
|
||||
case NULL:
|
||||
ctx.sql(' ').visit(K_NULL);
|
||||
@ -1597,7 +1597,7 @@ final class AlterTableImpl extends AbstractRowCountQuery implements
|
||||
else if (dropColumns != null) {
|
||||
ctx.start(ALTER_TABLE_DROP);
|
||||
|
||||
if (REQUIRE_REPEAT_DROP_ON_MULTI_ALTER.contains(family)) {
|
||||
if (REQUIRE_REPEAT_DROP_ON_MULTI_ALTER.contains(ctx.dialect())) {
|
||||
String separator = "";
|
||||
|
||||
for (Field<?> dropColumn : dropColumns) {
|
||||
@ -1659,12 +1659,12 @@ final class AlterTableImpl extends AbstractRowCountQuery implements
|
||||
ctx.start(ALTER_TABLE_DROP);
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, true);
|
||||
|
||||
if (dropConstraintType == FOREIGN_KEY && NO_SUPPORT_DROP_CONSTRAINT.contains(family)) {
|
||||
if (dropConstraintType == FOREIGN_KEY && NO_SUPPORT_DROP_CONSTRAINT.contains(ctx.dialect())) {
|
||||
ctx.visit(K_DROP).sql(' ').visit(K_FOREIGN_KEY)
|
||||
.sql(' ')
|
||||
.visit(dropConstraint);
|
||||
}
|
||||
else if (dropConstraintType == PRIMARY_KEY && NO_SUPPORT_DROP_CONSTRAINT.contains(family)) {
|
||||
else if (dropConstraintType == PRIMARY_KEY && NO_SUPPORT_DROP_CONSTRAINT.contains(ctx.dialect())) {
|
||||
ctx.visit(K_DROP).sql(' ').visit(K_PRIMARY_KEY);
|
||||
}
|
||||
else {
|
||||
|
||||
@ -142,14 +142,14 @@ final class CompareCondition extends AbstractCondition implements LikeEscapeStep
|
||||
// VARCHAR when applying a LIKE predicate
|
||||
if ((op == LIKE || op == NOT_LIKE || op == SIMILAR_TO || op == NOT_SIMILAR_TO)
|
||||
&& field1.getType() != String.class
|
||||
&& REQUIRES_CAST_ON_LIKE.contains(family)) {
|
||||
&& REQUIRES_CAST_ON_LIKE.contains(ctx.dialect())) {
|
||||
|
||||
lhs = castIfNeeded(lhs, String.class);
|
||||
}
|
||||
|
||||
// [#1423] [#9889] PostgreSQL and H2 support ILIKE natively. Other dialects
|
||||
// need to emulate this as LOWER(lhs) LIKE LOWER(rhs)
|
||||
else if ((op == LIKE_IGNORE_CASE || op == NOT_LIKE_IGNORE_CASE) && NO_SUPPORT_ILIKE.contains(family)) {
|
||||
else if ((op == LIKE_IGNORE_CASE || op == NOT_LIKE_IGNORE_CASE) && NO_SUPPORT_ILIKE.contains(ctx.dialect())) {
|
||||
lhs = lhs.lower();
|
||||
rhs = rhs.lower();
|
||||
op = (op == LIKE_IGNORE_CASE ? LIKE : NOT_LIKE);
|
||||
|
||||
@ -264,12 +264,10 @@ implements
|
||||
}
|
||||
|
||||
private final void accept0(Context<?> ctx) {
|
||||
SQLDialect family = ctx.family();
|
||||
|
||||
ctx.start(Clause.CREATE_SEQUENCE_SEQUENCE)
|
||||
.visit(K_CREATE)
|
||||
.sql(' ')
|
||||
.visit(family == CUBRID ? K_SERIAL : K_SEQUENCE)
|
||||
.visit(ctx.family() == CUBRID ? K_SERIAL : K_SEQUENCE)
|
||||
.sql(' ');
|
||||
|
||||
if (createSequenceIfNotExists && supportsIfNotExists(ctx))
|
||||
@ -277,10 +275,10 @@ implements
|
||||
.sql(' ');
|
||||
|
||||
ctx.visit(sequence);
|
||||
String noSeparator = NO_SEPARATOR.contains(family) ? "" : " ";
|
||||
String noSeparator = NO_SEPARATOR.contains(ctx.dialect()) ? "" : " ";
|
||||
|
||||
// Some databases default to sequences starting with MIN_VALUE
|
||||
if (startWith == null && REQUIRES_START_WITH.contains(family))
|
||||
if (startWith == null && REQUIRES_START_WITH.contains(ctx.dialect()))
|
||||
ctx.sql(' ').visit(K_START_WITH).sql(" 1");
|
||||
else if (startWith != null)
|
||||
ctx.sql(' ').visit(K_START_WITH).sql(' ').visit(startWith);
|
||||
@ -290,23 +288,23 @@ implements
|
||||
|
||||
if (minvalue != null)
|
||||
ctx.sql(' ').visit(K_MINVALUE).sql(' ').visit(minvalue);
|
||||
else if (noMinvalue && !OMIT_NO_MINVALUE.contains(family))
|
||||
else if (noMinvalue && !OMIT_NO_MINVALUE.contains(ctx.dialect()))
|
||||
ctx.sql(' ').visit(K_NO).sql(noSeparator).visit(K_MINVALUE);
|
||||
|
||||
if (maxvalue != null)
|
||||
ctx.sql(' ').visit(K_MAXVALUE).sql(' ').visit(maxvalue);
|
||||
else if (noMaxvalue && !OMIT_NO_MAXVALUE.contains(family))
|
||||
else if (noMaxvalue && !OMIT_NO_MAXVALUE.contains(ctx.dialect()))
|
||||
ctx.sql(' ').visit(K_NO).sql(noSeparator).visit(K_MAXVALUE);
|
||||
|
||||
if (cycle)
|
||||
ctx.sql(' ').visit(K_CYCLE);
|
||||
else if (noCycle && !OMIT_NO_CYCLE.contains(family))
|
||||
else if (noCycle && !OMIT_NO_CYCLE.contains(ctx.dialect()))
|
||||
ctx.sql(' ').visit(K_NO).sql(noSeparator).visit(K_CYCLE);
|
||||
|
||||
if (!NO_SUPPORT_CACHE.contains(family))
|
||||
if (!NO_SUPPORT_CACHE.contains(ctx.dialect()))
|
||||
if (cache != null)
|
||||
ctx.sql(' ').visit(K_CACHE).sql(' ').visit(cache);
|
||||
else if (noCache && !OMIT_NO_CACHE.contains(family))
|
||||
else if (noCache && !OMIT_NO_CACHE.contains(ctx.dialect()))
|
||||
ctx.sql(' ').visit(K_NO).sql(noSeparator).visit(K_CACHE);
|
||||
|
||||
ctx.end(Clause.CREATE_SEQUENCE_SEQUENCE);
|
||||
|
||||
@ -657,7 +657,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
SQLDialect family = ctx.family();
|
||||
|
||||
// [#822] Some RDBMS need precision / scale information on BigDecimals
|
||||
if (converted != null && type == BigDecimal.class && NEEDS_PRECISION_SCALE_ON_BIGDECIMAL.contains(family)) {
|
||||
if (converted != null && type == BigDecimal.class && NEEDS_PRECISION_SCALE_ON_BIGDECIMAL.contains(ctx.dialect())) {
|
||||
|
||||
// Add precision / scale on BigDecimals
|
||||
int scale = ((BigDecimal) converted).scale();
|
||||
@ -700,7 +700,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
// [#1130] TODO type can be null for ARRAY types, etc.
|
||||
// [#7351] UUID data types need to be cast too
|
||||
// [#7242] JSON(B) data types need to be cast too
|
||||
else if (REQUIRES_JSON_CAST.contains(family) &&
|
||||
else if (REQUIRES_JSON_CAST.contains(ctx.dialect()) &&
|
||||
(sqlDataType == null ||
|
||||
(!sqlDataType.isTemporal()
|
||||
&& sqlDataType != SQLDataType.UUID
|
||||
@ -720,7 +720,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
// [#7379] Most databases cannot cast a bind variable to an enum type
|
||||
else if (!NO_SUPPORT_ENUM_CAST.contains(family) && EnumType.class.isAssignableFrom(type))
|
||||
else if (!NO_SUPPORT_ENUM_CAST.contains(ctx.dialect()) && EnumType.class.isAssignableFrom(type))
|
||||
sqlCast(
|
||||
ctx,
|
||||
converted,
|
||||
|
||||
@ -172,15 +172,15 @@ final class Expression<T> extends AbstractField<T> {
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// DB2, H2 and HSQLDB know functions, instead of operators
|
||||
if (BIT_AND == operator && SUPPORT_BIT_AND.contains(family))
|
||||
if (BIT_AND == operator && SUPPORT_BIT_AND.contains(ctx.dialect()))
|
||||
ctx.visit(function("bitand", getDataType(), arguments));
|
||||
else if (BIT_AND == operator && FIREBIRD == family)
|
||||
ctx.visit(function("bin_and", getDataType(), arguments));
|
||||
else if (BIT_XOR == operator && SUPPORT_BIT_OR_XOR.contains(family))
|
||||
else if (BIT_XOR == operator && SUPPORT_BIT_OR_XOR.contains(ctx.dialect()))
|
||||
ctx.visit(function("bitxor", getDataType(), arguments));
|
||||
else if (BIT_XOR == operator && FIREBIRD == family)
|
||||
ctx.visit(function("bin_xor", getDataType(), arguments));
|
||||
else if (BIT_OR == operator && SUPPORT_BIT_OR_XOR.contains(family))
|
||||
else if (BIT_OR == operator && SUPPORT_BIT_OR_XOR.contains(ctx.dialect()))
|
||||
ctx.visit(function("bitor", getDataType(), arguments));
|
||||
else if (BIT_OR == operator && FIREBIRD == family)
|
||||
ctx.visit(function("bin_or", getDataType(), arguments));
|
||||
@ -192,7 +192,7 @@ final class Expression<T> extends AbstractField<T> {
|
||||
|
||||
|
||||
// ~(a & b) & (a | b)
|
||||
else if (BIT_XOR == operator && EMULATE_BIT_XOR.contains(family))
|
||||
else if (BIT_XOR == operator && EMULATE_BIT_XOR.contains(ctx.dialect()))
|
||||
ctx.visit(DSL.bitAnd(
|
||||
DSL.bitNot(DSL.bitAnd(lhsAsNumber(), rhsAsNumber())),
|
||||
DSL.bitOr(lhsAsNumber(), rhsAsNumber())));
|
||||
@ -211,12 +211,12 @@ final class Expression<T> extends AbstractField<T> {
|
||||
ctx.visit(function(SHL == operator ? "bin_shl" : "bin_shr", getDataType(), arguments));
|
||||
|
||||
// Many dialects don't support shifts. Use multiplication/division instead
|
||||
else if (SHL == operator && EMULATE_SHR_SHL.contains(family))
|
||||
else if (SHL == operator && EMULATE_SHR_SHL.contains(ctx.dialect()))
|
||||
ctx.visit(lhs.mul((Field<? extends Number>) castIfNeeded(DSL.power(two(), rhsAsNumber()), lhs)));
|
||||
|
||||
// [#3962] This emulation is expensive. If this is emulated, BitCount should
|
||||
// use division instead of SHR directly
|
||||
else if (SHR == operator && EMULATE_SHR_SHL.contains(family))
|
||||
else if (SHR == operator && EMULATE_SHR_SHL.contains(ctx.dialect()))
|
||||
ctx.visit(lhs.div((Field<? extends Number>) castIfNeeded(DSL.power(two(), rhsAsNumber()), lhs)));
|
||||
|
||||
// Use the default operator expression for all other cases
|
||||
|
||||
@ -80,11 +80,11 @@ final class Neg<T> extends AbstractField<T> {
|
||||
public final void accept(Context<?> ctx) {
|
||||
SQLDialect family = ctx.family();
|
||||
|
||||
if (operator == BIT_NOT && EMULATE_BIT_NOT.contains(family))
|
||||
if (operator == BIT_NOT && EMULATE_BIT_NOT.contains(ctx.dialect()))
|
||||
ctx.sql("(0 - ")
|
||||
.visit(field)
|
||||
.sql(" - 1)");
|
||||
else if (operator == BIT_NOT && SUPPORT_BIT_NOT.contains(family))
|
||||
else if (operator == BIT_NOT && SUPPORT_BIT_NOT.contains(ctx.dialect()))
|
||||
ctx.sql("bitnot(")
|
||||
.visit(field)
|
||||
.sql(')');
|
||||
|
||||
@ -129,8 +129,6 @@ final class RowSubqueryCondition extends AbstractCondition {
|
||||
final Configuration configuration = ctx.configuration();
|
||||
final RenderContext render = ctx instanceof RenderContext ? (RenderContext) ctx : null;
|
||||
|
||||
SQLDialect family = configuration.family();
|
||||
|
||||
// [#3505] TODO: Emulate this where it is not supported
|
||||
if (rightQuantified != null) {
|
||||
return new Native();
|
||||
@ -138,7 +136,7 @@ final class RowSubqueryCondition extends AbstractCondition {
|
||||
|
||||
// [#2395] These dialects have full native support for comparison
|
||||
// predicates with row value expressions and subqueries:
|
||||
else if (SUPPORT_NATIVE.contains(family)) {
|
||||
else if (SUPPORT_NATIVE.contains(ctx.dialect())) {
|
||||
return new Native();
|
||||
}
|
||||
|
||||
|
||||
@ -938,7 +938,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
if (into != null
|
||||
&& !TRUE.equals(context.data(DATA_OMIT_INTO_CLAUSE))
|
||||
&& EMULATE_SELECT_INTO_AS_CTAS.contains(family)) {
|
||||
&& EMULATE_SELECT_INTO_AS_CTAS.contains(dialect)) {
|
||||
|
||||
context.data(DATA_OMIT_INTO_CLAUSE, true);
|
||||
context.visit(DSL.createTable(into).as(this));
|
||||
@ -1611,7 +1611,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
if (actualInto != null
|
||||
&& !TRUE.equals(context.data(DATA_OMIT_INTO_CLAUSE))
|
||||
&& (SUPPORT_SELECT_INTO_TABLE.contains(family) || !(actualInto instanceof Table))) {
|
||||
&& (SUPPORT_SELECT_INTO_TABLE.contains(context.dialect()) || !(actualInto instanceof Table))) {
|
||||
|
||||
context.formatSeparator()
|
||||
.visit(K_INTO)
|
||||
@ -1775,7 +1775,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
|
||||
// [#4292] Some dialects don't support empty GROUP BY () clauses
|
||||
else if (EMULATE_EMPTY_GROUP_BY_OTHER.contains(family))
|
||||
else if (EMULATE_EMPTY_GROUP_BY_OTHER.contains(context.dialect()))
|
||||
context.sql('(').visit(DSL.select(one())).sql(')');
|
||||
|
||||
// Few dialects support the SQL standard "grand total" (i.e. empty grouping set)
|
||||
|
||||
@ -2285,7 +2285,7 @@ final class Tools {
|
||||
if (render == null) render = new DefaultRenderContext(bind.configuration());
|
||||
|
||||
SQLDialect family = render.family();
|
||||
boolean mysql = SUPPORT_MYSQL_SYNTAX.contains(family);
|
||||
boolean mysql = SUPPORT_MYSQL_SYNTAX.contains(render.dialect());
|
||||
char[][][] quotes = QUOTES.get(family);
|
||||
|
||||
// [#3630] Depending on this setting, we need to consider backslashes as escape characters within string literals.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user