mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#611 - findRowCount ignores @SoftDelete, does not add predicate
This commit is contained in:
@@ -234,6 +234,10 @@ public class CQueryBuilder {
|
||||
predicates.prepare(true);
|
||||
|
||||
SqlTree sqlTree = createSqlTree(request, predicates, getHistorySupport(query), getDraftSupport(query));
|
||||
if (SpiQuery.TemporalMode.CURRENT == query.getTemporalMode()) {
|
||||
sqlTree.addSoftDeletePredicate(query);
|
||||
}
|
||||
|
||||
SqlLimitResponse s = buildSql(sqlSelect, request, predicates, sqlTree);
|
||||
String sql = s.getSql();
|
||||
if (hasMany || query.isRawSql()) {
|
||||
|
||||
@@ -600,10 +600,7 @@ public class DefaultOrmQuery<T> implements SpiQuery<T> {
|
||||
if (detail != null) {
|
||||
copy.detail = detail.copy();
|
||||
}
|
||||
if (temporalMode == TemporalMode.DRAFT) {
|
||||
copy.temporalMode = TemporalMode.DRAFT;
|
||||
}
|
||||
|
||||
copy.temporalMode = temporalMode;
|
||||
copy.firstRow = firstRow;
|
||||
copy.maxRows = maxRows;
|
||||
copy.rawWhereClause = rawWhereClause;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user