-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
type/bugSomething isn't working as expectedSomething isn't working as expected
Description
h3. Component
[| #component]
No response
h3. Infrahub SDK version
[| #infrahub-sdk-version]
1.14
h3. Current Behavior
[| #current-behavior]
Considering the peer of a relationship R of a node N, if R inherits from a generic G and the relationship schema within N points to G (and not to R), then fetching the node N from the sdk wouldn't fill the attributes of the peer corresponding to R. Thus, the resulting peer node is missing attributes while they might not even be optional.
h3. Expected Behavior
[| #expected-behavior]
The related node should have its attributes filled.
h3. Steps to Reproduce
[| #steps-to-reproduce]
class TestFetchPeerInheriting(TestInfrahubApp):
async def test_fetch_peer_inheriting(
self, db: InfrahubDatabase, client: InfrahubClient, schemas_person: SchemaRoot, default_branch: Branch
) -> None:
schema = {
"version": "1.0",
"generics": [
{
"name": "GenericPerson",
"namespace": "Test",
"relationships": [
{
"name": "car",
"peer": "TestCarr",
"optional": True,
"cardinality": "one",
},
],
},
],
"nodes": [
{
"name": "Carr",
"namespace": "Test",
"default_filter": "name__value",
"attributes": [
{"name": "name", "kind": "Text", "unique": True},
],
"relationships": [
{
"name": "owner",
"peer": "TestGenericPerson",
"optional": False,
"cardinality": "one",
},
],
},
{
"name": "Personn",
"namespace": "Test",
"default_filter": "name__value",
"inherit_from": ["TestGenericPerson"],
"attributes": [
{"name": "name", "kind": "Text", "unique": True},
],
},
],
}
response = await client.schema.load(schemas=[schema])
assert len(response.errors) == 0, response.errors
person = await client.create(kind="TestPersonn", name="JohnDoe")
await person.save()
car = await client.create(kind="TestCarr", name="AMercedes", owner=person)
await car.save()
# clear store
client.store._branches = {}
car = await client.get(kind="TestCarr", name__value="AMercedes", prefetch_relationships=True)
owner_name = car.owner.peer.name.value
assert owner_name == "JohnDoe", owner_name <--- Raises an error, owner_name is `None`
h3. Additional Information
[| #additional-information]
No response
Metadata
Metadata
Assignees
Labels
type/bugSomething isn't working as expectedSomething isn't working as expected