Skip to content

Commit

Permalink
Merge 2b14dd9 into beb9308
Browse files Browse the repository at this point in the history
  • Loading branch information
josephjunker committed Sep 22, 2014
2 parents beb9308 + 2b14dd9 commit 9abac6d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ var db = require('priam')({
Release Notes
-------------
- `0.8.15`: Add isBatch method to base driver to check if an object is a Priam batch.
- `0.8.14`: Fix `resultTransformer` bug when query generates an error.
- `0.8.13`: Fix `Batch.add()` when given empty `Batch` or `Query` objects.
- `0.8.12`: Remove github dependency via `priam-connection-cql` module. Added versioning logic around `cqlVersion` to use the appropriate driver.
Expand Down
4 changes: 4 additions & 0 deletions lib/drivers/base-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ BaseDriver.prototype.connectionResolverFetchHandler = function connectionResolve
}
};

BaseDriver.prototype.isBatch = function isBatch(obj){
return obj instanceof Batch;
};

function setDefaultConsistency(defaultConsistencyLevel, options, callback) {
var p = checkOptionalParameters(options, callback);
if (!p.options.consistency) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "priam",
"version": "0.8.14",
"version": "0.8.15",
"description": "A simple Cassandra driver. It wraps the helenus and node-cassandra-cql drivers with additional error/retry handling, external .cql file support, and connection option resolution from an external source, among other improvements.",
"keywords": [
"cassandra",
Expand Down
32 changes: 32 additions & 0 deletions test/unit/drivers/base-driver.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,36 @@ describe('lib/drivers/base-driver.js', function () {
expect(type).to.equal(driver.dataType.text);
});
});

describe('isBatch', function(){
var driver;

beforeEach(function () {
driver = new getDefaultInstance();
});

it('returns true if passed a batch', function(){
var batch = driver.beginBatch();
expect(driver.isBatch(batch)).to.be.true;
});

it('returns false if passed a non-batch', function(){
var notBatch = {
add: function(){},
foo: 'bar'
};
expect(driver.isBatch(notBatch)).to.be.false;
});

it('handles weird values', function(){
expect(driver.isBatch()).to.be.false;
expect(driver.isBatch(null)).to.be.false;
expect(driver.isBatch(undefined)).to.be.false;
expect(driver.isBatch({})).to.be.false;
expect(driver.isBatch(true)).to.be.false;
expect(driver.isBatch(false)).to.be.false;
expect(driver.isBatch([])).to.be.false;
});

});
});

0 comments on commit 9abac6d

Please sign in to comment.