@@ -365,9 +365,110 @@ describe('162. getStmtInfo.js', function() {
365365 'OBJECT_GRANT_AS_GRANTOR',
366366 :schema_name_in
367367 from dual` ;
368- const connection = await oracledb . getConnection ( dbConfig ) ;
369- const info = await connection . getStatementInfo ( sql ) ;
368+ const info = await conn . getStatementInfo ( sql ) ;
370369 assert . deepStrictEqual ( info . bindNames , [ 'ÖOBJECT_NAME_IN' , 'SCHEMA_NAME_IN' ] ) ;
371- await connection . close ( ) ;
372370 } ) ; // 162.28
371+
372+ it ( '162.29 Ignore multiple single line comments having : in sql' , async function ( ) {
373+ // Issue 1561
374+ const sql = `select
375+ 1
376+ from
377+ -- :
378+ dual
379+ where
380+ -- :
381+ 1=1` ;
382+ const info = await conn . getStatementInfo ( sql ) ;
383+ assert . deepStrictEqual ( info . bindNames , [ ] ) ;
384+ const result = await conn . execute ( sql ) ;
385+ assert . deepStrictEqual ( result . rows [ 0 ] , [ 1 ] ) ;
386+ } ) ;
387+
388+ it ( '162.30 Ignore multiple single and multi line comments having : in sql' , async function ( ) {
389+ const sql = `select
390+ 1
391+ from
392+ -- :
393+ /* adding
394+ multi line comments :1 */
395+ dual
396+ where
397+ /* adding :bind */
398+ -- :
399+ 1=1` ;
400+ const info = await conn . getStatementInfo ( sql ) ;
401+ assert . deepStrictEqual ( info . bindNames , [ ] ) ;
402+ const result = await conn . execute ( sql ) ;
403+ assert . deepStrictEqual ( result . rows [ 0 ] , [ 1 ] ) ;
404+ } ) ;
405+
406+ it ( '162.31 Multiple single line comments with binds before the comment in sql' , async function ( ) {
407+ const sql = `select
408+ -- :
409+ :1 -- :
410+ -- :
411+ from
412+ -- :
413+ dual
414+ where
415+ -- :
416+ 1=1` ;
417+ const info = await conn . getStatementInfo ( sql ) ;
418+ assert . deepStrictEqual ( info . bindNames , [ '1' ] ) ;
419+ const result = await conn . execute ( sql , [ 1 ] ) ;
420+ assert . deepStrictEqual ( result . rows [ 0 ] , [ 1 ] ) ;
421+ } ) ;
422+
423+ it ( '162.32 Multiple single line comments with binds after the comment in sql' , async function ( ) {
424+ const sql = `select
425+ -- :
426+ -- :
427+ :1
428+ -- :
429+ from
430+ -- :
431+ dual
432+ where
433+ -- :
434+ 1=1` ;
435+ const info = await conn . getStatementInfo ( sql ) ;
436+ assert . deepStrictEqual ( info . bindNames , [ '1' ] ) ;
437+ const result = await conn . execute ( sql , [ 1 ] ) ;
438+ assert . deepStrictEqual ( result . rows [ 0 ] , [ 1 ] ) ;
439+ } ) ;
440+
441+ it ( '162.33 Bind Variable before, inbetween and after comments in sql' , async function ( ) {
442+ const sql = `select
443+ :1,
444+ -- :
445+ :2
446+ -- :
447+ from
448+ -- :
449+ dual
450+ where
451+ -- :
452+ :3=1` ;
453+ const info = await conn . getStatementInfo ( sql ) ;
454+ assert . deepStrictEqual ( info . bindNames , [ '1' , '2' , '3' ] ) ;
455+ const result = await conn . execute ( sql , [ 1 , 1 , 1 ] ) ;
456+ assert . deepStrictEqual ( result . rows [ 0 ] , [ 1 , 1 ] ) ;
457+ } ) ;
458+
459+ it ( '162.34 ignore literals only during bind processing' , async function ( ) {
460+ const sql = `select 'HELLO' from
461+ -- :
462+ /* adding
463+ multi line comments :1 */
464+ dual
465+ where
466+ /* adding :bind */
467+ 1=1` ;
468+ const info = await conn . getStatementInfo ( sql ) ;
469+ assert . deepStrictEqual ( info . bindNames , [ ] ) ;
470+ const result = await conn . execute ( sql ) ;
471+ assert . deepStrictEqual ( result . rows [ 0 ] , [ 'HELLO' ] ) ;
472+ } ) ;
473+
373474} ) ;
0 commit comments