mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix for #172 - Regression: @Where predicates not applied in eager fetch (but are on lazy load)
This commit is contained in:
@@ -103,7 +103,7 @@ public class TestSecondaryQueries extends BaseTestCase {
|
||||
// from o_order_detail t0
|
||||
// where (t0.order_id) in (?,?,?,?,?) ; --bind(1,4,1,1,1)
|
||||
|
||||
Assert.assertTrue(ordSecondarySql.contains(" from o_order_detail t0 where (t0.order_id) in (?"));
|
||||
Assert.assertTrue(ordSecondarySql.contains(" from o_order_detail t0 where t0.id > 0 and (t0.order_id) in (?"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TestQueryFetchManyTwoDeep extends BaseTestCase {
|
||||
|
||||
SpiQuery<?> secondaryQuery = secondaryQueries.get(0);
|
||||
String secondarySql = secondaryQuery.getGeneratedSql();
|
||||
Assert.assertTrue(secondarySql.contains("from o_order_detail t0 where (t0.order_id) in"));
|
||||
Assert.assertTrue(secondarySql.contains("from o_order_detail t0 where t0.id > 0 and (t0.order_id) in"));
|
||||
|
||||
// select t0.order_id c0, t0.id c1, t0.order_qty c2, t0.ship_qty c3, t0.unit_price c4, t0.cretime c5, t0.updtime c6, t0.order_id c7, t0.product_id c8
|
||||
// from o_order_detail t0
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.avaje.tests.query.other;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.avaje.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
public class TestWhereAnnotation extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void fetchEager_inFirstQuery(){
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
Ebean.find(Customer.class)
|
||||
.fetch("orders")
|
||||
.findList();
|
||||
|
||||
List<String> loggedSql = LoggedSqlCollector.stop();
|
||||
|
||||
Assert.assertEquals(1, loggedSql.size());
|
||||
|
||||
String sql = loggedSql.get(0);
|
||||
Assert.assertTrue(sql.contains("t1.order_date is not null"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fetchLazy_inLazyLoadQuery(){
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
List<Customer> customers = Ebean.find(Customer.class).findList();
|
||||
|
||||
List<Order> orders = customers.get(0).getOrders();
|
||||
orders.size();
|
||||
|
||||
List<String> loggedSql = LoggedSqlCollector.stop();
|
||||
|
||||
Assert.assertEquals(2, loggedSql.size());
|
||||
|
||||
String sql = loggedSql.get(1);
|
||||
Assert.assertTrue(sql.contains("t0.order_date is not null"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user