[#3156] "Column ambiguously defined" when emulating derived column lists with duplicate column names
This commit is contained in:
parent
eca996a5ca
commit
c47e9e95bc
@ -40,6 +40,7 @@
|
||||
*/
|
||||
package org.jooq.test._.testcases;
|
||||
|
||||
import static org.jooq.impl.DSL.fieldByName;
|
||||
import static org.jooq.impl.DSL.one;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
@ -111,6 +112,27 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
assertEquals(BOOK_IDS, books.getValues(b_ID));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDerivedColumnListsWithAmbiguousColumnNames() throws Exception {
|
||||
|
||||
// [#3156] If derived column lists are emulated on derived tables that contain
|
||||
// ambiguous column names, jOOQ must make sure that this ambiguity doesn't cause any issues
|
||||
Result<Record> result =
|
||||
create().select()
|
||||
.from(
|
||||
table(
|
||||
select(TBook_ID(), TAuthor_ID())
|
||||
.from(TBook())
|
||||
.join(TAuthor()).on(TBook_AUTHOR_ID().eq(TAuthor_ID()))
|
||||
).as("t", "a", "b"))
|
||||
.orderBy(fieldByName("a"))
|
||||
.fetch();
|
||||
|
||||
assertEquals(4, result.size());
|
||||
assertEquals(BOOK_IDS, result.getValues("a"));
|
||||
assertEquals(BOOK_AUTHOR_IDS, result.getValues("b"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testAliasingTablesAndFields() throws Exception {
|
||||
|
||||
@ -2086,6 +2086,11 @@ public abstract class jOOQAbstractTest<
|
||||
new AliasTests(this).testAliasingSimple();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDerivedColumnListsWithAmbiguousColumnNames() throws Exception {
|
||||
new AliasTests(this).testDerivedColumnListsWithAmbiguousColumnNames();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliasingTablesAndFields() throws Exception {
|
||||
new AliasTests(this).testAliasingTablesAndFields();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user