Skip to content

Conversation

@NBIX-Mark-Southern
Copy link
Contributor

My Odata system returns state from an update (PATCH) call. It makes sense to update the entity object with this and not need to make a separate call (force_refresh=True). The logic is the same as for an insert (POST) call.

As an aside, it may make sense to separate the save method into insert and update calls as in order to make an update without first having to query for an entity before updating it. To achieve this, I had to set Entity.__odata__.persisted = True which seems too obsure for a general pattern.

sample = odata_service.entities["SAMPLE"]()
sample.Barcode = "12345" # primary key
sample.HELLO = "world"    # property to update
sample.__odata__.persisted = True  # flag it already exists to force an update
odata_service.save(sample, force_refresh=False)

@eblis eblis merged commit d6f4d00 into eblis:master Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants