-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Improve settings validation and type handling #10582
Comments
One addition: Exports might have "0" or "1". We have to ensure that these imports won't fail again 👍 |
Another addition: |
refs TryGhost#10582 - Importer should do similar conversion introduced in 04c60b4
We don't have any specific handling for null/undefined values in keys atm. When the value is not present for a key, this check in Settings model prevents it from being set to
Ideally objects without As for Regarding date/timestamp fields, the only values we store are for |
This needs some more context. Worth raising a separate issue with your findings. |
…oleans refs TryGhost#10582 - otherwise we will forward string booleans to model layer - causes trouble if we trigger events - causes trouble if we want to add conditions to the model e.g. setting.get('value') ?
refs TryGhost#10582 - ensure we won't forward booleans to database - type TEXT will transform booleans to "0"/"1!
refs TryGhost#10582 - deprecated - won't serve - won't save
refs TryGhost#10582 - the db input formatter ensures we always forward "true" or "false" for boolean fields
refs TryGhost#10582 - I don't think this is a good idea - If a user passses "null", we should treat it as a string - I am not aware of a use case why people have "null" in their database - If people send "null" via the API, we should respect this and accept a string
…oleans refs #10582 - otherwise we will forward string booleans to model layer - causes trouble if we trigger events - causes trouble if we want to add conditions to the model e.g. setting.get('value') ?
refs #10582 - ensure we won't forward booleans to database - type TEXT will transform booleans to "0"/"1!
refs #10582 - deprecated - won't serve - won't save
refs #10582 - the db input formatter ensures we always forward "true" or "false" for boolean fields
refs #10582 - I don't think this is a good idea - If a user passses "null", we should treat it as a string - I am not aware of a use case why people have "null" in their database - If people send "null" via the API, we should respect this and accept a string
The Problem
It is unclear what values can be set for each key in the settings object. This caused issues like #10576 and #10580
Current state
At the moment we don't have clear schema definition for all the values that can be stored in settings. There is a validation present on model layer, but it doesn't contain validations for all fields. We are not consistent with how boolean values are stored in the database.
Future improvements
We need to review uses of following data types/values that might cause the most of problems:
List of issues should be tackled for booleas:
true
/false
into"true"
/"false"
to be stored in the dbThe text was updated successfully, but these errors were encountered: