From c79a52d186e2dc1582d9ca9830192359ded096e1 Mon Sep 17 00:00:00 2001 From: Stephen Sawchuk Date: Wed, 8 Oct 2014 20:14:08 -0400 Subject: [PATCH] datastore: fix - mark transactions as finalized. --- lib/datastore/request.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/datastore/request.js b/lib/datastore/request.js index 3f7e3277494..e47e3ff9396 100644 --- a/lib/datastore/request.js +++ b/lib/datastore/request.js @@ -253,12 +253,15 @@ DatastoreRequest.prototype.save = function(entities, callback) { callback(err); return; } + if (this.id) { + this.isFinalized = true; + } var autoInserted = (resp.mutation_result.insert_auto_id_key || []); autoInserted.forEach(function(key, index) { keys[insertIndexes[index]] = entity.keyFromKeyProto(key); }); callback(null, isMultipleRequest ? keys : keys[0]); - }); + }.bind(this)); }; /** @@ -300,7 +303,12 @@ DatastoreRequest.prototype.delete = function(keys, callback) { } req = new pb.CommitRequest(req); var res = pb.CommitResponse; - this.createRequest_('commit', req, res, callback); + this.createRequest_('commit', req, res, function(err) { + if (!err && this.id) { + this.isFinalized = true; + } + callback.apply(null, util.toArray(arguments)); + }.bind(this)); }; /**