objectbox / objectbox/objectbox-java

Add query filter that tests for empty ToMany

Open
#677 1 comment 11 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

It would be nice if QueryBuilder would allow to test for emptiness without having to resort to using filter(). This would be especially useful with many-to-many relations if one could write something like this:

boxFor(SomeEntity::class)
    .query()
    .empty(SomeEntity_.otherEntities)
    .build()
    .find()

This would return all instances of SomeEntity that do not have any related OtherEntity if SomeEntity is defined like this:

class SomeEntity {
    lateinit var otherEntities: ToMany<OtherEntity>
}

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 by locating the QueryBuilder API and its existing filter() handling, then review how ToMany relations are represented in queries. The work is complete when an empty(SomeEntity_.otherEntities)-style query returns entities with no related OtherEntity records and is covered by appropriate query tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.