Program: 150523
Project: 150523
Buggy source:
@Test public void testSchemaMapping() throws Exception {
switch (getDialect()) {
case SQLITE:
    log.info("String_Node_Str","String_Node_Str");
  return;
}
Settings settings=new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput(TAuthor().getSchema().getName()).withOutput(TAuthor().getSchema().getName()).withTables(new MappedTable().withInput(TAuthor().getName()).withOutput(TAuthor().getName()),new MappedTable().withInput(TBook().getName()).withOutput(TBook().getName()))));
Select<Record> query=create(settings).select(TBook_TITLE()).from(TAuthor()).join(TBook()).on(TAuthor_ID().equal(TBook_AUTHOR_ID())).orderBy(TBook_ID().asc());
Result<Record> result=query.fetch();
assertEquals("String_Node_Str",result.getValue(0,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(1,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(2,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(3,TBook_TITLE()));
String sql=query.getSQL();
log.info("String_Node_Str",sql);
assertEquals(result,create().fetch(sql,query.getBindValues().toArray()));
switch (getDialect()) {
case ASE:
case DB2:
case DERBY:
case H2:
case HSQLDB:
case INGRES:
case ORACLE:
case POSTGRES:
case SQLITE:
case SQLSERVER:
case SYBASE:
log.info("String_Node_Str","String_Node_Str");
return;
case MYSQL:
if (delegate.getClass() == jOOQMySQLTestSchemaRewrite.class) {
log.info("String_Node_Str","String_Node_Str");
return;
}
}
settings=new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput(TAuthor().getSchema().getName()).withOutput(TAuthor().getSchema().getName() + "String_Node_Str")));
Select<Record> q=create(settings).select(TBook_TITLE()).from(TAuthor()).join(TBook()).on(TAuthor_ID().equal(TBook_AUTHOR_ID())).orderBy(TBook_ID().asc());
assertTrue(create(settings).render(q).contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertTrue(q.getSQL().contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertEquals(create(settings).render(q),q.getSQL());
result=q.fetch();
assertEquals("String_Node_Str",result.getValue(0,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(1,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(2,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(3,TBook_TITLE()));
Field<Integer> f1=FOneField().cast(Integer.class);
Field<Integer> f2=FNumberField(42).cast(Integer.class);
q=create(settings).select(f1,f2);
assertTrue(create(settings).render(q).contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertTrue(q.getSQL().contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertEquals(create(settings).render(q),q.getSQL());
Record record=q.fetchOne();
assertEquals(1,(int)record.getValue(f1));
assertEquals(42,(int)record.getValue(f2));
settings=new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput(TAuthor().getSchema().getName()).withOutput(TAuthor().getSchema().getName() + "String_Node_Str").withTables(new MappedTable().withInput(TAuthor().getName()).withOutput(VAuthor().getName()),new MappedTable().withInput(TBook().getName()).withOutput(VBook().getName()))));
q=create(settings).select(TBook_TITLE()).from(TAuthor()).join(TBook()).on(TAuthor_ID().equal(TBook_AUTHOR_ID())).orderBy(TBook_ID().asc());
assertTrue(create(settings).render(q).contains(VAuthor().getName()));
assertTrue(create(settings).render(q).contains(VBook().getName()));
assertTrue(create(settings).render(q).contains("String_Node_Str"));
assertFalse(create(settings).render(q).contains(TAuthor().getName()));
assertFalse(create(settings).render(q).contains(TBook().getName()));
result=q.fetch();
assertEquals("String_Node_Str",result.getValue(0,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(1,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(2,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(3,TBook_TITLE()));
}

Fixed version (ground truth):
@Test public void testSchemaMapping() throws Exception {
switch (getDialect()) {
case SQLITE:
    log.info("String_Node_Str","String_Node_Str");
  return;
}
Settings settings=new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput(TAuthor().getSchema().getName()).withOutput(TAuthor().getSchema().getName()).withTables(new MappedTable().withInput(TAuthor().getName()).withOutput(TAuthor().getName()),new MappedTable().withInput(TBook().getName()).withOutput(TBook().getName()))));
Select<Record> query=create(settings).select(TBook_TITLE()).from(TAuthor()).join(TBook()).on(TAuthor_ID().equal(TBook_AUTHOR_ID())).orderBy(TBook_ID().asc());
Result<Record> result=query.fetch();
assertEquals("String_Node_Str",result.getValue(0,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(1,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(2,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(3,TBook_TITLE()));
String sql=query.getSQL();
log.info("String_Node_Str",sql);
assertEquals(result,create().fetch(sql,query.getBindValues().toArray()));
switch (getDialect()) {
case ASE:
case CUBRID:
case DB2:
case DERBY:
case H2:
case HSQLDB:
case INGRES:
case ORACLE:
case POSTGRES:
case SQLITE:
case SQLSERVER:
case SYBASE:
log.info("String_Node_Str","String_Node_Str");
return;
case MYSQL:
if (delegate.getClass() == jOOQMySQLTestSchemaRewrite.class) {
log.info("String_Node_Str","String_Node_Str");
return;
}
}
settings=new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput(TAuthor().getSchema().getName()).withOutput(TAuthor().getSchema().getName() + "String_Node_Str")));
Select<Record> q=create(settings).select(TBook_TITLE()).from(TAuthor()).join(TBook()).on(TAuthor_ID().equal(TBook_AUTHOR_ID())).orderBy(TBook_ID().asc());
assertTrue(create(settings).render(q).contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertTrue(q.getSQL().contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertEquals(create(settings).render(q),q.getSQL());
result=q.fetch();
assertEquals("String_Node_Str",result.getValue(0,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(1,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(2,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(3,TBook_TITLE()));
Field<Integer> f1=FOneField().cast(Integer.class);
Field<Integer> f2=FNumberField(42).cast(Integer.class);
q=create(settings).select(f1,f2);
assertTrue(create(settings).render(q).contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertTrue(q.getSQL().contains(TAuthor().getSchema().getName() + "String_Node_Str"));
assertEquals(create(settings).render(q),q.getSQL());
Record record=q.fetchOne();
assertEquals(1,(int)record.getValue(f1));
assertEquals(42,(int)record.getValue(f2));
settings=new Settings().withRenderMapping(new RenderMapping().withSchemata(new MappedSchema().withInput(TAuthor().getSchema().getName()).withOutput(TAuthor().getSchema().getName() + "String_Node_Str").withTables(new MappedTable().withInput(TAuthor().getName()).withOutput(VAuthor().getName()),new MappedTable().withInput(TBook().getName()).withOutput(VBook().getName()))));
q=create(settings).select(TBook_TITLE()).from(TAuthor()).join(TBook()).on(TAuthor_ID().equal(TBook_AUTHOR_ID())).orderBy(TBook_ID().asc());
assertTrue(create(settings).render(q).contains(VAuthor().getName()));
assertTrue(create(settings).render(q).contains(VBook().getName()));
assertTrue(create(settings).render(q).contains("String_Node_Str"));
assertFalse(create(settings).render(q).contains(TAuthor().getName()));
assertFalse(create(settings).render(q).contains(TBook().getName()));
result=q.fetch();
assertEquals("String_Node_Str",result.getValue(0,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(1,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(2,TBook_TITLE()));
assertEquals("String_Node_Str",result.getValue(3,TBook_TITLE()));
}