Skip to content

Commit

Permalink
datastore: fix - mark transactions as finalized.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Oct 9, 2014
1 parent a9645cd commit c79a52d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/datastore/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

/**
Expand Down Expand Up @@ -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));
};

/**
Expand Down

0 comments on commit c79a52d

Please sign in to comment.