[jOOQ/jOOQ#9777] Add SQLDialect.supportedUntil()

This commit is contained in:
Lukas Eder 2020-01-30 12:54:44 +01:00
parent cf59e643e5
commit dc9de88262
3 changed files with 33 additions and 28 deletions

View File

@ -645,33 +645,57 @@ public enum SQLDialect {
}
/**
* Get a set of supported dialect versions given a dialect version.
* Get a set of supported dialect versions and predecessors given a dialect
* version.
* <p>
* The resulting set of dialects contain all the families and dialect
* versions that support the argument dialect.
* versions that precede the argument dialect.
*/
public static final Set<SQLDialect> supportedUntil(SQLDialect dialect) {
return predecessors(dialect);
}
/**
* Get a set of supported dialect versions and predecessors given a dialect
* version.
* <p>
* The resulting set of dialects contain all the families and dialect
* versions that precede the argument dialect.
*/
public static final Set<SQLDialect> supportedUntil(SQLDialect... dialects) {
return predecessors(dialects);
}
/**
* Get a set of supported dialect versions and successors given a dialect
* version.
* <p>
* The resulting set of dialects contain all the families and dialect
* versions that support the argument dialect, i.e. that succeed it.
*/
public static final Set<SQLDialect> supportedBy(SQLDialect dialect) {
EnumSet<SQLDialect> result = EnumSet.noneOf(SQLDialect.class);
addSupported(dialect, result);
addSupportedBy(dialect, result);
return Collections.unmodifiableSet(result);
}
/**
* Get a set of supported dialect versions given a set of dialect versions.
* Get a set of supported dialect versions and successors given a set of
* dialect versions.
* <p>
* The resulting set of dialects contain all the families and dialect
* versions that support the argument dialects.
* versions that support the argument dialects, i.e. that succeed them.
*/
public static final Set<SQLDialect> supportedBy(SQLDialect... dialects) {
EnumSet<SQLDialect> result = EnumSet.noneOf(SQLDialect.class);
for (SQLDialect dialect : dialects)
addSupported(dialect, result);
addSupportedBy(dialect, result);
return Collections.unmodifiableSet(result);
}
private static final void addSupported(SQLDialect dialect, EnumSet<SQLDialect> supported) {
private static final void addSupportedBy(SQLDialect dialect, EnumSet<SQLDialect> supported) {
supported.add(dialect);
if (dialect.isFamily())

View File

@ -150,7 +150,6 @@ import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
@ -216,7 +215,7 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
private static final Set<SQLDialect> NO_SUPPORT_FOR_UPDATE_QUALIFIED = SQLDialect.supportedBy(DERBY, FIREBIRD, H2, HSQLDB);
private static final Set<SQLDialect> SUPPORT_SELECT_INTO_TABLE = SQLDialect.supportedBy(HSQLDB, POSTGRES);
static final Set<SQLDialect> SUPPORT_WINDOW_CLAUSE = SQLDialect.supportedBy(H2 /* -- See [#8279] */, MYSQL, POSTGRES /*, SQLITE -- See [#8279] [#8548] */);
private static final Set<SQLDialect> REQUIRES_FROM_CLAUSE;
private static final Set<SQLDialect> REQUIRES_FROM_CLAUSE = SQLDialect.supportedUntil(CUBRID, DERBY, FIREBIRD, HSQLDB);
private static final Set<SQLDialect> REQUIRES_DERIVED_TABLE_DML = SQLDialect.supportedBy(MARIADB, MYSQL);
private static final Set<SQLDialect> EMULATE_EMPTY_GROUP_BY_OTHER = SQLDialect.supportedBy(FIREBIRD, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE);
private static final Set<SQLDialect> SUPPORT_FULL_WITH_TIES = SQLDialect.supportedBy(H2);
@ -235,20 +234,12 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
static {
Set<SQLDialect> temp = EnumSet.copyOf(SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, HSQLDB));
REQUIRES_FROM_CLAUSE = Collections.unmodifiableSet(temp);
}
private final WithImpl with;
private final SelectFieldList<SelectFieldOrAsterisk> select;
private Table<?> into;

View File

@ -61,8 +61,6 @@ import static org.jooq.impl.Keywords.K_TABLE;
import static org.jooq.impl.Keywords.K_VALUES;
import static org.jooq.impl.Names.N_VALUES;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
import org.jooq.Context;
@ -85,15 +83,7 @@ final class Values<R extends Record> extends AbstractTable<R> {
* Generated UID
*/
private static final long serialVersionUID = -637982217747670311L;
private static final Set<SQLDialect> NO_SUPPORT_VALUES;
static {
Set<SQLDialect> temp = EnumSet.copyOf(SQLDialect.supportedBy(FIREBIRD, MARIADB));
NO_SUPPORT_VALUES = Collections.unmodifiableSet(temp);
}
private static final Set<SQLDialect> NO_SUPPORT_VALUES = SQLDialect.supportedUntil(FIREBIRD, MARIADB);
private final Row[] rows;