Skip to content

bug: Updating node attribute to its original value #349

@LucasG0

Description

@LucasG0

Component

Python SDK

Infrahub SDK version

1.10.1

Current Behavior

If we create a node, fetch it from the server, then modifies an attribute value, and re-modify this value with the original value set during creation, the value is not updated:

This is because we consider blue to be the original data within the _strip_unmodified logic supposed to not send non-updated fields within the GraphQL query. We may need a similar fix to what has been done for relationships, ie adding a flag to indicate whether the attribute comes from initialization.

Expected Behavior

Attribute value should be correctly updated

Steps to Reproduce

owner = await client.create(kind="TestPerson", name="owner", item="blue")
await owner.save()
owner = await client.get(kind="TestPerson", id=owner.id)

owner.item.value = "red"
await owner.save()

owner.item.value = "blue"
await owner.save()
node = await client.get(kind="TestPerson", id=owner.id)
assert node.item.value == "blue"  # --> fails, it's red 

Additional Information

The issue still happens with populate_store=False within get calls.

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions