@@ -45,7 +45,6 @@ describe('4. binding.js', function() {
45
45
let connection = null ;
46
46
before ( async function ( ) {
47
47
connection = await oracledb . getConnection ( dbConfig ) ;
48
- assert ( connection ) ;
49
48
} ) ;
50
49
51
50
after ( async function ( ) {
@@ -58,7 +57,6 @@ describe('4. binding.js', function() {
58
57
BEGIN \
59
58
p_out := 'abcdef'; \
60
59
END;" ;
61
- assert ( connection ) ;
62
60
await connection . execute ( proc ) ;
63
61
let result = await connection . execute ( "BEGIN nodb_bindproc1(:o); END;" ,
64
62
{
@@ -86,7 +84,6 @@ describe('4. binding.js', function() {
86
84
BEGIN \
87
85
p_out := 10010; \
88
86
END;" ;
89
- assert ( connection ) ;
90
87
await connection . execute ( proc ) ;
91
88
let result = await connection . execute (
92
89
"BEGIN nodb_bindproc2(:o); END;" ,
@@ -113,7 +110,6 @@ describe('4. binding.js', function() {
113
110
p_inout := p_in || ' ' || p_inout; \
114
111
p_out := 101; \
115
112
END; " ;
116
- assert ( connection ) ;
117
113
await connection . execute ( proc ) ;
118
114
let result = await connection . execute (
119
115
"BEGIN nodb_bindproc3(:i, :io, :o); END;" ,
@@ -145,7 +141,6 @@ describe('4. binding.js', function() {
145
141
p_inout := p_in || ' ' || p_inout; \
146
142
p_out := 101; \
147
143
END; " ;
148
- assert ( connection ) ;
149
144
await connection . execute ( proc ) ;
150
145
let result = await connection . execute (
151
146
"BEGIN nodb_bindproc4(:io, :o, :i); END;" ,
@@ -169,7 +164,6 @@ describe('4. binding.js', function() {
169
164
} ) ;
170
165
171
166
it ( '4.1.5 default bind type - STRING' , async function ( ) {
172
- assert ( connection ) ;
173
167
const sql = "begin :n := 1001; end;" ;
174
168
const bindVar = { n : { dir : oracledb . BIND_OUT } } ;
175
169
let options = { } ;
@@ -211,7 +205,6 @@ describe('4. binding.js', function() {
211
205
} ) ;
212
206
213
207
afterEach ( async function ( ) {
214
- assert ( connection ) ;
215
208
await connection . execute ( "DROP TABLE nodb_binding1 PURGE" ) ;
216
209
await connection . close ( ) ;
217
210
} ) ;
@@ -386,7 +379,7 @@ describe('4. binding.js', function() {
386
379
387
380
describe ( '4.3 insert with DATE column and DML returning' , function ( ) {
388
381
let connection = null ;
389
- let createTable =
382
+ const createTable =
390
383
"BEGIN \
391
384
DECLARE \
392
385
e_table_missing EXCEPTION; \
@@ -412,7 +405,6 @@ describe('4. binding.js', function() {
412
405
} ) ;
413
406
414
407
afterEach ( async function ( ) {
415
- assert ( connection ) ;
416
408
await connection . execute ( "DROP TABLE nodb_binding2 PURGE" ) ;
417
409
await connection . close ( ) ;
418
410
} ) ;
@@ -477,7 +469,6 @@ describe('4. binding.js', function() {
477
469
BEGIN \
478
470
p_out := 'ABCDEF GHIJK LMNOP QRSTU'; \
479
471
END;" ;
480
- assert ( connection ) ;
481
472
await connection . execute ( proc ) ;
482
473
await assert . rejects (
483
474
async ( ) => {
@@ -543,7 +534,6 @@ describe('4. binding.js', function() {
543
534
await connection . close ( ) ;
544
535
} ) ;
545
536
546
-
547
537
it ( '4.5.1 DML default bind' , async function ( ) {
548
538
await connection . execute (
549
539
"insert into nodb_raw (num) values (:id)" ,
@@ -572,90 +562,87 @@ describe('4. binding.js', function() {
572
562
+ "if sqlcode <> -942 then "
573
563
+ "raise; "
574
564
+ "end if; end;" ;
575
- const binds = [ ] ;
576
- let options = { } ;
577
-
578
- const connect = await oracledb . getConnection ( dbConfig ) ;
579
- let result = await connect . execute ( sql , binds , options ) ;
565
+ const connection = await oracledb . getConnection ( dbConfig ) ;
566
+ const result = await connection . execute ( sql ) ;
580
567
assert . deepStrictEqual ( result , { } ) ;
568
+ await connection . close ( ) ;
581
569
} ) ;
582
570
} ) ;
583
571
584
572
// Test cases involving JSON value as input
585
573
describe ( '4.7 Value as JSON named/unamed test cases' , function ( ) {
574
+ let connection ;
575
+
576
+ before ( async function ( ) {
577
+ connection = await oracledb . getConnection ( dbConfig ) ;
578
+ } ) ;
579
+
580
+ after ( async function ( ) {
581
+ await connection . close ( ) ;
582
+ } ) ;
583
+
586
584
it ( '4.7.1 valid case when numeric values are passed as it is' ,
587
585
async function ( ) {
588
586
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
589
587
const binds = [ 1 , 456 ] ;
590
- let connect = await oracledb . getConnection ( dbConfig ) ;
591
- let result = await connect . execute ( sql , binds ) ;
588
+ const result = await connection . execute ( sql , binds ) ;
592
589
assert ( ( result . rows [ 0 ] [ 0 ] ) instanceof Date ) ;
593
590
} ) ;
594
591
595
592
it ( '4.7.2 Valid values when one of the value is passed as JSON ' ,
596
593
async function ( ) {
597
594
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
598
595
const binds = [ 1 , { val : 456 } ] ;
599
-
600
- let connect = await oracledb . getConnection ( dbConfig ) ;
601
- let result = await connect . execute ( sql , binds ) ;
596
+ const result = await connection . execute ( sql , binds ) ;
602
597
assert ( ( result . rows [ 0 ] [ 0 ] ) instanceof Date ) ;
603
598
} ) ;
604
599
605
600
it ( '4.7.3 Valid test case when one of the value is passed as JSON ' ,
606
601
async function ( ) {
607
602
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
608
603
const binds = [ { val : 1 } , 456 ] ;
609
- let connect = await oracledb . getConnection ( dbConfig ) ;
610
- let result = await connect . execute ( sql , binds ) ;
604
+ const result = await connection . execute ( sql , binds ) ;
611
605
assert ( ( result . rows [ 0 ] [ 0 ] ) instanceof Date ) ;
612
606
} ) ;
613
607
614
608
it ( '4.7.4 Valid Test case when both values are passed as JSON' ,
615
609
async function ( ) {
616
610
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
617
611
const binds = [ { val : 1 } , { val : 456 } ] ;
618
-
619
- let connect = await oracledb . getConnection ( dbConfig ) ;
620
- const result = await connect . execute ( sql , binds ) ;
612
+ const result = await connection . execute ( sql , binds ) ;
621
613
assert ( ( result . rows [ 0 ] [ 0 ] ) instanceof Date ) ;
622
614
} ) ;
623
615
624
616
it ( '4.7.5 Invalid Test case when value is passed as named JSON' ,
625
617
async function ( ) {
626
618
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
627
619
const binds = [ { val : 1 } , { c : { val : 456 } } ] ;
628
- let connect = await oracledb . getConnection ( dbConfig ) ;
629
620
await assert . rejects (
630
- async ( ) => await connect . execute ( sql , binds ) ,
621
+ async ( ) => await connection . execute ( sql , binds ) ,
631
622
/ N J S - 0 4 4 : /
632
623
) ;
633
-
634
624
} ) ;
635
625
636
626
it ( '4.7.6 Invalid Test case when other-value is passed as named JSON' ,
637
627
async function ( ) {
638
628
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
639
629
const binds = [ { b : { val : 1 } } , { val : 456 } ] ;
640
- let connect = await oracledb . getConnection ( dbConfig ) ;
641
630
await assert . rejects (
642
- async ( ) => await connect . execute ( sql , binds ) ,
631
+ async ( ) => await connection . execute ( sql , binds ) ,
643
632
/ N J S - 0 4 4 : /
644
633
) ;
645
-
646
634
} ) ;
647
635
648
636
it ( '4.7.7 Invalid Test case when all values is passed as named JSON' ,
649
637
async function ( ) {
650
638
const sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
651
639
const binds = [ { b : { val : 1 } } , { c : { val : 456 } } ] ;
652
- let connect = await oracledb . getConnection ( dbConfig ) ;
653
640
await assert . rejects (
654
- async ( ) => await connect . execute ( sql , binds ) ,
641
+ async ( ) => await connection . execute ( sql , binds ) ,
655
642
/ N J S - 0 4 4 : /
656
643
) ;
657
-
658
644
} ) ; // 4.7.7
645
+
659
646
} ) ; // 4.7
660
647
661
648
describe ( '4.8 bind DATE' , function ( ) {
@@ -763,44 +750,44 @@ describe('4. binding.js', function() {
763
750
} ) ; // 4.8
764
751
765
752
describe ( '4.9 different placeholders for bind name' , function ( ) {
753
+ let connection ;
754
+
755
+ before ( async function ( ) {
756
+ connection = await oracledb . getConnection ( dbConfig ) ;
757
+ } ) ;
758
+
759
+ after ( async function ( ) {
760
+ await connection . close ( ) ;
761
+ } ) ;
766
762
767
763
it ( '4.9.1 test case sensitivity of quoted bind names' , async function ( ) {
768
764
const sql = 'select :"test" from dual' ;
769
765
const binds = { '"test"' : 1 } ;
770
-
771
- const connect = await oracledb . getConnection ( dbConfig ) ;
772
- const result = await connect . execute ( sql , binds ) ;
766
+ const result = await connection . execute ( sql , binds ) ;
773
767
assert ( ( result . rows [ 0 ] [ 0 ] ) , 1 ) ;
774
- await connect . release ( ) ;
775
768
} ) ;
776
769
777
770
it ( '4.9.2 using a reserved keyword as a bind name' , async function ( ) {
778
771
const sql = 'select :ROWID from dual' ;
779
-
780
- const connect = await oracledb . getConnection ( dbConfig ) ;
781
772
await assert . rejects (
782
773
async ( ) => {
783
- await connect . execute ( sql , { ROWID :1 } ) ;
774
+ await connection . execute ( sql , { ROWID :1 } ) ;
784
775
} ,
785
776
//NJS-098: 1 positional bind values are required but 0 were provided
786
777
/ O R A - 0 1 7 4 5 : | N J S - 0 9 8 : /
787
778
) ;
788
- await connect . release ( ) ;
789
779
} ) ;
790
780
791
781
it ( '4.9.3 not using a bind name in execute statement' , async function ( ) {
792
782
const sql = 'select :val from dual' ;
793
-
794
- const connect = await oracledb . getConnection ( dbConfig ) ;
795
783
await assert . rejects (
796
784
async ( ) => {
797
- await connect . execute ( sql ) ;
785
+ await connection . execute ( sql ) ;
798
786
} ,
799
787
//ORA-01008: not all variables bound
800
788
//NJS-098: 1 positional bind values are required but 0 were provided
801
789
/ O R A - 0 1 0 0 8 : | N J S - 0 9 8 : /
802
790
) ;
803
- await connect . release ( ) ;
804
791
} ) ;
805
792
} ) ; // 4.9
806
793
@@ -810,16 +797,16 @@ describe('4. binding.js', function() {
810
797
const sql = 'SELECT :"percent%" FROM DUAL' ;
811
798
const binds = { percent : "percent%" } ;
812
799
813
- const connect = await oracledb . getConnection ( dbConfig ) ;
800
+ const connection = await oracledb . getConnection ( dbConfig ) ;
814
801
await assert . rejects (
815
802
async ( ) => {
816
- await connect . execute ( sql , binds ) ;
803
+ await connection . execute ( sql , binds ) ;
817
804
} ,
818
805
//ORA-01036: illegal variable name/number
819
806
//NJS-097: no bind placeholder named: :PERCENT was found in the SQL text
820
807
/ O R A - 0 1 0 3 6 : | N J S - 0 9 7 : /
821
808
) ;
822
- await connect . release ( ) ;
809
+ await connection . release ( ) ;
823
810
} ) ;
824
811
} ) ;
825
812
0 commit comments