Skip to content

Commit e59a61f

Browse files
datastore: fix - mark transactions as finalized.
1 parent a9645cd commit e59a61f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/datastore/request.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,15 @@ DatastoreRequest.prototype.save = function(entities, callback) {
253253
callback(err);
254254
return;
255255
}
256+
if (this.id) {
257+
this.isFinalized = true;
258+
}
256259
var autoInserted = (resp.mutation_result.insert_auto_id_key || []);
257260
autoInserted.forEach(function(key, index) {
258261
keys[insertIndexes[index]] = entity.keyFromKeyProto(key);
259262
});
260263
callback(null, isMultipleRequest ? keys : keys[0]);
261-
});
264+
}.bind(this));
262265
};
263266

264267
/**
@@ -300,7 +303,12 @@ DatastoreRequest.prototype.delete = function(keys, callback) {
300303
}
301304
req = new pb.CommitRequest(req);
302305
var res = pb.CommitResponse;
303-
this.createRequest_('commit', req, res, callback);
306+
this.createRequest_('commit', req, res, function() {
307+
if (this.id) {
308+
this.isFinalized = true;
309+
}
310+
callback.apply(null, util.toArray(arguments));
311+
}.bind(this));
304312
};
305313

306314
/**

0 commit comments

Comments
 (0)