diff --git a/jOOQ/src/main/java/org/jooq/SchemaMapping.java b/jOOQ/src/main/java/org/jooq/SchemaMapping.java
index 2bbd750269..659759df4b 100644
--- a/jOOQ/src/main/java/org/jooq/SchemaMapping.java
+++ b/jOOQ/src/main/java/org/jooq/SchemaMapping.java
@@ -322,6 +322,11 @@ public class SchemaMapping implements Serializable {
result = getCatalogs().get(catalogName);
}
+ // [#4642] [#13723] There can still be a default name (e.g. from
+ // code generation, even when there's no runtime schema mapping
+ else if ("".equals(result.getName()))
+ result = null;
+
return result;
}
@@ -341,6 +346,9 @@ public class SchemaMapping implements Serializable {
else if (schema instanceof RenamedSchema) return schema;
Schema result = schema;
+ if (result == null)
+ result = schema(name(""));
+
RenderMapping m = mapping();
// [#4642] Don't initialise schema mapping if not necessary
@@ -349,9 +357,6 @@ public class SchemaMapping implements Serializable {
!isEmpty(m.getDefaultSchema()) ||
!isEmpty(m.getDefaultCatalog())) {
- if (result == null)
- result = schema(name(""));
-
Catalog catalog = result.getCatalog();
if (catalog == null)
catalog = DSL.catalog(name(""));
@@ -433,6 +438,11 @@ public class SchemaMapping implements Serializable {
result = getSchemata().get(key);
}
+ // [#4642] [#13723] There can still be a default name (e.g. from
+ // code generation, even when there's no runtime schema mapping
+ else if ("".equals(result.getName()))
+ result = null;
+
return result;
}