objectbox / objectbox/objectbox-dart

Support oneOf for relations

Open
#523 10 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

Basic info (please complete the following information):
  • ObjectBox version: 2.0.0
  • Flutter/Dart SDK: Flutter 3.7.7
  • Null-safety enabled: yes
  • Reproducibility: always
  • OS: macOs, but it shoudlnt exactly matter
Steps to reproduce

Dart version lacks any kind of eager loading of relations so I wanted to batch get them rather then fetching it one by one.

Example: ObjectA with ToOne relation to ObjectB.

final q = (db.store.box<ObjectA>().query()..link(ObjectA_.relation, ObjectB_.id.oneOf([1])))
    .build();
final res = q.find();

getting

Unsupported operation: Unsupported type for IN: 11

Similarly:

final q = (db.store.box<ObjectA>().query(ObjectA_.relation.oneOf([1])).build();
final res = q.find();

Same error.

Expected behavior

Return ObjectA list where relation is filtered by oneOf.

Contributor guide

Open the contributing guide

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

No source files or tests are named. Start by reproducing the relation query with ToOne and oneOf shown in the issue, then trace the Dart query-builder handling for linked relations and IN filters. Done means both examples return ObjectA records whose relation matches oneOf without the unsupported-type error.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
database, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.