nodejs-datastore
nodejs-datastore copied to clipboard
fix: not check index exclusion path for `null` values
This PR fixes issue #1327 🦕
Summary
Considering the following 4 types of index exclusions:
excludeFromindexes: ['foo.*']excludeFromindexes: ['foo.bar']excludeFromindexes: ['foo[].*']excludeFromindexes: ['foo[].bar']
Supplying { entity: { foo: null } } throws for 2 and 3, but not for 1 and 4.
save({ excludeFromIndexes: ['foo.bar'], entity: { sho: 1, foo: null })
// throws TypeError: Cannot read properties of undefined (reading 'properties')
save({ excludeFromIndexes: ['foo[].*'], entity: { sho: 1, foo: null })
// throws TypeError: Cannot read properties of undefined (reading 'values')
With the changes in this PR, the save calls will not throw in any of the 4 cases.