diff --git a/src/row.js b/src/row.js index e3d894704..4d0e9e63d 100644 --- a/src/row.js +++ b/src/row.js @@ -266,6 +266,7 @@ class Row { data: options.entry, method: Mutation.methods.INSERT, }; + this.data = {}; this.table.mutate(entry, options.gaxOptions, (err, apiResponse) => { if (err) { @@ -367,7 +368,7 @@ class Row { rowKey: Mutation.convertToBytes(this.id), rules, }; - + this.data = {}; this.bigtable.request( { client: 'BigtableClient', @@ -409,7 +410,7 @@ class Row { key: this.id, method: Mutation.methods.DELETE, }; - + this.data = {}; this.table.mutate(mutation, gaxOptions, callback); } @@ -467,7 +468,7 @@ class Row { data: arrify(columns), method: Mutation.methods.DELETE, }; - + this.data = {}; this.table.mutate(mutation, gaxOptions, callback); } @@ -599,7 +600,7 @@ class Row { trueMutations: createFlatMutationsList(config.onMatch), falseMutations: createFlatMutationsList(config.onNoMatch), }; - + this.data = {}; this.bigtable.request( { client: 'BigtableClient', @@ -728,10 +729,10 @@ class Row { return; } - extend(true, this.data, row.data); + this.data = row.data; // If the user specifies column names, we'll return back the row data we - // received. Otherwise, we'll return the row itthis in a typical + // received. Otherwise, we'll return the row "this" in a typical // GrpcServiceObject#get fashion. callback(null, columns.length ? row.data : this); }); @@ -910,7 +911,7 @@ class Row { data: entry, method: Mutation.methods.INSERT, }; - + this.data = {}; this.table.mutate(mutation, gaxOptions, callback); } } diff --git a/test/row.js b/test/row.js index 3283545f0..e11cf5adf 100644 --- a/test/row.js +++ b/test/row.js @@ -719,6 +719,17 @@ describe('Bigtable/Row', function() { row.delete(gaxOptions, done); }); + + it('should remove existing data', function(done) { + var gaxOptions = {}; + row.table.mutate = function(mutation, gaxOptions_) { + assert.strictEqual(gaxOptions_, gaxOptions); + done(); + }; + + row.delete(gaxOptions, done); + assert.strictEqual(row.data, undefined); + }); }); describe('deleteCells', function() { @@ -746,6 +757,15 @@ describe('Bigtable/Row', function() { row.deleteCells(columns, gaxOptions, done); }); + + it('should remove existing data', function(done) { + row.table.mutate = function(mutation, gaxOptions, callback) { + callback(); // done() + }; + + row.deleteCells(columns, done); + assert.strictEqual(row.data, undefined); + }); }); describe('exists', function() { @@ -1440,6 +1460,17 @@ describe('Bigtable/Row', function() { row.save(data, gaxOptions, assert.ifError); }); + + it('should remove existing data', function(done) { + var gaxOptions = {}; + row.table.mutate = function(entry, gaxOptions_) { + assert.strictEqual(gaxOptions_, gaxOptions); + done(); + }; + + row.save(data, gaxOptions, assert.ifError); + assert.strictEqual(row.data, undefined); + }); }); describe('RowError', function() {