Skip to content

Commit

Permalink
bigtable: set true/false filters to null when omitted
Browse files Browse the repository at this point in the history
  • Loading branch information
callmehiphop authored and stephenplusplus committed Aug 4, 2016
1 parent 1a42246 commit aa4bf39
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/bigtable/src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,10 @@ Filter.prototype.time = function(time) {
* execution of the filters will be the order in which they were specified.
*/
Filter.prototype.toProto = function() {
if (!this.filters_.length) {
return null;
}

if (this.filters_.length === 1) {
return this.filters_[0];
}
Expand Down
19 changes: 19 additions & 0 deletions packages/bigtable/system-test/bigtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,25 @@ function generateTableName() {
});
});

it('should run a conditional filter with pass only', function(done) {
var filter = {
condition: {
test: [{
row: 'gwashington'
}],
pass: [{
all: true
}]
}
};

TABLE.getRows({ filter: filter }, function(err, rows) {
assert.ifError(err);
assert(rows.length > 0);
done();
});
});

it('should only get cells for a specific family', function(done) {
var entries = [{
key: 'gwashington',
Expand Down
7 changes: 7 additions & 0 deletions packages/bigtable/test/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,13 @@ describe('Bigtable/Filter', function() {
});

describe('toProto', function() {
it('should return null when no filters are present', function() {
var filter = new Filter();
var filterProto = filter.toProto();

assert.strictEqual(filterProto, null);
});

it('should return a plain filter if there is only 1', function() {
filter.filters_ = [{}];

Expand Down

0 comments on commit aa4bf39

Please sign in to comment.