File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ var CHARS_ESCAPE_MAP = {
1414 '\'' : '\\\'' ,
1515 '\\' : '\\\\'
1616} ;
17- var ONE_ID_PATTERN = '^ `(?:[^`]|``)+`$ ' ; // TODO(mikesamuel): Should allow ``?
17+ var ONE_ID_PATTERN = '`(?:[^`]|``)+`' ; // TODO(mikesamuel): Should allow ``?
1818// One or more Identifiers separated by dots.
1919var QUALIFIED_ID_REGEXP = new RegExp (
2020 '^' + ONE_ID_PATTERN + '(?:[.]' + ONE_ID_PATTERN + ')*$' ) ;
Original file line number Diff line number Diff line change @@ -259,9 +259,18 @@ test('SqlString.format', {
259259
260260 'double quest marks passes pre-escaped id' : function ( ) {
261261 var sql = SqlString . format (
262- 'SELECT * FROM ?? WHERE id = ?' ,
263- [ SqlString . identifier ( 'table' ) , 42 ] ) ;
264- assert . equal ( sql , 'SELECT * FROM `table` WHERE id = 42' ) ;
262+ 'SELECT ?? FROM ?? WHERE id = ?' ,
263+ [ SqlString . identifier ( 'table.id' ) ,
264+ SqlString . identifier ( 'table' ) , 42 ] ) ;
265+ assert . equal ( sql , 'SELECT `table`.`id` FROM `table` WHERE id = 42' ) ;
266+ } ,
267+
268+ 'double quest marks rejects invalid raw' : function ( ) {
269+ assert . throws ( function ( ) {
270+ SqlString . format (
271+ 'SELECT * FROM ?? WHERE id = 42' ,
272+ [ SqlString . raw ( 'NOW()' ) ] ) ;
273+ } ) ;
265274 } ,
266275
267276 'extra question marks are left untouched' : function ( ) {
You can’t perform that action at this time.
0 commit comments