Skip to content

Commit

Permalink
updated to include '.' in RE_PARAM; mysqljs#14
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusecker committed May 14, 2019
1 parent d5134a3 commit 8363a74
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// based on code from Brian White @mscdex mariasql library - https://github.com/mscdex/node-mariasql/blob/master/lib/Client.js#L272-L332
// License: https://github.com/mscdex/node-mariasql/blob/master/LICENSE

const RE_PARAM = /(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_]*)))/g,
const RE_PARAM = /(?:\?)|(?::(\d+|(?:[a-zA-Z][a-zA-Z0-9_\.]*)))/g,
DQUOTE = 34,
SQUOTE = 39,
BSLASH = 92;
Expand Down
269 changes: 269 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ describe('given input query with named parameters', () => {
compile(query, { id: Number(123) })
.should.eql([ 'SELECT * FROM items WHERE deleted = "0000-00-00 00:00:00" AND id = ?',
[ 123 ] ]);

query = 'SELECT * FROM items WHERE deleted = "0000-00-00 00:00:00" AND `dot.id` = :dot.id';
compile(query, { 'dot.id': Number(123) })
.should.eql([ 'SELECT * FROM items WHERE deleted = "0000-00-00 00:00:00" AND `dot.id` = ?',
[ 123 ] ]);
});

it('should throw error when query contains placeholders but parameters object not passed', () => {
Expand Down

0 comments on commit 8363a74

Please sign in to comment.