mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
FIX: subquery could not not have a where clause
This commit is contained in:
@@ -4,7 +4,6 @@ import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
import io.ebeantest.LoggedSql;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.Order;
|
||||
@@ -111,4 +110,17 @@ public class TestQueryExists extends BaseTestCase {
|
||||
|
||||
assertThat(sql).contains("not exists (");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistsNoWhere() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Order> subQuery = Ebean.find(Order.class).alias("sq").select("id");
|
||||
Query<Customer> query = Ebean.find(Customer.class).alias("qt").where().notExists(subQuery).query();
|
||||
|
||||
query.findList();
|
||||
String sql = query.getGeneratedSql();
|
||||
|
||||
assertThat(sql).contains("not exists (select sq.id from o_order sq)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,17 @@ public class TestSubQuery extends BaseTestCase {
|
||||
Query<Order> sq = DB.createQuery(Order.class).select("id").where()
|
||||
.isIn("details.product.id", productIds).query();
|
||||
|
||||
DB.find(Order.class).where().isIn("id", sq).findList();
|
||||
assertThat(DB.find(Order.class).where().isIn("id", sq).findList()).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_IsInNoWhere() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Order> sq = DB.createQuery(Order.class).select("id");
|
||||
int expectedSize = DB.find(Order.class).findCount(); // expect everything
|
||||
|
||||
assertThat(DB.find(Order.class).where().isIn("id", sq).findList()).hasSize(expectedSize);
|
||||
}
|
||||
|
||||
public void testCompositeKey() {
|
||||
|
||||
Reference in New Issue
Block a user