#611 - findRowCount ignores @SoftDelete, does not add predicate

This commit is contained in:
Robin Bygrave
2016-03-22 10:35:20 +13:00
parent 5d3d73aac8
commit e57ce7a6c4
3 changed files with 30 additions and 5 deletions
@@ -44,13 +44,37 @@ public class TestSoftDeleteBasic extends BaseTestCase {
}
@Test
public void testDeleteById() {
public void testDeleteById_and_findRowCount() {
EBasicSoftDelete bean = new EBasicSoftDelete();
bean.setName("two");
Ebean.save(bean);
int rowCountBefore = Ebean.find(EBasicSoftDelete.class).findRowCount();
Ebean.delete(EBasicSoftDelete.class, bean.getId());
// -- test .findRowCount()
LoggedSqlCollector.start();
int rowCountAfter = Ebean.find(EBasicSoftDelete.class).findRowCount();
List<String> loggedSql = LoggedSqlCollector.stop();
assertThat(loggedSql).hasSize(1);
assertThat(loggedSql.get(0)).contains("where coalesce(t0.deleted,false)=false");
assertThat(rowCountAfter).isEqualTo(rowCountBefore - 1);
// -- test includeSoftDeletes().findRowCount()
LoggedSqlCollector.start();
int rowCountFull = Ebean.find(EBasicSoftDelete.class).includeSoftDeletes().findRowCount();
assertThat(rowCountFull).isGreaterThan(rowCountAfter);
loggedSql = LoggedSqlCollector.stop();
assertThat(loggedSql).hasSize(1);
assertThat(loggedSql.get(0)).doesNotContain("where coalesce(t0.deleted,false)=false");
}
@Test