Don't merge JSON fields after save() when using Postgres to keep same behaviour as MongoDB (#4808) (#4815)

This commit is contained in:
Jaeger
2018-06-07 12:43:54 -04:00
committed by Florent Vilmart
parent 1afc34eea3
commit cf3a872e67
2 changed files with 28 additions and 1 deletions

View File

@@ -1324,7 +1324,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
return p + ` - '$${index + 1 + i}:value'`;
}, '');
updatePatterns.push(`$${index}:name = ( COALESCE($${index}:name, '{}'::jsonb) ${deletePatterns} ${incrementPatterns} || $${index + 1 + keysToDelete.length}::jsonb )`);
updatePatterns.push(`$${index}:name = ('{}'::jsonb ${deletePatterns} ${incrementPatterns} || $${index + 1 + keysToDelete.length}::jsonb )`);
values.push(fieldName, ...keysToDelete, JSON.stringify(fieldValue));
index += 2 + keysToDelete.length;