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

feat(db) make schema set fields to default if missing from DB #3756

Merged
merged 4 commits into from
Sep 12, 2018

Conversation

hishamhm
Copy link
Contributor

@hishamhm hishamhm commented Sep 10, 2018

This PR proposes new semantics for handling missing or unset values arriving from the strategies. With this PR, the DAO will apply the default values if a strategy returns a column as ngx.null and is marked as nullable = false in a schema. We also make records in entities non-nullable by default, so that we always recurse their structure, filling defaults for their fields.

This will allow us to produce default values in newly-added columns without requiring a migration filling the table with default values.

@hishamhm hishamhm added the pr/wip A work in progress PR opened to receive feedback label Sep 10, 2018
@hishamhm hishamhm force-pushed the feat/auto-defaults branch 2 times, most recently from 6225d6e to e4cb490 Compare September 12, 2018 15:52
Make records in Entities non-nullable by default, so that they return their
full structure on API queries. The idea of returning explicit nulls in API
queries was to allow users to see what are the available fields. In nested
structures, for that to happen we need to make records non-nullable, even if
their individual fields are.

A field of the `record` type in an Entity can still be made nullable if
desired, with an explicit `nullable = true` property.

This is done at the Entity level because the MetaSchema uses nullable
records extensively.
@hishamhm hishamhm force-pushed the feat/auto-defaults branch 3 times, most recently from 0f16905 to eb2af97 Compare September 12, 2018 16:57
This allows us to auto-fill the then_field with a default and
not require the presence of the if_field when performing
a partial update.
@hishamhm hishamhm removed the pr/wip A work in progress PR opened to receive feedback label Sep 12, 2018
@thibaultcha thibaultcha merged commit 6aafb91 into next Sep 12, 2018
@thibaultcha thibaultcha deleted the feat/auto-defaults branch September 12, 2018 20:48
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