@@ -1119,4 +1119,72 @@ describe('4. binding.js', function() {
11191119 }
11201120 } ) ;
11211121 } ) ;
1122+
1123+ describe ( '4.15 binding different data types for same sql' , function ( ) {
1124+ let connection ;
1125+ let sysDBAConn ;
1126+ let sid ;
1127+ const numIters = 40 ;
1128+
1129+ before ( async function ( ) {
1130+ if ( ! dbConfig . test . DBA_PRIVILEGE ) this . skip ( ) ;
1131+ const dbaConfig = {
1132+ user : dbConfig . test . DBA_user ,
1133+ password : dbConfig . test . DBA_password ,
1134+ connectionString : dbConfig . connectString ,
1135+ privilege : oracledb . SYSDBA
1136+ } ;
1137+ sysDBAConn = await oracledb . getConnection ( dbaConfig ) ;
1138+ connection = await oracledb . getConnection ( dbConfig ) ;
1139+ sid = await testsUtil . getSid ( connection ) ;
1140+ } ) ;
1141+
1142+ after ( async function ( ) {
1143+ if ( connection ) {
1144+ await connection . close ( ) ;
1145+ }
1146+ if ( sysDBAConn ) {
1147+ await sysDBAConn . close ( ) ;
1148+ }
1149+ } ) ;
1150+
1151+ it ( '4.15.1 change bindtypes using bindByPosition for queries' ,
1152+ async function ( ) {
1153+ const sql = 'SELECT :1 FROM DUAL' ;
1154+ const dt = new Date ( ) ;
1155+ const openCount = await testsUtil . getOpenCursorCount ( sysDBAConn , sid ) ;
1156+ for ( let i = 0 ; i < numIters ; i ++ ) {
1157+ let result = await connection . execute ( sql , [ 1 ] ) ;
1158+ assert . strictEqual ( result . rows [ 0 ] [ 0 ] , 1 ) ;
1159+ result = await connection . execute ( sql , [ dt ] ) ;
1160+ assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , dt ) ;
1161+ result = await connection . execute ( sql , [ 2 ] ) ;
1162+ assert . strictEqual ( result . rows [ 0 ] [ 0 ] , 2 ) ;
1163+ }
1164+ const newOpenCount = await testsUtil .
1165+ getOpenCursorCount ( sysDBAConn , sid ) ;
1166+
1167+ // ensure cursors are not linearly opened as numIters causing leak.
1168+ assert ( newOpenCount - openCount < 4 ) ;
1169+ } ) ;
1170+
1171+ it ( '4.15.2 change bindtypes using bindByName for queries' ,
1172+ async function ( ) {
1173+ const sql = 'SELECT :x FROM DUAL' ;
1174+ const openCount = await testsUtil . getOpenCursorCount ( sysDBAConn , sid ) ;
1175+ const dt = new Date ( ) ;
1176+ for ( let i = 0 ; i < numIters ; i ++ ) {
1177+ let result = await connection . execute ( sql , { x : 1 } ) ;
1178+ assert . strictEqual ( result . rows [ 0 ] [ 0 ] , 1 ) ;
1179+ result = await connection . execute ( sql , { x : dt } ) ;
1180+ assert . deepStrictEqual ( result . rows [ 0 ] [ 0 ] , dt ) ;
1181+ result = await connection . execute ( sql , { x : 2 } ) ;
1182+ assert . strictEqual ( result . rows [ 0 ] [ 0 ] , 2 ) ;
1183+ }
1184+ const newOpenCount = await testsUtil . getOpenCursorCount ( sysDBAConn , sid ) ;
1185+
1186+ // ensure cursors are not linearly opened as numIters causing leak.
1187+ assert ( newOpenCount - openCount < 4 ) ;
1188+ } ) ;
1189+ } ) ;
11221190} ) ;
0 commit comments