@@ -777,4 +777,148 @@ describe('4. binding.js', function() {
777
777
778
778
} )
779
779
} )
780
+
781
+ // Test cases involving JSON value as input
782
+ describe ( '4.7 Value as JSON named/unamed test cases' , function ( ) {
783
+ it ( '4.7.1 valid case when numeric values are passed as it is' ,
784
+ function ( done ) {
785
+ var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
786
+ var binds = [ 1 , 456 ] ;
787
+
788
+ oracledb . getConnection (
789
+ dbConfig ,
790
+ function ( err , connection ) {
791
+
792
+ should . not . exist ( err ) ;
793
+ connection . execute (
794
+ sql ,
795
+ binds ,
796
+ function ( err , result ) {
797
+ should . not . exist ( err ) ;
798
+ done ( ) ;
799
+ }
800
+ ) ;
801
+ } ) ;
802
+ } ) ;
803
+
804
+ it ( '4.7.2 Valid values when one of the value is passed as JSON ' ,
805
+ function ( done ) {
806
+ var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
807
+ var binds = [ 1 , { val : 456 } ] ;
808
+
809
+ oracledb . getConnection (
810
+ dbConfig ,
811
+ function ( err , connection ) {
812
+
813
+ should . not . exist ( err ) ;
814
+ connection . execute (
815
+ sql ,
816
+ binds ,
817
+ function ( err , result ) {
818
+ should . not . exist ( err ) ;
819
+ done ( ) ;
820
+ } ) ;
821
+ } ) ;
822
+ } ) ;
823
+
824
+ it ( '4.7.3 Valid test case when one of the value is passed as JSON ' ,
825
+ function ( done ) {
826
+ var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
827
+ var binds = [ { val : 1 } , 456 ] ;
828
+
829
+ oracledb . getConnection (
830
+ dbConfig ,
831
+ function ( err , connection ) {
832
+
833
+ should . not . exist ( err ) ;
834
+ connection . execute (
835
+ sql ,
836
+ binds ,
837
+ function ( err , result ) {
838
+ should . not . exist ( err ) ;
839
+ done ( ) ;
840
+ } ) ;
841
+ } ) ;
842
+ } ) ;
843
+
844
+ it ( '4.7.4 Valid Test case when both values are passed as JSON' ,
845
+ function ( done ) {
846
+ var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
847
+ var binds = [ { val : 1 } , { val : 456 } ] ;
848
+
849
+ oracledb . getConnection (
850
+ dbConfig ,
851
+ function ( err , connection ) {
852
+
853
+ should . not . exist ( err ) ;
854
+ connection . execute (
855
+ sql ,
856
+ binds ,
857
+ function ( err , result ) {
858
+ should . not . exist ( err ) ;
859
+ done ( ) ;
860
+ } ) ;
861
+ } ) ;
862
+ } ) ;
863
+
864
+ it ( '4.7.5 Invalid Test case when value is passed as named JSON' ,
865
+ function ( done ) {
866
+ var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
867
+ var binds = [ { val : 1 } , { c : { val : 456 } } ] ;
868
+
869
+ oracledb . getConnection (
870
+ dbConfig ,
871
+ function ( err , connection ) {
872
+ should . not . exist ( err ) ;
873
+ connection . execute (
874
+ sql ,
875
+ binds ,
876
+ function ( err , result ) {
877
+ should . exist ( err ) ;
878
+ ( err . message ) . should . startWith ( 'NJS-044' ) ;
879
+ done ( ) ;
880
+ } ) ;
881
+ } ) ;
882
+ } ) ;
883
+
884
+ it ( '4.7.6 Invalid Test case when other-value is passed as named JSON' ,
885
+ function ( done ) {
886
+ var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
887
+ var binds = [ { b : { val : 1 } } , { val : 456 } ] ;
888
+
889
+ oracledb . getConnection (
890
+ dbConfig ,
891
+ function ( err , connection ) {
892
+ should . not . exist ( err ) ;
893
+ connection . execute (
894
+ sql ,
895
+ binds ,
896
+ function ( err , result ) {
897
+ should . exist ( err ) ;
898
+ ( err . message ) . should . startWith ( 'NJS-044' ) ;
899
+ done ( ) ;
900
+ } ) ;
901
+ } ) ;
902
+ } ) ;
903
+
904
+ it ( '4.7.7 Invalid Test case when all values is passed as named JSON' ,
905
+ function ( done ) {
906
+ var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 " ;
907
+ var binds = [ { b : { val : 1 } } , { c : { val : 456 } } ] ;
908
+
909
+ oracledb . getConnection (
910
+ dbConfig ,
911
+ function ( err , connection ) {
912
+ should . not . exist ( err ) ;
913
+ connection . execute (
914
+ sql ,
915
+ binds ,
916
+ function ( err , result ) {
917
+ should . exist ( err ) ;
918
+ ( err . message ) . should . startWith ( 'NJS-044' ) ;
919
+ done ( ) ;
920
+ } ) ;
921
+ } ) ;
922
+ } ) ;
923
+ } ) ;
780
924
} )
0 commit comments