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

Returning all fields after creation even if it's NULL #827

Closed
Marlysson opened this issue Oct 28, 2022 · 1 comment
Closed

Returning all fields after creation even if it's NULL #827

Marlysson opened this issue Oct 28, 2022 · 1 comment
Labels
bug An existing feature is not working as intended

Comments

@Marlysson
Copy link
Contributor

Describe the bug
Is there a way to hydrate model that includes null fields? Because if I load the model from DB, all fields that are null are not included in Model.attributes
Even Model.all_attributes() doesn't give me all attributes hydrated with None values.

To Reproduce

result = Model.create(field=value)
result.__attributes__ # nullable field with NULL values will not appear in dict

Expected behavior

result.__attributes__ -> {...., {"nullable_field": None}}
@Marlysson Marlysson added the bug An existing feature is not working as intended label Oct 28, 2022
@josephmancuso
Copy link
Member

Theres really not a great way to do this with consistency. The problem is if you don't supply the fields, we don't know what the defaults will be. Not every field you don't specify will be nullable. Some fields could default to any value you specify in the migration or table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An existing feature is not working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants