diff --git a/jOOQ/src/main/java/org/jooq/SchemaMapping.java b/jOOQ/src/main/java/org/jooq/SchemaMapping.java index 0750a88c5d..586b38816f 100644 --- a/jOOQ/src/main/java/org/jooq/SchemaMapping.java +++ b/jOOQ/src/main/java/org/jooq/SchemaMapping.java @@ -92,7 +92,6 @@ public class SchemaMapping implements Serializable { private final Configuration configuration; private final boolean ignoreMapping; - private final boolean renderSchema; private volatile transient Map schemata; private volatile transient Map> tables; @@ -107,15 +106,7 @@ public class SchemaMapping implements Serializable { * Auxiliary constructor used for backwards-compatibility. */ private SchemaMapping(Configuration configuration, boolean ignore) { - Settings settings = configuration.getSettings(); - - boolean isRenderSchema = true; - if (settings.isRenderSchema() != null) { - isRenderSchema = settings.isRenderSchema(); - } - this.configuration = configuration; - this.renderSchema = isRenderSchema; this.ignoreMapping = ignore; } @@ -123,6 +114,10 @@ public class SchemaMapping implements Serializable { return SettingsTools.getRenderMapping(configuration.getSettings()); } + private final boolean renderSchema() { + return Boolean.TRUE.equals(configuration.getSettings().isRenderSchema()); + } + private static void logDeprecation() { if (!loggedDeprecation) { @@ -289,7 +284,7 @@ public class SchemaMapping implements Serializable { // [#1774] The default Settings render schema flag takes precedence over // The DefaultConfiguration's ignoreMapping flag! - if (!renderSchema) return null; + if (!renderSchema()) return null; if (ignoreMapping) return schema; Schema result = null; diff --git a/jOOQ/src/test/java/org/jooq/test/SettingsTest.java b/jOOQ/src/test/java/org/jooq/test/SettingsTest.java index dc5c166a30..1d715054f6 100644 --- a/jOOQ/src/test/java/org/jooq/test/SettingsTest.java +++ b/jOOQ/src/test/java/org/jooq/test/SettingsTest.java @@ -40,13 +40,18 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.jooq.Record; import org.jooq.SQLDialect; +import org.jooq.Schema; +import org.jooq.Table; import org.jooq.conf.MappedSchema; import org.jooq.conf.MappedTable; import org.jooq.conf.RenderMapping; import org.jooq.conf.Settings; import org.jooq.conf.SettingsTools; import org.jooq.impl.Executor; +import org.jooq.impl.SchemaImpl; +import org.jooq.impl.TableImpl; import org.junit.Before; import org.junit.Test; @@ -77,6 +82,22 @@ public class SettingsTest { assertFalse(settings.isAttachRecords()); } + @Test + public void testRenderSchema() { + Schema schema = new SchemaImpl("S"); + Table table = new TableImpl("T", schema); + + Executor create0 = new Executor(SQLDialect.ORACLE); + assertEquals("\"S\".\"T\"", create0.render(table)); + + Executor create1 = new Executor(SQLDialect.ORACLE, new Settings().withRenderSchema(false)); + assertEquals("\"T\"", create1.render(table)); + + Executor create2 = new Executor(SQLDialect.ORACLE); + create2.getSettings().setRenderSchema(false); + assertEquals("\"T\"", create2.render(table)); + } + @Test public void testRenderMapping() { Executor create1 = new Executor(SQLDialect.ORACLE, new Settings().withRenderMapping(mapping()));