Skip to content

Model: pass relation name to database #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions objectbox/lib/src/native/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ class Model {
void addRelation(ModelRelation rel) {
_check(C.model_relation(
_cModel, rel.id.id, rel.id.uid, rel.targetId.id, rel.targetId.uid));

final name = rel.name.toNativeUtf8();
try {
_check(C.model_relation_name(_cModel, name.cast()));
} finally {
calloc.free(name);
}

if (rel.externalType != null) {
_check(C.model_relation_external_type(_cModel, rel.externalType!));
}
Expand Down
2 changes: 1 addition & 1 deletion objectbox_test/test/query_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ void main() {
[
'tString == "foo"',
'| Link RelatedEntityB via relBId with conditions: tString == "bar"',
'| Link RelatedEntityA via standalone Relation 1 (from entity 1 to 4) with conditions: tInt == 11',
'| Link RelatedEntityA via standalone Relation 1 (relManyA) (from entity 1 to 4) with conditions: tInt == 11',
].join('\n'));
});

Expand Down
Loading