feat: support nullable embedded entities #10829
Open
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.
Support nullable embedded fields such that embedded documents in MongoDB can correctly be returned as null for a subdocument that is explicitly nullable.
Closes: #3913
Description of change
This change adds to the
ColumnEmbeddedOptions
thenullable
field, thus allowing subdocuments in MongoDB to benull
explicitly. This ensures they're returned correctly from the database in the case a null is set. This is useful when a developer has a required key that can be set to null - currently the key is not returned at all.I saw this in #3913 though this was reverted as it previously changed all nested fields to null, which caused some problems I imagine for people. This method of implementing this change should not cause problems or any breaking changes and is entirely optional.
I have locally tested this with MongoDB, but not a SQL provider.
Pull-Request Checklist
master
branchnpm run format
to apply prettier formattingnpm run test
passes with this changeFixes #0000