@@ -26,15 +26,30 @@ test('template tag', {
2626 ( ) => sql `SELECT ${ 1 + 1 } ` ) ;
2727 } ,
2828 'date' : function ( ) {
29+ const date = new Date ( Date . UTC ( 2000 , 0 , 1 , 0 , 0 , 0 ) ) ;
2930 runTagTest (
3031 `SELECT '2000-01-01 00:00:00.000'` ,
31- ( ) => sql ( { timeZone : 'GMT' } ) `SELECT ${ new Date ( Date . UTC ( 2000 , 0 , 1 , 0 , 0 , 0 ) ) } ` ) ;
32+ ( ) => sql ( { timeZone : 'GMT' } ) `SELECT ${ date } ` ) ;
3233 } ,
3334 'string' : function ( ) {
3435 runTagTest (
3536 `SELECT 'Hello, World!\\n'` ,
3637 ( ) => sql `SELECT ${ 'Hello, World!\n' } ` ) ;
3738 } ,
39+ 'stringify' : function ( ) {
40+ const obj = {
41+ 'Hello' : 'World!' ,
42+ toString : function ( ) {
43+ return 'Hello, World!' ;
44+ }
45+ } ;
46+ runTagTest (
47+ `SELECT 'Hello, World!'` ,
48+ ( ) => sql ( { stringifyObjects : true } ) `SELECT ${ obj } ` ) ;
49+ runTagTest (
50+ 'SELECT * FROM t WHERE `Hello` = \'World!\'' ,
51+ ( ) => sql ( { stringifyObjects : false } ) `SELECT * FROM t WHERE ${ obj } ` ) ;
52+ } ,
3853 'identifier' : function ( ) {
3954 runTagTest (
4055 'SELECT `foo`' ,
@@ -139,4 +154,7 @@ test('template tag', {
139154 // See comments in lib/es6/Lexer.js.
140155 assert . throws ( ( ) => sql `SELECT (${ 0 } ) -- comment` ) ;
141156 }
157+
158+ // TODO: is there a token-merging hazard in sql`SELECT 'x'${'y'}`?
159+ // A literal ' shows up in the decoded output of a single string literal.
142160} ) ;
0 commit comments