mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix/select distinct cascaded fetch (#1015)
Fix/select distinct cascaded fetch with findSingleAttributeList() on associated property path
This commit is contained in:
committed by
Rob Bygrave
parent
e51f7f11f1
commit
f9c70d2a2b
@@ -3,6 +3,8 @@ package org.tests.query.other;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
|
||||
import org.tests.model.basic.Contact;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.ResetBasicData;
|
||||
import org.avaje.test.model.rawsql.inherit.ChildA;
|
||||
@@ -162,6 +164,20 @@ public class TestQuerySingleAttribute extends BaseTestCase {
|
||||
assertThat(cities).contains("Auckland").containsNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void distinctWithCascadedFetch() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Contact> query = Ebean.find(Contact.class)
|
||||
.setDistinct(true)
|
||||
.fetch("customer.billingAddress","city");
|
||||
|
||||
List<String> cities = query.findSingleAttributeList();
|
||||
|
||||
assertThat(sqlOf(query)).contains("select distinct t2.city from contact t0 join o_customer t1 on t1.id = t0.customer_id left join o_address t2 on t2.id = t1.billing_address_id");
|
||||
assertThat(cities).contains("Auckland").containsNull();
|
||||
}
|
||||
@Test
|
||||
public void distinctSelectOnInheritedBean() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user