Skip to content

Commit b9f08d9

Browse files
committed
Do not mutate parameter object in DatabaseController.
1 parent 7143a12 commit b9f08d9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Controllers/DatabaseController.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var Parse = require('parse/node').Parse;
66

77
var Schema = require('./../Schema');
88
var transform = require('./../transform');
9+
const deepcopy = require('deepcopy');
910

1011
// options can contain:
1112
// collectionPrefix: the string to put in front of every collection name.
@@ -130,6 +131,9 @@ DatabaseController.prototype.untransformObject = function(
130131
// one of the provided strings must provide the caller with
131132
// write permissions.
132133
DatabaseController.prototype.update = function(className, query, update, options) {
134+
// Make a copy of the object, so we don't mutate the incoming data.
135+
update = deepcopy(update);
136+
133137
var acceptor = function(schema) {
134138
return schema.hasKeys(className, Object.keys(query));
135139
};
@@ -300,6 +304,9 @@ DatabaseController.prototype.destroy = function(className, query, options = {})
300304
// Inserts an object into the database.
301305
// Returns a promise that resolves successfully iff the object saved.
302306
DatabaseController.prototype.create = function(className, object, options) {
307+
// Make a copy of the object, so we don't mutate the incoming data.
308+
object = deepcopy(object);
309+
303310
var schema;
304311
var isMaster = !('acl' in options);
305312
var aclGroup = options.acl || [];

0 commit comments

Comments
 (0)