fix: Don't throw an error for null inputs to the save function #1361
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.
Summary:
This PR fixes issue #1327.
Background:
Taken directly from this PR
Changes:
src/entity.ts
: A couple of lines have been added that prevent errors from being thrown whenarray
orentity
is null or undefined. This change may not make the save function perfect and is a sign there may be more work to perfect the save function, but it is clearly an improvement because now code will work for certain inputs that used to throw useless errors.test/entity.ts
: A test has been added that throws an error and fails without the new changes tosrc/entity.ts
. In this test,excludeFromIndexes: true
is always in the right place.Next steps:
The save function was broken down here, but for the save function to work properly for every possible input, more edge cases for special cases with nulls, undefined values and other unique values passed into the save function should be explored.