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 4 commits into from Sep 12, 2018


None yet
2 participants
Copy link

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 label Sep 10, 2018

@hishamhm hishamhm force-pushed the feat/auto-defaults branch 2 times, most recently from 6225d6e to e4cb490 Sep 11, 2018

hishamhm added some commits Sep 10, 2018

feat(schema) make records non-nullable by default
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 Sep 12, 2018

hishamhm added some commits Sep 11, 2018

feat(schema) require only if_field in conditional fields
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 force-pushed the feat/auto-defaults branch from eb2af97 to 57235ea Sep 12, 2018

@hishamhm hishamhm removed the pr/wip label Sep 12, 2018

@thibaultcha thibaultcha merged commit 6aafb91 into next Sep 12, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@thibaultcha thibaultcha deleted the feat/auto-defaults branch Sep 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.