Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#14 - Add '.' to RE_PARAM #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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