Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1056 Make refresh work when foreign key is set to null, and with load_json #1060

Merged
merged 8 commits into from
Jul 30, 2024

Conversation

dantownsend
Copy link
Member

Related to #1056

There are a couple of other edge cases I discovered.

Null objects

>>> band = await Band.objects(Band.manager).where(Band.name == "Pythonistas").first()
>>> band.manager.name
"Guido"

# If the band.manager foreign key gets set to null, when we refresh the object, it should now be null
>>> await band.refresh()
>>> band.manager
None

load_json

When refreshing, it doesn't load any JSON:

>>> studio = await RecordingStudio.objects().output(load_json=True).first()
>>> studio.facilities
{'restaurant': True, 'mixing_desk': True}

>>> await studio.refresh()
>>> studio.facilities
 '{"restaurant":true,"mixing_desk":true}'

Now you can do this:

>>> await studio.refresh(load_json=True)
>>> studio.facilities
{"restaurant":true,"mixing_desk":true}

@dantownsend dantownsend added the enhancement New feature or request label Jul 29, 2024
@dantownsend dantownsend merged commit 8c1563e into master Jul 30, 2024
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant