Skip to content

Commit 6f708c5

Browse files
committed
Fix for relationship cardinality one of type ref
1 parent bdd4d32 commit 6f708c5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

infrahub_sdk/spec/object.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ async def get_relationship_info(
103103
else:
104104
info.reason_relationship_not_valid = "Too many objects provided for a relationship of cardinality one"
105105

106+
elif rel_schema.cardinality == "one" and isinstance(value, str):
107+
info.format = RelationshipDataFormat.ONE_REF
108+
106109
elif rel_schema.cardinality == "one" and isinstance(value, dict) and "data" in value:
107110
info.format = RelationshipDataFormat.ONE_OBJ
108111

tests/integration/test_spec_object.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def test_load_persons02(self, client: InfrahubClient, branch_name: str, in
8989
await obj_file.validate_format(client=client, branch=branch_name)
9090

9191
# Check that the nodes are not present in the database before loading the file
92-
assert len(await client.all(kind=obj_file.spec.kind, branch=branch_name)) == 4
92+
assert len(await client.all(kind=obj_file.spec.kind, branch=branch_name)) == 3
9393

9494
await obj_file.process(client=client, branch=branch_name)
9595

0 commit comments

Comments
 (0)