[#2870] Added failing integration test
This commit is contained in:
parent
04b8343b12
commit
46feeb8da7
@ -495,6 +495,28 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
assertEquals(result4, result5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinOnKeyWithAlias() throws Exception {
|
||||
|
||||
// Test using unambiguous keys
|
||||
// ---------------------------
|
||||
Table<B> b = TBook().as("b");
|
||||
Table<S> bs = TBookStore().as("bs");
|
||||
Result<Record2<Integer, String>> result4 =
|
||||
create().select(b.field(TBook_ID()), bs.field(TBookStore_NAME()))
|
||||
.from(b)
|
||||
.join(TBookToBookStore()).onKey()
|
||||
.join(bs).onKey()
|
||||
.orderBy(b.field(TBook_ID()), bs.field(TBookStore_NAME()))
|
||||
.fetch();
|
||||
|
||||
assertEquals(6, result4.size());
|
||||
assertEquals(asList(1, 1, 2, 3, 3, 3), result4.getValues(0));
|
||||
assertEquals(asList(
|
||||
"Ex Libris", "Orell Füssli", "Orell Füssli",
|
||||
"Buchhandlung im Volkshaus", "Ex Libris", "Orell Füssli"), result4.getValues(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInverseAndNestedJoin() throws Exception {
|
||||
|
||||
|
||||
@ -1956,6 +1956,11 @@ public abstract class jOOQAbstractTest<
|
||||
new JoinTests(this).testJoinOnKey();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinOnKeyWithAlias() throws Exception {
|
||||
new JoinTests(this).testJoinOnKeyWithAlias();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInverseAndNestedJoin() throws Exception {
|
||||
new JoinTests(this).testInverseAndNestedJoin();
|
||||
|
||||
@ -477,7 +477,7 @@ class JoinTable extends AbstractTable<Record> implements TableOptionalOnStep, Ta
|
||||
throw onKeyException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public final JoinTable onKey(ForeignKey<?, ?> key) {
|
||||
JoinTable result = this;
|
||||
@ -486,7 +486,11 @@ class JoinTable extends AbstractTable<Record> implements TableOptionalOnStep, Ta
|
||||
TableField<?, ?>[] referenced = key.getKey().getFieldsArray();
|
||||
|
||||
for (int i = 0; i < references.length; i++) {
|
||||
result.and(((Field<Void>) references[i]).equal((Field<Void>) referenced[i]));
|
||||
Field f1 = references[i];
|
||||
Field f2 = referenced[i];
|
||||
|
||||
// [#2870] TODO: If lhs or rhs are aliased tables, extract the appropriate fields from them
|
||||
result.and(f1.equal(f2));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user