Skip to content

Enable an update to handle returned state - #10

Merged
eblis merged 1 commit into
eblis:masterfrom
NBIX-Mark-Southern:patch_returns_state
Feb 22, 2025
Merged

Enable an update to handle returned state#10
eblis merged 1 commit into
eblis:masterfrom
NBIX-Mark-Southern:patch_returns_state

Conversation

@NBIX-Mark-Southern

Copy link
Copy Markdown
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 keysample.HELLO="world"# property to updatesample.__odata__.persisted=True# flag it already exists to force an updateodata_service.save(sample, force_refresh=False)

@eblis
eblis merged commit d6f4d00 into eblis:masterFeb 22, 2025
Sign up for freeto 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

@NBIX-Mark-Southern@eblis