@@ -178,34 +178,99 @@ describe('40. dataTypeClob.js', function() {
178178 const sqlCreateQuery = `
179179 CREATE TABLE ${ tableNameCLOB } (
180180 num NUMBER,
181+ value varchar2(255),
181182 content CLOB
182183 )` ;
183184 const sqlDrop = testsUtil . sqlDropTable ( tableNameCLOB ) ;
184185 const sqlCreate = testsUtil . sqlCreateTable ( tableNameCLOB , sqlCreateQuery ) ;
185- const insertSql = `INSERT INTO ${ tableNameCLOB } (num, content) ` +
186- `VALUES (:n, 'CLOB')` ;
187- const selectSql = `SELECT content FROM ${ tableNameCLOB } WHERE num = 1` ;
188-
189- before ( async function ( ) {
190- oracledb . fetchAsString = [ oracledb . CLOB ] ;
186+ const insertSql = `INSERT INTO ${ tableNameCLOB } (num, value, content) ` +
187+ `VALUES (:n, :val, 'CLOB')` ;
188+ const selectSqlCharBind = `SELECT * FROM ${ tableNameCLOB } WHERE value = :val` ;
189+ const binds = [
190+ { n : 1 , val : 'GEN_COL' } ,
191+ { n : 2 , val : 'GEN_COL_NEW' }
192+ ] ;
193+
194+ async function setupConnAndTable ( ) {
191195 connection = await oracledb . getConnection ( dbConfig ) ;
192196 await connection . execute ( sqlCreate ) ;
193- await connection . execute ( insertSql , { n : 1 } , { autoCommit : false } ) ;
197+ await connection . executeMany ( insertSql , binds ) ;
198+ }
199+
200+ async function doFirstSelect ( ) {
201+ await connection . execute ( selectSqlCharBind , { val :'GEN_COL' } , { keepInStmtCache : true } ) ;
202+ await connection . execute ( sqlDrop ) ;
203+ await connection . execute ( sqlCreate ) ;
204+ await connection . executeMany ( insertSql , binds ) ;
205+ }
206+
207+ afterEach ( async function ( ) {
208+ if ( connection ) {
209+ await connection . execute ( sqlDrop ) ;
210+ await connection . close ( ) ;
211+ connection = null ;
212+ }
194213 } ) ;
195214
196215 after ( async function ( ) {
197216 oracledb . fetchAsString = [ ] ;
198- await connection . execute ( sqlDrop ) ;
199- await connection . close ( ) ;
217+ if ( connection ) {
218+ await connection . execute ( sqlDrop ) ;
219+ await connection . close ( ) ;
220+ }
200221 } ) ;
201222
202- it ( '40.3.1 Recreate table after CLOB column is read and statement is in statement cache' ,
223+ it ( '40.3.1 Recreate table after CLOB column as CLOB is read and statement is in statement cache' ,
224+ async function ( ) {
225+ oracledb . fetchAsString = [ ] ;
226+ await setupConnAndTable ( ) ;
227+ await doFirstSelect ( ) ;
228+ await connection . execute ( selectSqlCharBind , { val :'GEN_COL' } ) ;
229+ } ) ;
230+
231+ it ( '40.3.2 Recreate table after CLOB column as String is read and statement is in statement cache' ,
203232 async function ( ) {
204- await connection . execute ( selectSql , { } , { keepInStmtCache : true } ) ;
233+ oracledb . fetchAsString = [ oracledb . CLOB ] ;
234+ await setupConnAndTable ( ) ;
235+ await doFirstSelect ( ) ;
236+ await connection . execute ( selectSqlCharBind , { val :'GEN_COL' } ) ;
237+ } ) ;
238+
239+ it ( '40.3.3 select with large bindvalue than previous select bindvalue after Recreate table ' ,
240+ async function ( ) {
241+ oracledb . fetchAsString = [ oracledb . CLOB ] ;
242+ await setupConnAndTable ( ) ;
243+ await doFirstSelect ( ) ;
244+ // provide bind value 'GEN_COL_NEW' larger than earlier bind value 'GEN_COL'.
245+ await connection . execute ( selectSqlCharBind , { val :'GEN_COL_NEW' } ) ;
246+ } ) ;
247+
248+ it ( '40.3.4 select using fetchAsCLOB with large bindvalue than previous select bindvalue after Recreate table ' ,
249+ async function ( ) {
250+ oracledb . fetchAsString = [ ] ;
251+ await setupConnAndTable ( ) ;
252+ await doFirstSelect ( ) ;
253+ // provide bind value 'GEN_COL_NEW' larger than earlier bind value 'GEN_COL'.
254+ await connection . execute ( selectSqlCharBind , { val :'GEN_COL_NEW' } ) ;
255+ } ) ;
256+
257+ it ( '40.3.5 select using fetchAsCLOB with large bindvalue than previous select bindvalue after Recreate table twice' ,
258+ async function ( ) {
259+ oracledb . fetchAsString = [ oracledb . CLOB ] ;
260+ await setupConnAndTable ( ) ;
261+ await doFirstSelect ( ) ;
262+ // provide bind value 'GEN_COL_NEW' larger than earlier bind value 'GEN_COL'.
263+ await connection . execute ( selectSqlCharBind , { val :'GEN_COL_NEW' } ) ;
264+
265+ // cleanup the connection
205266 await connection . execute ( sqlDrop ) ;
206- await connection . execute ( sqlCreate ) ;
207- await connection . execute ( insertSql , { n : 1 } , { autoCommit : false } ) ;
208- await connection . execute ( selectSql ) ;
267+ await connection . close ( ) ;
268+ connection = null ;
269+
270+ await setupConnAndTable ( ) ;
271+ await doFirstSelect ( ) ;
272+ // provide bind value 'GEN_COL_NEW' larger than earlier bind value 'GEN_COL'.
273+ await connection . execute ( selectSqlCharBind , { val :'GEN_COL_NEW' } ) ;
209274 } ) ;
210275
211276 } ) ;
0 commit comments