From fb09fbbb81c2aeac1631b74a00b174c4d5ca5b6d Mon Sep 17 00:00:00 2001 From: lukaseder Date: Thu, 2 Aug 2018 18:12:27 +0200 Subject: [PATCH] [#7714] Meta.getCatalogs() should not return catalogs in databases that do not support them --- .../src/main/java/org/jooq/impl/MetaImpl.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java b/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java index 776fd008ae..4672e7d01e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/MetaImpl.java @@ -74,12 +74,14 @@ */ package org.jooq.impl; +// ... // ... // ... import static org.jooq.SQLDialect.H2; import static org.jooq.SQLDialect.MARIADB; import static org.jooq.SQLDialect.MYSQL; import static org.jooq.SQLDialect.SQLITE; +// ... import static org.jooq.impl.DSL.condition; import static org.jooq.impl.DSL.name; import static org.jooq.impl.Tools.EMPTY_SORTFIELD; @@ -140,6 +142,9 @@ final class MetaImpl extends AbstractMeta { private static final EnumSet CURRENT_TIMESTAMP_COLUMN_DEFAULT = EnumSet.of(MYSQL, MARIADB); private static final EnumSet EXPRESSION_COLUMN_DEFAULT = EnumSet.of(H2); + + + private final DSLContext ctx; private final Configuration configuration; private final DatabaseMetaData databaseMetaData; @@ -177,21 +182,28 @@ final class MetaImpl extends AbstractMeta { public final List getCatalogs() { List result = new ArrayList(); - // [#2760] MySQL JDBC confuses "catalog" and "schema" - if (!inverseSchemaCatalog) { - Result catalogs = meta(new MetaFunction() { - @Override - public Result run(DatabaseMetaData meta) throws SQLException { - return ctx.fetch( - meta.getCatalogs(), - SQLDataType.VARCHAR // TABLE_CATALOG - ); - } - }); - for (String name : catalogs.getValues(0, String.class)) - result.add(new MetaCatalog(name)); - } + + + + + + + + + + + + + + + + + + + + + // There should always be at least one (empty) catalog in a database if (result.isEmpty()) @@ -281,7 +293,6 @@ final class MetaImpl extends AbstractMeta { } }); - for (String name : schemas.getValues(0, String.class)) result.add(new MetaSchema(name, MetaCatalog.this)); }