[#2262] RenderSchema has no effect, if not supplied to the Executor

constructor
This commit is contained in:
Lukas Eder 2013-02-24 11:50:51 +01:00
parent 6a6c9d3526
commit 78937968a6
2 changed files with 26 additions and 10 deletions

View File

@ -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<String, Schema> schemata;
private volatile transient Map<String, Table<?>> 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;

View File

@ -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<Record>("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()));