objectbox / objectbox/objectbox-java

Can't use query ForEach() with Order()

Open
#238 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
4.6k
Forks
311
PR merge metrics
No merged PRs in 30d

Description

I got that exception message when i tried to use foreach function with order list:
"This method is currently only available for unordered queries"
Its not make any sense because I can just query with order and make forEach manually in my code and it will work. Weird a bit.

Issue Basics

ObjectBox v1.1.0

It can reproduce.

Code
final Box<CallRemindersData> box = objectBox.boxFor(CallRemindersData.class);
final QueryBuilder<CallRemindersData> callRemindersDataQueryBuilder = box.query().order(CallRemindersData_.notificationTime);
callRemindersDataQueryBuilder .build().forEach()

The code that make it (Query.java):

if (hasOrder) {
            throw new UnsupportedOperationException("This method is currently only available for unordered queries");
 }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Query.java at the hasOrder check that throws UnsupportedOperationException, then inspect the surrounding forEach implementation and query execution behavior. Reproduce the Java example with an ordered query and verify that forEach completes in order without the exception, adding or running the relevant existing tests if available.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.