mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - reformat code whitespace etc
This commit is contained in:
@@ -10,26 +10,29 @@ import com.avaje.tests.model.basic.CKeyParent;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
public class TestQueryAlias extends BaseTestCase {
|
||||
@Test
|
||||
public void testExists() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<CKeyParent> sq = Ebean.createQuery(CKeyParent.class).select("id.oneKey").alias("st0")
|
||||
.setAutofetch(false).where().query();
|
||||
@Test
|
||||
public void testExists() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<CKeyParent> pq = Ebean.find(CKeyParent.class).alias("myt0").where().in("id.oneKey", sq).query();
|
||||
Query<CKeyParent> sq = Ebean.createQuery(CKeyParent.class)
|
||||
.select("id.oneKey").alias("st0")
|
||||
.setAutofetch(false).where().query();
|
||||
|
||||
pq.findList();
|
||||
Query<CKeyParent> pq = Ebean.find(CKeyParent.class).alias("myt0").where().in("id.oneKey", sq).query();
|
||||
|
||||
String sql = pq.getGeneratedSql();
|
||||
|
||||
System.out.println(sql);
|
||||
// Without alias command is should be:
|
||||
// select t0.one_key c0, t0.two_key c1, t0.name c2, t0.version c3, t0.assoc_id c4 from ckey_parent t0 where (t0.one_key) in (select t0.one_key from ckey_parent t0)
|
||||
// but with alias command SQL should look like this:
|
||||
// select myt0.one_key c0, myt0.two_key c1, myt0.name c2, myt0.version c3, myt0.assoc_id c4 from ckey_parent myt0 where (myt0.one_key) in (select st0.one_key from ckey_parent st0)
|
||||
|
||||
Assert.assertTrue(sql.indexOf("ckey_parent myt0")>0);
|
||||
Assert.assertTrue(sql.indexOf("in (select st0.one_key from ckey_parent st0)")>0);
|
||||
}
|
||||
pq.findList();
|
||||
|
||||
String sql = pq.getGeneratedSql();
|
||||
|
||||
System.out.println(sql);
|
||||
// Without alias command is should be:
|
||||
// select t0.one_key c0, t0.two_key c1, t0.name c2, t0.version c3, t0.assoc_id c4 from ckey_parent t0 where (t0
|
||||
// .one_key) in (select t0.one_key from ckey_parent t0)
|
||||
// but with alias command SQL should look like this:
|
||||
// select myt0.one_key c0, myt0.two_key c1, myt0.name c2, myt0.version c3, myt0.assoc_id c4 from ckey_parent myt0
|
||||
// where (myt0.one_key) in (select st0.one_key from ckey_parent st0)
|
||||
|
||||
Assert.assertTrue(sql.indexOf("ckey_parent myt0") > 0);
|
||||
Assert.assertTrue(sql.indexOf("in (select st0.one_key from ckey_parent st0)") > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,31 +11,31 @@ import com.avaje.tests.model.basic.Order;
|
||||
import com.avaje.tests.model.basic.ResetBasicData;
|
||||
|
||||
public class TestQueryExists extends BaseTestCase {
|
||||
@Test
|
||||
public void testExists() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Query<Order> subQuery=Ebean.find(Order.class).alias("sq").select("id").where().raw("sq.kcustomer_id = qt.id")
|
||||
.query();
|
||||
Query<Customer> query=Ebean.find(Customer.class).alias("qt").where().exists(subQuery).query();
|
||||
@Test
|
||||
public void testExists() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
query.findList();
|
||||
String sql=query.getGeneratedSql();
|
||||
Query<Order> subQuery = Ebean.find(Order.class).alias("sq").select("id").where().raw("sq.kcustomer_id = qt.id").query();
|
||||
|
||||
Assert.assertTrue(sql.indexOf("exists (")>0);
|
||||
}
|
||||
Query<Customer> query = Ebean.find(Customer.class).alias("qt").where().exists(subQuery).query();
|
||||
|
||||
@Test
|
||||
public void testNotExists() {
|
||||
ResetBasicData.reset();
|
||||
query.findList();
|
||||
String sql = query.getGeneratedSql();
|
||||
|
||||
Query<Order> subQuery=Ebean.find(Order.class).alias("sq").select("id").where().raw("sq.kcustomer_id = qt.id")
|
||||
.query();
|
||||
Query<Customer> query=Ebean.find(Customer.class).alias("qt").where().notExists(subQuery).query();
|
||||
Assert.assertTrue(sql.indexOf("exists (") > 0);
|
||||
}
|
||||
|
||||
query.findList();
|
||||
String sql=query.getGeneratedSql();
|
||||
@Test
|
||||
public void testNotExists() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Assert.assertTrue(sql.indexOf("not exists (")>0);
|
||||
}
|
||||
Query<Order> subQuery = Ebean.find(Order.class).alias("sq").select("id").where().raw("sq.kcustomer_id = qt.id").query();
|
||||
Query<Customer> query = Ebean.find(Customer.class).alias("qt").where().notExists(subQuery).query();
|
||||
|
||||
query.findList();
|
||||
String sql = query.getGeneratedSql();
|
||||
|
||||
Assert.assertTrue(sql.indexOf("not exists (") > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user