mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1170 - ENH: Add isIn() methods as alias to in() on ExpressionList (for use with Kotlin where in is a keyword)
This commit is contained in:
@@ -24,6 +24,17 @@ public class TestInEmpty extends BaseTestCase {
|
||||
assertEquals(0, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_isIn_empty() {
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class).where().isIn("id", new Object[0]).gt("id", 0)
|
||||
.query();
|
||||
|
||||
List<Order> list = query.findList();
|
||||
assertThat(query.getGeneratedSql()).contains("1=0");
|
||||
assertEquals(0, list.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_notIn_empty() {
|
||||
|
||||
|
||||
@@ -30,6 +30,24 @@ public class TestQueryInAssocOne extends BaseTestCase {
|
||||
assertThat(sql).contains("t0.kcustomer_id in (?");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_isIn() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Customer> list = Ebean.find(Customer.class).where().lt("id", 300).findList();
|
||||
|
||||
Query<Order> query = Ebean.find(Order.class).where().isIn("customer", list).query();
|
||||
|
||||
query.findList();
|
||||
String sql = query.getGeneratedSql();
|
||||
|
||||
assertThat(sql).contains("join o_customer t1 on t1.id = t0.kcustomer_id");
|
||||
assertThat(sql).contains("t0.kcustomer_id in (?");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_notIn() {
|
||||
|
||||
|
||||
@@ -31,6 +31,20 @@ public class TestSubQuery extends BaseTestCase {
|
||||
Ebean.find(Order.class).where().in("id", sq).findList();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_IsIn() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
List<Integer> productIds = new ArrayList<>();
|
||||
productIds.add(3);
|
||||
|
||||
Query<Order> sq = Ebean.createQuery(Order.class).select("id").where()
|
||||
.isIn("details.product.id", productIds).query();
|
||||
|
||||
Ebean.find(Order.class).where().isIn("id", sq).findList();
|
||||
}
|
||||
|
||||
public void testCompositeKey() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user