Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/datastore/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'use strict';

var arrify = require('arrify');
var extend = require('extend');
var nodeutil = require('util');

/**
Expand Down Expand Up @@ -418,10 +417,12 @@ Transaction.prototype.commit_ = function(callback) {

// Take the `req` array built previously, and merge them into one request to
// send as the final transactional commit.
var reqOpts = this.requests_.reduce(function(acc, req) {
return extend(true, acc, req);
}, {});

var reqOpts = {
mutations: this.requests_.reduce(function(acc, req) {

This comment was marked as spam.

This comment was marked as spam.

acc = acc.concat(req.mutations);
return acc;
}, [])
};

this.request_(protoOpts, reqOpts, function(err, resp) {
if (err) {
Expand Down
26 changes: 20 additions & 6 deletions test/datastore/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
var arrify = require('arrify');
var assert = require('assert');
var entity = require('../../lib/datastore/entity.js');
var extend = require('extend');
var mockery = require('mockery-next');
var util = require('../../lib/common/util.js');

Expand Down Expand Up @@ -364,14 +363,29 @@ describe('Transaction', function() {

it('should send the built request object', function(done) {
transaction.requests_ = [
{ a: 'b', c: 'd' },
{ e: 'f', g: 'h' }
{
mutations: [
{ a: 'b' },
{ c: 'd' }
]
},
{
mutations: [
{ e: 'f' },
{ g: 'h' }
]
}
];

transaction.request_ = function(protoOpts, reqOpts) {
var req1 = transaction.requests_[0];
var req2 = transaction.requests_[1];
assert.deepEqual(reqOpts, extend(req1, req2));
assert.deepEqual(reqOpts, {
mutations: [
{ a: 'b' },
{ c: 'd' },
{ e: 'f' },
{ g: 'h' }
]
});
done();
};

Expand Down