Skip to content

Commit 1896e42

Browse files
Model: pass relation name to database #142
Also fix test that is asserting query parameters. This also nicely verifies that passing the name works.
1 parent 21d7ec9 commit 1896e42

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

objectbox/lib/src/native/model.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ class Model {
142142
void addRelation(ModelRelation rel) {
143143
_check(C.model_relation(
144144
_cModel, rel.id.id, rel.id.uid, rel.targetId.id, rel.targetId.uid));
145+
146+
final name = rel.name.toNativeUtf8();
147+
try {
148+
_check(C.model_relation_name(_cModel, name.cast()));
149+
} finally {
150+
calloc.free(name);
151+
}
152+
145153
if (rel.externalType != null) {
146154
_check(C.model_relation_external_type(_cModel, rel.externalType!));
147155
}

objectbox_test/test/query_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ void main() {
976976
[
977977
'tString == "foo"',
978978
'| Link RelatedEntityB via relBId with conditions: tString == "bar"',
979-
'| Link RelatedEntityA via standalone Relation 1 (from entity 1 to 4) with conditions: tInt == 11',
979+
'| Link RelatedEntityA via standalone Relation 1 (relManyA) (from entity 1 to 4) with conditions: tInt == 11',
980980
].join('\n'));
981981
});
982982

0 commit comments

Comments
 (0)