Skip to content

Commit 4917cfc

Browse files
committed
Query: allow comparator for findUnique()
1 parent fa61dbb commit 4917cfc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private void ensureNoComparator() {
182182
*/
183183
@Nullable
184184
public T findUnique() {
185-
ensureNoFilterNoComparator();
185+
ensureNoFilter(); // Comparator is fine: does not make any difference for a unique result
186186
return callInReadTx(new Callable<T>() {
187187
@Override
188188
public T call() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ public void comparator_findFirst_unsupported() {
144144
.findFirst();
145145
}
146146

147-
@Test(expected = UnsupportedOperationException.class)
148-
public void comparator_findUnique_unsupported() {
147+
@Test
148+
public void comparator_findUnique_supported() {
149149
box.query()
150150
.sort(createTestComparator())
151151
.build()

0 commit comments

Comments
 (0)