Skip to content

Commit

Permalink
Merge pull request #42 from DullReferenceException/bom-fix
Browse files Browse the repository at this point in the history
BOM fix
  • Loading branch information
asilvas committed Feb 3, 2015
2 parents bb00844 + 2fdb4e5 commit 34e8392
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/util/query-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ QueryCache.prototype.initQueries = function initQueries() {
, fileCache = this.fileCache
, files = fs.readdirSync(queryDir);
files.forEach(function (filePath) {
fileCache[path.basename(filePath, ".cql")] = fs.readFileSync(path.join(queryDir, filePath), "utf8");
var fileContent = fs.readFileSync(path.join(queryDir, filePath), "utf8").replace(/^\uFEFF/, ''); // remove BOM
fileCache[path.basename(filePath, ".cql")] = fileContent;
});
};

Expand Down
1 change: 1 addition & 0 deletions test/stubs/cql/cqlFileWithBOM.cql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM "myColumnFamily"
13 changes: 13 additions & 0 deletions test/unit/drivers/datastax.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,19 @@ describe('lib/drivers/datastax', function () {
});
});

it('handles CQL files containing a BOM', function (done) {
// arrange
var queryName = 'cqlFileWithBOM';
var params = [];
var consistency = cql.types.consistencies.one;

// act
instance.namedQuery(queryName, params, { consistency: consistency }, function () {
expect(instance.execCql.firstCall.args[0]).to.equal('SELECT * FROM "myColumnFamily"');
done();
});
});

it('allows caller to disable prepared statement', function (done) {
// arrange
var queryName = 'myFakeCql';
Expand Down

0 comments on commit 34e8392

Please sign in to comment.