@@ -43,17 +43,11 @@ var assist = require('./dataTypeAssist.js');
43
43
44
44
describe ( '4. binding.js' , function ( ) {
45
45
46
- var credentials = {
47
- user : dbConfig . user ,
48
- password : dbConfig . password ,
49
- connectString : dbConfig . connectString
50
- } ;
51
-
52
46
describe ( '4.1 test STRING, NUMBER, ARRAY & JSON format' , function ( ) {
53
47
54
48
var connection = null ;
55
49
before ( function ( done ) {
56
- oracledb . getConnection ( credentials , function ( err , conn ) {
50
+ oracledb . getConnection ( dbConfig , function ( err , conn ) {
57
51
if ( err ) { console . error ( err . message ) ; return ; }
58
52
connection = conn ;
59
53
done ( ) ;
@@ -179,7 +173,7 @@ describe('4. binding.js', function() {
179
173
) ;
180
174
}
181
175
] , done ) ;
182
- } )
176
+ } ) ; // 4.1.2
183
177
184
178
it ( '4.1.3 Multiple binding values, Object & Array formats' , function ( done ) {
185
179
async . series ( [
@@ -353,7 +347,7 @@ describe('4. binding.js', function() {
353
347
var options = { autoCommit : true , outFormat : oracledb . OBJECT } ;
354
348
355
349
beforeEach ( function ( done ) {
356
- oracledb . getConnection ( credentials , function ( err , conn ) {
350
+ oracledb . getConnection ( dbConfig , function ( err , conn ) {
357
351
should . not . exist ( err ) ;
358
352
connection = conn ;
359
353
conn . execute (
@@ -454,7 +448,7 @@ describe('4. binding.js', function() {
454
448
END; " ;
455
449
456
450
beforeEach ( function ( done ) {
457
- oracledb . getConnection ( credentials , function ( err , conn ) {
451
+ oracledb . getConnection ( dbConfig , function ( err , conn ) {
458
452
should . not . exist ( err ) ;
459
453
connection = conn ;
460
454
conn . execute (
@@ -589,7 +583,7 @@ describe('4. binding.js', function() {
589
583
var connection = null ;
590
584
591
585
before ( function ( done ) {
592
- oracledb . getConnection ( credentials , function ( err , conn ) {
586
+ oracledb . getConnection ( dbConfig , function ( err , conn ) {
593
587
if ( err ) { console . error ( err . message ) ; return ; }
594
588
connection = conn ;
595
589
done ( ) ;
@@ -705,7 +699,7 @@ describe('4. binding.js', function() {
705
699
var tableName = "nodb_raw" ;
706
700
707
701
before ( function ( done ) {
708
- oracledb . getConnection ( credentials , function ( err , conn ) {
702
+ oracledb . getConnection ( dbConfig , function ( err , conn ) {
709
703
if ( err ) { console . error ( err . message ) ; return ; }
710
704
connection = conn ;
711
705
assist . createTable ( connection , tableName , done ) ;
@@ -758,7 +752,7 @@ describe('4. binding.js', function() {
758
752
var options = { } ;
759
753
760
754
oracledb . getConnection (
761
- credentials ,
755
+ dbConfig ,
762
756
function ( err , connection )
763
757
{
764
758
should . not . exist ( err ) ;
@@ -792,7 +786,7 @@ describe('4. binding.js', function() {
792
786
var binds = [ 1 , 456 ] ;
793
787
794
788
oracledb . getConnection (
795
- credentials ,
789
+ dbConfig ,
796
790
function ( err , connection ) {
797
791
798
792
should . not . exist ( err ) ;
@@ -814,7 +808,7 @@ describe('4. binding.js', function() {
814
808
var binds = [ 1 , { val : 456 } ] ;
815
809
816
810
oracledb . getConnection (
817
- credentials ,
811
+ dbConfig ,
818
812
function ( err , connection ) {
819
813
820
814
should . not . exist ( err ) ;
@@ -835,7 +829,7 @@ describe('4. binding.js', function() {
835
829
var binds = [ { val : 1 } , 456 ] ;
836
830
837
831
oracledb . getConnection (
838
- credentials ,
832
+ dbConfig ,
839
833
function ( err , connection ) {
840
834
841
835
should . not . exist ( err ) ;
@@ -856,7 +850,7 @@ describe('4. binding.js', function() {
856
850
var binds = [ { val : 1 } , { val : 456 } ] ;
857
851
858
852
oracledb . getConnection (
859
- credentials ,
853
+ dbConfig ,
860
854
function ( err , connection ) {
861
855
862
856
should . not . exist ( err ) ;
@@ -877,7 +871,7 @@ describe('4. binding.js', function() {
877
871
var binds = [ { val : 1 } , { c : { val : 456 } } ] ;
878
872
879
873
oracledb . getConnection (
880
- credentials ,
874
+ dbConfig ,
881
875
function ( err , connection ) {
882
876
should . not . exist ( err ) ;
883
877
connection . execute (
@@ -897,7 +891,7 @@ describe('4. binding.js', function() {
897
891
var binds = [ { b : { val : 1 } } , { val : 456 } ] ;
898
892
899
893
oracledb . getConnection (
900
- credentials ,
894
+ dbConfig ,
901
895
function ( err , connection ) {
902
896
should . not . exist ( err ) ;
903
897
connection . execute (
@@ -917,7 +911,7 @@ describe('4. binding.js', function() {
917
911
var binds = [ { b : { val : 1 } } , { c : { val : 456 } } ] ;
918
912
919
913
oracledb . getConnection (
920
- credentials ,
914
+ dbConfig ,
921
915
function ( err , connection ) {
922
916
should . not . exist ( err ) ;
923
917
connection . execute (
@@ -931,4 +925,193 @@ describe('4. binding.js', function() {
931
925
} ) ;
932
926
} ) ; // 4.7.7
933
927
} ) ; // 4.7
934
- } )
928
+
929
+ describe ( '4.8 bind DATE' , function ( ) {
930
+
931
+ var connection = null ;
932
+ before ( function ( done ) {
933
+ oracledb . getConnection ( dbConfig , function ( err , conn ) {
934
+ should . not . exist ( err ) ;
935
+ connection = conn ;
936
+ done ( ) ;
937
+ } ) ;
938
+ } ) ; // before
939
+
940
+ after ( function ( done ) {
941
+ connection . release ( function ( err ) {
942
+ should . not . exist ( err ) ;
943
+ done ( ) ;
944
+ } ) ;
945
+ } ) ; // after
946
+
947
+ it ( '4.8.1 binding out in Object & Array formats' , function ( done ) {
948
+
949
+ async . series ( [
950
+ function ( cb ) {
951
+ var proc = "CREATE OR REPLACE PROCEDURE nodb_binddate1 ( \n" +
952
+ " p_out1 OUT DATE, \n" +
953
+ " p_out2 OUT DATE \n" +
954
+ ") \n" +
955
+ "AS \n" +
956
+ "BEGIN \n" +
957
+ " p_out1 := SYSDATE + 10; \n" +
958
+ " p_out2 := TO_DATE('5-AUG-2016'); \n" +
959
+ "END;" ;
960
+
961
+ connection . execute (
962
+ proc ,
963
+ function ( err ) {
964
+ should . not . exist ( err ) ;
965
+ cb ( ) ;
966
+ }
967
+ ) ;
968
+ } ,
969
+ function ( cb ) {
970
+ connection . execute (
971
+ "BEGIN nodb_binddate1(:o1, :o2); END;" ,
972
+ {
973
+ o1 : { type : oracledb . DATE , dir : oracledb . BIND_OUT } ,
974
+ o2 : { type : oracledb . DATE , dir : oracledb . BIND_OUT }
975
+ } ,
976
+ function ( err , result ) {
977
+ should . not . exist ( err ) ;
978
+ // console.log(result);
979
+ ( result . outBinds . o1 ) . should . be . a . Date ( ) ;
980
+
981
+ var vdate = new Date ( 2016 , 7 , 5 ) ;
982
+ ( result . outBinds . o2 ) . should . eql ( vdate ) ;
983
+ cb ( ) ;
984
+ }
985
+ ) ;
986
+ } ,
987
+ function ( cb ) {
988
+ connection . execute (
989
+ "BEGIN nodb_binddate1(:o1, :o2); END;" ,
990
+ [
991
+ { type : oracledb . DATE , dir : oracledb . BIND_OUT } ,
992
+ { type : oracledb . DATE , dir : oracledb . BIND_OUT }
993
+ ] ,
994
+ function ( err , result ) {
995
+ should . not . exist ( err ) ;
996
+ ( result . outBinds [ 0 ] ) . should . be . a . Date ( ) ;
997
+
998
+ var vdate = new Date ( 2016 , 7 , 5 ) ;
999
+ ( result . outBinds [ 1 ] ) . should . eql ( vdate ) ;
1000
+ cb ( ) ;
1001
+ }
1002
+ ) ;
1003
+ } ,
1004
+ function ( cb ) {
1005
+ connection . execute (
1006
+ "DROP PROCEDURE nodb_binddate1" ,
1007
+ function ( err ) {
1008
+ should . not . exist ( err ) ;
1009
+ cb ( ) ;
1010
+ }
1011
+ ) ;
1012
+ }
1013
+ ] , done ) ;
1014
+
1015
+ } ) ; // 4.8.1
1016
+
1017
+ it ( '4.8.2 BIND_IN' , function ( done ) {
1018
+
1019
+ async . series ( [
1020
+ function ( cb ) {
1021
+ var proc = "CREATE OR REPLACE PROCEDURE nodb_binddate2 ( \n" +
1022
+ " p_in IN DATE, \n" +
1023
+ " p_out OUT DATE \n" +
1024
+ ") \n" +
1025
+ "AS \n" +
1026
+ "BEGIN \n" +
1027
+ " p_out := p_in; \n" +
1028
+ "END;" ;
1029
+
1030
+ connection . execute (
1031
+ proc ,
1032
+ function ( err ) {
1033
+ should . not . exist ( err ) ;
1034
+ cb ( ) ;
1035
+ }
1036
+ ) ;
1037
+ } ,
1038
+ function ( cb ) {
1039
+ var vdate = new Date ( 2016 , 7 , 5 ) ;
1040
+ connection . execute (
1041
+ "BEGIN nodb_binddate2(:i, :o); END;" ,
1042
+ {
1043
+ i : { type : oracledb . DATE , dir : oracledb . BIND_IN , val : vdate } ,
1044
+ o : { type : oracledb . DATE , dir : oracledb . BIND_OUT }
1045
+ } ,
1046
+ function ( err , result ) {
1047
+ should . not . exist ( err ) ;
1048
+ // console.log(result);
1049
+ ( result . outBinds . o ) . should . eql ( vdate ) ;
1050
+ cb ( ) ;
1051
+ }
1052
+ ) ;
1053
+ } ,
1054
+ function ( cb ) {
1055
+ connection . execute (
1056
+ "DROP PROCEDURE nodb_binddate2" ,
1057
+ function ( err ) {
1058
+ should . not . exist ( err ) ;
1059
+ cb ( ) ;
1060
+ }
1061
+ ) ;
1062
+ }
1063
+ ] , done ) ;
1064
+
1065
+ } ) ; // 4.8.2
1066
+
1067
+ it . skip ( '4.8.3 BIND_INOUT' , function ( done ) {
1068
+
1069
+ async . series ( [
1070
+ function ( cb ) {
1071
+ var proc = "CREATE OR REPLACE PROCEDURE nodb_binddate3 ( \n" +
1072
+ " p_inout IN OUT DATE \n" +
1073
+ ") \n" +
1074
+ "AS \n" +
1075
+ "BEGIN \n" +
1076
+ " p_inout := p_inout; \n" +
1077
+ "END;" ;
1078
+
1079
+ connection . execute (
1080
+ proc ,
1081
+ function ( err ) {
1082
+ should . not . exist ( err ) ;
1083
+ cb ( ) ;
1084
+ }
1085
+ ) ;
1086
+ } ,
1087
+ function ( cb ) {
1088
+ var vdate = new Date ( 2016 , 7 , 5 ) ;
1089
+ connection . execute (
1090
+
1091
+ "BEGIN nodb_binddate3(:io); END;" ,
1092
+ {
1093
+ io : { val : vdate , dir : oracledb . BIND_INOUT , type : oracledb . DATE }
1094
+ } ,
1095
+ function ( err , result ) {
1096
+ should . not . exist ( err ) ;
1097
+ console . log ( result ) ;
1098
+ ( result . outBinds . o ) . should . eql ( vdate ) ;
1099
+ cb ( ) ;
1100
+ }
1101
+ ) ;
1102
+ } ,
1103
+ function ( cb ) {
1104
+ connection . execute (
1105
+ "DROP PROCEDURE nodb_binddate3" ,
1106
+ function ( err ) {
1107
+ should . not . exist ( err ) ;
1108
+ cb ( ) ;
1109
+ }
1110
+ ) ;
1111
+ }
1112
+ ] , done ) ;
1113
+
1114
+ } ) ; // 4.8.3
1115
+
1116
+ } ) ; // 4.8
1117
+ } ) ;
0 commit comments