mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Bug findsingleattributelist o2m orderby
This commit is contained in:
@@ -756,6 +756,31 @@ public class TestQuerySingleAttribute extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oneToMany_orderBy() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Customer> query = DB.find(Customer.class)
|
||||
.fetch("orders", "status")
|
||||
.orderBy("orders.status");
|
||||
|
||||
List<Order.Status> statusList = query.findSingleAttributeList();
|
||||
|
||||
assertSql(query)
|
||||
.contains("select t1.status from o_customer t0 "
|
||||
+ "left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null order by t1.status")
|
||||
.doesNotContain("order by t0.id");
|
||||
// query was: select t1.status from o_customer t0
|
||||
// left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null
|
||||
// order by t0.id, t1.status
|
||||
// -> why order by t0.id?
|
||||
// Results in wrong order:
|
||||
assertThat(statusList).hasSize(7);
|
||||
assertThat(statusList.get(0)).isEqualTo(null);
|
||||
assertThat(statusList.get(6)).isEqualTo(Order.Status.COMPLETE);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
MainEntity e1 = new MainEntity();
|
||||
|
||||
Reference in New Issue
Block a user