[#1801] Add Table.as(String, String...) to allow for creating a table

aliases (correlation names) with derived column lists - Add test case
for renaming JOIN expressions
This commit is contained in:
Lukas Eder 2013-01-02 18:09:45 +01:00
parent 1999c73065
commit d60432d463
2 changed files with 25 additions and 0 deletions

View File

@ -39,6 +39,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.jooq.impl.Factory.select;
import static org.jooq.impl.Factory.selectOne;
import static org.jooq.impl.Factory.selectZero;
import static org.jooq.impl.Factory.table;
import static org.jooq.impl.Factory.two;
import static org.jooq.impl.Factory.zero;
@ -168,4 +169,23 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, I, IPK, T725,
assertNull(r2.getValue(3));
assertNull(r2.getValue("v3"));
}
@Test
public void testAliasingJoins() throws Exception {
Record r1 = create()
.select()
.from(table(selectOne())
.crossJoin(table(selectZero())).as("t", "a", "b"))
.fetchOne();
assertEquals("a", r1.getField(0).getName());
assertEquals("b", r1.getField(1).getName());
assertEquals("a", r1.getField("a").getName());
assertEquals("b", r1.getField("b").getName());
assertEquals(1, r1.getValue(0));
assertEquals(0, r1.getValue(1));
assertEquals(1, r1.getValue("a"));
assertEquals(0, r1.getValue("b"));
}
}

View File

@ -1554,6 +1554,11 @@ public abstract class jOOQAbstractTest<
new AliasTests(this).testAliasingSelectAndFields();
}
@Test
public void testAliasingJoins() throws Exception {
new AliasTests(this).testAliasingJoins();
}
// @Test // TODO [#579] re-enable this test when fixing this bug
public void testUnaliasedSubqueryProjections() throws Exception {
new SelectTests(this).testUnaliasedSubqueryProjections();