@@ -487,7 +487,7 @@ describe('173. soda5.js', () => {
487487 await dropIdxOpt ( options ) ;
488488 } ) ; // 173.11
489489
490- it ( '173.12 getDataGiuide (), basic case' , async ( ) => {
490+ it ( '173.12 getDataGuide (), basic case' , async ( ) => {
491491
492492 let conn , collection ;
493493
@@ -512,54 +512,50 @@ describe('173. soda5.js', () => {
512512 should . not . exist ( err ) ;
513513 }
514514
515- let compatibleVersion ;
516- if ( dbconfig . test . DBA_PRIVILEGE ) {
517- try {
518- const connectionDetails = {
519- user : dbconfig . test . DBA_user ,
520- password : dbconfig . test . DBA_password ,
521- connectString : dbconfig . connectString ,
522- privilege : oracledb . SYSDBA ,
523- } ;
524- let conn = await oracledb . getConnection ( connectionDetails ) ;
525- let res = await conn . execute ( "select name, value from v$parameter where name like lower('%'||:x||'%')" , [ 'COMPATIBLE' ] ) ;
526- if ( res . rows . length > 0 ) {
527- compatibleVersion = res . rows [ 0 ] [ 1 ] ;
528- }
529- await conn . close ( ) ;
530- } catch ( err ) {
531- should . not . exist ( err ) ;
532- }
533- }
534- const isCreateIndexEnabled = sodaUtil . versionStringCompare ( compatibleVersion , '12.2.0.0.0' ) ;
515+ /*
516+ * if isCreateIndexEligible >= 0: Can Create Index without error
517+ * if isCreateIndexEligible < 0: Create Index will throw error ORA-00406
518+ * if isCreateIndexEligible = undefined: Getting COMPATIBLE VERSION string failed, the following part is skipped
519+ */
520+ const isCreateIndexEligible = testsUtil . versionStringCompare ( await testsUtil . getDBCompatibleVersion ( ) , '12.2.0.0.0' ) ;
535521 try {
536522 let indexSpec = {
537523 "name" : "TEST_IDX" ,
538524 "search_on" : "none" ,
539525 "dataguide" : "on"
540526 } ;
541- if ( isCreateIndexEnabled >= 0 ) {
527+ if ( isCreateIndexEligible >= 0 ) {
542528 await collection . createIndex ( indexSpec ) ;
543529 let outDocument = await collection . getDataGuide ( ) ;
544530 should . exist ( outDocument ) ;
545- } else if ( isCreateIndexEnabled < 0 ) {
531+ } else if ( isCreateIndexEligible < 0 ) {
546532 await testsUtil . assertThrowsAsync ( async ( ) => { await collection . createIndex ( indexSpec ) ; } , / O R A - 0 0 4 0 6 : / ) ;
547533 }
548534 } catch ( err ) {
549535 should . not . exist ( err ) ;
550536 }
551- if ( isCreateIndexEnabled >= 0 ) {
537+
538+ if ( isCreateIndexEligible >= 0 ) {
552539 try {
553540 let result = await collection . dropIndex ( 'TEST_IDX' ) ;
554541 should . strictEqual ( result . dropped , true ) ;
555542 await conn . commit ( ) ;
556- await collection . drop ( ) ;
557- await conn . close ( ) ;
558543 } catch ( err ) {
559544 should . not . exist ( err ) ;
560545 }
561546 }
562547
548+ try {
549+ if ( collection ) await collection . drop ( ) ;
550+ } catch ( err ) {
551+ should . not . exist ( err ) ;
552+ }
553+ try {
554+ if ( conn ) await conn . close ( ) ;
555+ } catch ( err ) {
556+ should . not . exist ( err ) ;
557+ }
558+
563559 } ) ; // 173.12
564560
565561} ) ;
0 commit comments