[jOOQ/jOOQ#12240] Apply fix only to SQL Server

A lot of dialects report some sort of catalog, which can't be used in
SQL, and which we don't know anything about. We mustn't use that catalog
for lookups
This commit is contained in:
Lukas Eder 2021-07-21 16:53:23 +02:00
parent 57115719a9
commit 11d4cfef21

View File

@ -74,6 +74,7 @@ import static org.jooq.impl.Tools.flatMap;
import static org.jooq.impl.Tools.map;
import static org.jooq.tools.StringUtils.defaultIfEmpty;
import static org.jooq.tools.StringUtils.defaultString;
import static org.jooq.tools.StringUtils.isEmpty;
import java.io.Serializable;
import java.sql.DatabaseMetaData;
@ -158,6 +159,10 @@ final class MetaImpl extends AbstractMeta {
this.inverseSchemaCatalog = INVERSE_SCHEMA_CATALOG.contains(dialect());
}
final boolean hasCatalog(Catalog catalog) {
return catalog != null && !isEmpty(catalog.getName());
}
final <R> R catalogSchema(Catalog catalog, Schema schema, ThrowingBiFunction<String, String, R, SQLException> function) throws SQLException {
return catalogSchema(
catalog != null ? catalog.getName() : null,
@ -824,7 +829,7 @@ final class MetaImpl extends AbstractMeta {
// [#7377] The schema may be null instead of "" in some dialects
Schema schema = schemas.get(name(
defaultString(k.get(0, String.class)),
hasCatalog(getCatalog()) ? defaultString(k.get(0, String.class)) : null,
defaultString(k.get(1, String.class))
));