Repository navigation
feat: Implement Default Values on Exception model fields - #2678
Merged
Merged
Conversation
klkucaj
force-pushed
the
feature/1140-on-exception
branch
from
August 27, 2024 09:40
e5fce5b to
d6ff178
Compare
SandPod
reviewed
Aug 27, 2024
SandPod
left a comment
Contributor
There was a problem hiding this comment.
Nice work! change is pretty small.
Still would be nice to see more tests around this. Since, from the user perspective, this is separate feature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This is a follow-up to #2383.
This PR introduces support for default values in exception fields.
Default Types
In exception models, there are two types of default values that can be specified:
Important Note
Since exceptions are never persisted to the database, we do not support
defaultPersistfor exception fields. This means that onlydefaultanddefaultModelare relevant in this context.However, it’s important to note that
defaultModelwill overridedefaultif both are specified. Since exceptions only exist in the model (Dart code) and are not persisted, usingdefaultModelin combination withdefaultis redundant. ThedefaultModelvalue will always take precedence overdefault, making it unnecessary to use both in conjunction.Default Value Options for Exception Fields
In exception models, default values can be assigned to any field type that is supported in class models. This provides flexibility in specifying initial values for various field types, ensuring consistency across your exception handling.
Example Exception YAML
Related Issues
Pre-launch Checklist
///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.If you need help, consider asking for advice on the discussion board.
Breaking changes