mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1696 - Refactor - trim unnecessary whitespace around IN clause bind parameters
This commit is contained in:
+3
-3
@@ -76,7 +76,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
List<String> sql = LoggedSqlCollector.current();
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
assertThat(sql.get(0)).contains("from o_cached_bean t0 where t0.id in (?, ?, ? )");
|
||||
assertThat(sql.get(0)).contains("from o_cached_bean t0 where t0.id in (?,?,?)");
|
||||
}
|
||||
|
||||
log.info("All hits (3 of 3) ...");
|
||||
@@ -105,7 +105,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
// fetch the miss from DB
|
||||
assertThat(sql.get(0)).contains("from o_cached_bean t0 where t0.id in (? )");
|
||||
assertThat(sql.get(0)).contains("from o_cached_bean t0 where t0.id in (?)");
|
||||
}
|
||||
|
||||
// remove beans so that we get a "partial" hit (1 out of 3 in cache)
|
||||
@@ -124,7 +124,7 @@ public class TestBeanCache extends BaseTestCase {
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
// fetch the misses from DB
|
||||
assertThat(sql.get(0)).contains("from o_cached_bean t0 where t0.id in (?, ? )");
|
||||
assertThat(sql.get(0)).contains("from o_cached_bean t0 where t0.id in (?,?)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ public class TestMergeCustomer extends BaseTestCase {
|
||||
assertThat(sql.get(0)).contains("select t0.id, t3.id, t1.id, t2.id from mcustomer t0 left join maddress t3 on t3.id = t0.shipping_address_id left join maddress t1 on t1.id = t0.billing_address_id left join mcontact t2 on t2.customer_id = t0.id where t0.id = ?");
|
||||
if (isH2() || isHana()) {
|
||||
// with nested OneToMany .. we need a second query to read the contact message ids
|
||||
assertThat(sql.get(1)).contains("select t0.contact_id, t0.id from mcontact_message t0 where (t0.contact_id) in (?, ?, ?, ?, ?, ?, ?, ?, ?, ? )");
|
||||
assertThat(sql.get(1)).contains("select t0.contact_id, t0.id from mcontact_message t0 where (t0.contact_id) in (?,?,?,?,?,?,?,?,?,?)");
|
||||
}
|
||||
assertThat(sql.get(2)).contains("delete from mcontact_message where contact_id = ?");
|
||||
assertThat(sql.get(3)).contains("delete from mcontact where id=?");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TestAggregationMany extends BaseTestCase {
|
||||
|
||||
assertThat(machines).hasSize(5);
|
||||
if (isH2()) {
|
||||
assertThat(sql.get(1)).contains("select t0.machine_id, t0.name, sum(t0.use_secs), sum(t0.fuel) from d_machine_aux_use t0 where (t0.machine_id) in (?, ?, ?, ?, ? ) group by t0.machine_id, t0.name;");
|
||||
assertThat(sql.get(1)).contains("select t0.machine_id, t0.name, sum(t0.use_secs), sum(t0.fuel) from d_machine_aux_use t0 where (t0.machine_id) in (?,?,?,?,?) group by t0.machine_id, t0.name;");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -110,7 +110,7 @@ public class TestCacheViaComplexNaturalKey extends BaseTestCase {
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
// in clause with only 1 bind param - (sku=3 ... we got hits on sku 1 and 2)
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey t0 where t0.store = ? and t0.sku in (? ) order by t0.sku desc; --bind(abc,Array[1]={3})");
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey t0 where t0.store = ? and t0.sku in (?) order by t0.sku desc; --bind(abc,Array[1]={3})");
|
||||
}
|
||||
|
||||
assertThat(list).hasSize(3);
|
||||
@@ -149,7 +149,7 @@ public class TestCacheViaComplexNaturalKey extends BaseTestCase {
|
||||
assertThat(list).hasSize(3);
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
assertThat(sql.get(0)).contains("where t0.store = ? and t0.sku in (?, ? ) order by t0.sku desc; --bind(abc,Array[2]={1,3})");
|
||||
assertThat(sql.get(0)).contains("where t0.store = ? and t0.sku in (?,?) order by t0.sku desc; --bind(abc,Array[2]={1,3})");
|
||||
}
|
||||
assertNaturalKeyHitMiss(1, 2);
|
||||
assertBeanCacheHitMiss(1, 0);
|
||||
@@ -207,7 +207,7 @@ public class TestCacheViaComplexNaturalKey extends BaseTestCase {
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
// in clause with 2 bind params as we got not hits on the cache
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey t0 where t0.store = ? and t0.sku in (?, ? ) order by t0.sku desc; --bind(abc,Array[2]={3,4})");
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey t0 where t0.store = ? and t0.sku in (?,?) order by t0.sku desc; --bind(abc,Array[2]={3,4})");
|
||||
}
|
||||
|
||||
assertThat(list).hasSize(2);
|
||||
|
||||
+4
-4
@@ -116,7 +116,7 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
// in clause with only 1 bind param - (sku=3 ... we got hits on sku 1 and 2)
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and t0.code in (? ) and t0.sku = ? order by t0.sku desc, t0.code; --bind(def,Array[1]={1000},2)");
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and t0.code in (?) and t0.sku = ? order by t0.sku desc, t0.code; --bind(def,Array[1]={1000},2)");
|
||||
}
|
||||
|
||||
assertThat(list).hasSize(4);
|
||||
@@ -178,7 +178,7 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isH2()) {
|
||||
// in clause with 2 bind params as we got not hits on the cache
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and t0.sku in (?, ?, ? ) and t0.code = ? order by t0.sku desc; --bind(abc,Array[3]={3,2,4},1001)");
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and t0.sku in (?,?,?) and t0.code = ? order by t0.sku desc; --bind(abc,Array[3]={3,2,4},1001)");
|
||||
}
|
||||
|
||||
assertThat(list).hasSize(2);
|
||||
@@ -278,7 +278,7 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
assertBeanCacheHitMiss(1, 0);
|
||||
|
||||
if (isH2()) {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,'-',t0.code) in (?, ? ) order by t0.sku desc; --bind(def,Array[2]={2-1000,3-1000})");
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,'-',t0.code) in (?,?) order by t0.sku desc; --bind(def,Array[2]={2-1000,3-1000})");
|
||||
} else if (isPostgres()) {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and (t0.sku||'-'||t0.code)");
|
||||
} else if (isHana()) {
|
||||
@@ -321,7 +321,7 @@ public class TestCacheViaComplexNaturalKey3 extends BaseTestCase {
|
||||
assertBeanCacheHitMiss(1, 0);
|
||||
|
||||
if (isH2()) {
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,':',t0.code,'-foo') in (?, ? ) order by t0.sku desc; --bind(def,Array[2]={2:1000-foo,3:1000-foo})");
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and concat(t0.sku,':',t0.code,'-foo') in (?,?) order by t0.sku desc; --bind(def,Array[2]={2:1000-foo,3:1000-foo})");
|
||||
} else if (isPostgres()){
|
||||
assertThat(sql.get(0)).contains("from o_cached_natkey3 t0 where t0.store = ? and (t0.sku||':'||t0.code||'-foo')");
|
||||
} else if (isHana()){
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TestHistoryOneToMany extends BaseTestCase {
|
||||
if (isH2()) {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("from hi_tone_with_history t0 where (t0.sys_period_start <= ? and (t0.sys_period_end is null or t0.sys_period_end > ?)) and lower(t0.name) like ? escape'' limit 10");
|
||||
assertThat(sql.get(1)).contains("from hi_ttwo_with_history t0 left join hi_tthree_with_history t1 on t1.hi_ttwo_id = t0.id and (t1.sys_period_start <= ? and (t1.sys_period_end is null or t1.sys_period_end > ?)) where (t0.sys_period_start <= ? and (t0.sys_period_end is null or t0.sys_period_end > ?)) and (t0.hi_tone_id) in (? )");
|
||||
assertThat(sql.get(1)).contains("from hi_ttwo_with_history t0 left join hi_tthree_with_history t1 on t1.hi_ttwo_id = t0.id and (t1.sys_period_start <= ? and (t1.sys_period_end is null or t1.sys_period_end > ?)) where (t0.sys_period_start <= ? and (t0.sys_period_end is null or t0.sys_period_end > ?)) and (t0.hi_tone_id) in (?)");
|
||||
}
|
||||
|
||||
assertThat(list).hasSize(1);
|
||||
|
||||
Reference in New Issue
Block a user