postgres: Ensure that setting a value to undefined is a no-op on writes. (#5065) (#5069)

This commit is contained in:
Ben Briggs
2018-09-26 21:42:06 +01:00
committed by Florent Vilmart
parent 4b5fb84678
commit 45ff23bde2

View File

@@ -1442,7 +1442,10 @@ export class PostgresStorageAdapter implements StorageAdapter {
for (const fieldName in update) {
const fieldValue = update[fieldName];
if (fieldValue === null) {
// Drop any undefined values.
if (typeof fieldValue === 'undefined') {
delete update[fieldName];
} else if (fieldValue === null) {
updatePatterns.push(`$${index}:name = NULL`);
values.push(fieldName);
index += 1;