Skip to content

Commit

Permalink
[jOOQ#2262] RenderSchema has no effect, if not supplied to the Executor
Browse files Browse the repository at this point in the history
constructor

Conflicts:
	jOOQ/src/test/java/org/jooq/test/SettingsTest.java
  • Loading branch information
lukaseder committed Feb 26, 2013
1 parent 76cb9e3 commit 5985615
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
15 changes: 5 additions & 10 deletions jOOQ/src/main/java/org/jooq/SchemaMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,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;

Expand Down Expand Up @@ -129,22 +128,18 @@ public SchemaMapping(Configuration configuration) {
* 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;
}

private final RenderMapping mapping() {
return SettingsTools.getRenderMapping(configuration.getSettings());
}

private final boolean renderSchema() {
return Boolean.TRUE.equals(configuration.getSettings().isRenderSchema());
}

private static void logDeprecation() {
if (!loggedDeprecation) {

Expand Down Expand Up @@ -311,7 +306,7 @@ public Schema map(Schema schema) {

// [#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;
Expand Down
21 changes: 21 additions & 0 deletions jOOQ/src/test/java/org/jooq/test/SettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@
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.Factory;
import org.jooq.impl.SchemaImpl;
import org.jooq.impl.TableImpl;

import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -77,6 +82,22 @@ public void testDefaultSettings() {
assertFalse(settings.isAttachRecords());
}

@Test
public void testRenderSchema() {
Schema schema = new SchemaImpl("S");
Table<?> table = new TableImpl<Record>("T", schema);

Factory create0 = new Factory(SQLDialect.ORACLE);
assertEquals("\"S\".\"T\"", create0.render(table));

Factory create1 = new Factory(SQLDialect.ORACLE, new Settings().withRenderSchema(false));
assertEquals("\"T\"", create1.render(table));

Factory create2 = new Factory(SQLDialect.ORACLE);
create2.getSettings().setRenderSchema(false);
assertEquals("\"T\"", create2.render(table));
}

@Test
public void testRenderMapping() {
Factory create1 = new Factory(SQLDialect.ORACLE, new Settings().withRenderMapping(mapping()));
Expand Down

0 comments on commit 5985615

Please sign in to comment.