mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-03 00:23:24 +00:00
#895 - Refactor: Remove unnecessary coalesce on soft delete (as predicate on left join etc)
This commit is contained in:
1 parent
d0e9c6a218
commit
063c1825ca
3 files changed
+14
-15
No files matched your search
@@ -43,16 +43,16 @@ public class TestSoftDeletePagingList extends BaseTestCase {
|
||||
assertThat(sql).hasSize(2);
|
||||
assertThat(sql.get(0)).contains("select count(*) from cover t0 where t0.s3url like");
|
||||
if (isPlatformBooleanNative()) {
|
||||
assertThat(sql.get(0)).contains("and coalesce(t0.deleted,false)=false; --bind(SoftDelPaged-%)");
|
||||
assertThat(sql.get(0)).contains("and t0.deleted = false; --bind(SoftDelPaged-%)");
|
||||
} else {
|
||||
assertThat(sql.get(0)).contains("and coalesce(t0.deleted,0)=0; --bind(SoftDelPaged-%)");
|
||||
assertThat(sql.get(0)).contains("and t0.deleted = 0; --bind(SoftDelPaged-%)");
|
||||
}
|
||||
|
||||
assertThat(sql.get(1)).contains("where t0.s3url like ");
|
||||
if (isPlatformBooleanNative()) {
|
||||
assertThat(sql.get(1)).contains("and coalesce(t0.deleted,false)=false order by t0.id");
|
||||
assertThat(sql.get(1)).contains("and t0.deleted = false order by t0.id");
|
||||
} else {
|
||||
assertThat(sql.get(1)).contains("and coalesce(t0.deleted,0)=0 order by t0.id");
|
||||
assertThat(sql.get(1)).contains("and t0.deleted = 0 order by t0.id");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,8 +84,7 @@ public class TestSoftDeleteBasic extends BaseTestCase {
|
||||
|
||||
List<String> loggedSql = LoggedSqlCollector.stop();
|
||||
assertThat(loggedSql).hasSize(1);
|
||||
// usually where coalesce(t0.deleted,false)=false but false is 0 for Oracle etc
|
||||
assertThat(loggedSql.get(0)).contains("where coalesce(t0.deleted,");
|
||||
assertThat(loggedSql.get(0)).contains("where t0.deleted =");
|
||||
|
||||
assertThat(rowCountAfter).isEqualTo(rowCountBefore - 1);
|
||||
|
||||
@@ -182,8 +181,8 @@ public class TestSoftDeleteBasic extends BaseTestCase {
|
||||
String generatedSql = query1.getGeneratedSql();
|
||||
|
||||
// first statement is a single bulk update of the children with SoftDelete
|
||||
assertThat(generatedSql).contains("coalesce(t0.deleted,");
|
||||
assertThat(generatedSql).contains("coalesce(t1.deleted,");
|
||||
assertThat(generatedSql).contains("t0.deleted = ");
|
||||
assertThat(generatedSql).contains("t1.deleted = ");
|
||||
assertThat(fetch1.get(0).getChildren()).hasSize(2);
|
||||
|
||||
assertThat(fetch1.get(0).getNosdChildren()).hasSize(2);
|
||||
@@ -224,13 +223,14 @@ public class TestSoftDeleteBasic extends BaseTestCase {
|
||||
String generatedSql = sqlOf(query);
|
||||
|
||||
if (isPlatformBooleanNative()) {
|
||||
assertThat(generatedSql).contains("left join ebasic_sdchild t1 on t1.owner_id = t0.id and coalesce(t1.deleted,false)=false");
|
||||
assertThat(generatedSql).contains("coalesce(t0.deleted,false)=false");
|
||||
assertThat(generatedSql).contains("left join ebasic_sdchild t1 on t1.owner_id = t0.id and t1.deleted = false");
|
||||
assertThat(generatedSql).contains("t0.deleted = false");
|
||||
} else {
|
||||
assertThat(generatedSql).contains("left join ebasic_sdchild t1 on t1.owner_id = t0.id and coalesce(t1.deleted,0)=0");
|
||||
assertThat(generatedSql).contains("coalesce(t0.deleted,0)=0");
|
||||
assertThat(generatedSql).contains("left join ebasic_sdchild t1 on t1.owner_id = t0.id and t1.deleted = 0");
|
||||
assertThat(generatedSql).contains("t0.deleted = 0");
|
||||
}
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getChildren()).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user