Skip to content

Commit fa61dbb

Browse files
Query: throw if filter is used with remove().
1 parent a0839bc commit fa61dbb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

objectbox-java/src/main/java/io/objectbox/query/Query.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ public Query<T> setParameter(String alias, byte[] value) {
601601
* @return count of removed Objects
602602
*/
603603
public long remove() {
604+
ensureNoFilter();
604605
return box.internalCallWithWriterHandle(new CallWithHandle<Long>() {
605606
@Override
606607
public Long call(long cursorHandle) {

tests/objectbox-java-test/src/test/java/io/objectbox/query/QueryFilterComparatorTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ public void filter_count_unsupported() {
7575
.count();
7676
}
7777

78+
@Test(expected = UnsupportedOperationException.class)
79+
public void filter_remove_unsupported() {
80+
box.query()
81+
.filter(createTestFilter())
82+
.build()
83+
.remove();
84+
}
85+
7886
@Test(expected = UnsupportedOperationException.class)
7987
public void filter_findFirst_unsupported() {
8088
box.query()

0 commit comments

Comments
 (0)