Skip to content

Commit

Permalink
[#8547] Fix SQLITE comparisons against dialect
Browse files Browse the repository at this point in the history
SQLITE should normally be compared against the dialect family.

Also replace some occurrences of `context.configuration().dialect()`
with `context.dialect()`.
  • Loading branch information
knutwannheden committed May 28, 2019
1 parent 2b26053 commit d751d6e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions jOOQ-meta/src/main/java/org/jooq/meta/Databases.java
Expand Up @@ -133,6 +133,10 @@ public static final Class<? extends Database> databaseClass(SQLDialect dialect)


case POSTGRES: result = PostgresDatabase.class; break;




case SQLITE: result = SQLiteDatabase.class; break;

case DEFAULT:
Expand Down
2 changes: 1 addition & 1 deletion jOOQ/src/main/java/org/jooq/impl/CaseWhenStepImpl.java
Expand Up @@ -226,7 +226,7 @@ public final void accept(Context<?> ctx) {
.visit(K_CASE);

int size = compareValues.size();
switch (ctx.configuration().dialect()) {
switch (ctx.dialect()) {

// The DERBY dialect doesn't support the simple CASE clause
case DERBY: {
Expand Down
2 changes: 1 addition & 1 deletion jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java
Expand Up @@ -1444,7 +1444,7 @@ final void set0(BindingSetSQLOutputContext<U> ctx, BigInteger value) throws SQLE
final BigInteger get0(BindingGetResultSetContext<U> ctx) throws SQLException {

// The SQLite JDBC driver doesn't support BigDecimals
if (ctx.configuration().dialect() == SQLDialect.SQLITE)
if (ctx.family() == SQLDialect.SQLITE)
return Convert.convert(ctx.resultSet().getString(ctx.index()), BigInteger.class);

BigDecimal b = ctx.resultSet().getBigDecimal(ctx.index());
Expand Down
2 changes: 1 addition & 1 deletion jOOQ/src/main/java/org/jooq/impl/Function.java
Expand Up @@ -642,7 +642,7 @@ final void toSQLFunctionName(Context<?> ctx) {
if (name != null)
ctx.visit(name);
else if (term != null)
ctx.sql(term.translate(ctx.configuration().dialect()));
ctx.sql(term.translate(ctx.dialect()));
else
ctx.sql(getName());
}
Expand Down
4 changes: 2 additions & 2 deletions jOOQ/src/main/java/org/jooq/impl/FunctionTable.java
Expand Up @@ -82,7 +82,7 @@ public final Table<R> as(Name as, Name... fieldAliases) {

@Override
public final void accept(Context<?> ctx) {
switch (ctx.configuration().dialect()) {
switch (ctx.dialect()) {
case HSQLDB: {
ctx.visit(K_TABLE).sql('(').visit(function).sql(')');
break;
Expand All @@ -99,7 +99,7 @@ public final void accept(Context<?> ctx) {
}

default:
throw new SQLDialectNotSupportedException("FUNCTION TABLE is not supported for " + ctx.configuration().dialect());
throw new SQLDialectNotSupportedException("FUNCTION TABLE is not supported for " + ctx.dialect());
}
}

Expand Down
2 changes: 1 addition & 1 deletion jOOQ/src/main/java/org/jooq/impl/MetaImpl.java
Expand Up @@ -429,7 +429,7 @@ private final Result<Record> getColumns(String schema, String table) {

// SQLite JDBC's DatabaseMetaData.getColumns() can only return a single
// table's columns
if (columnCache == null && configuration.dialect() != SQLITE) {
if (columnCache == null && configuration.family() != SQLITE) {
Result<Record> columns = getColumns0(schema, "%");

Field<String> tableCat = (Field<String>) columns.field(0); // TABLE_CAT
Expand Down

0 comments on commit d751d6e

Please sign in to comment.