Skip to content

Commit a9cbe7a

Browse files
committed
Test PL/SQL Index-by bind error message changes
1 parent 5ae7f71 commit a9cbe7a

File tree

3 files changed

+286
-41
lines changed

3 files changed

+286
-41
lines changed

test/clobPlsqlBindAsString_bindin.js

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,148 @@ describe('74. clobPlsqlBindAsString_bindin.js', function() {
932932
], done);
933933
}); // 74.1.26
934934

935+
it('74.1.27 bind error: NJS-037, bind by name 1', function(done) {
936+
var bindVar = {
937+
i: { val: ["sequence"], type: oracledb.NUMBER, dir: oracledb.BIND_IN },
938+
c: { val: "sequence", type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
939+
};
940+
connection.execute(
941+
sqlRun,
942+
bindVar,
943+
{ autoCommit: true },
944+
function(err) {
945+
should.exist(err);
946+
// NJS-037: invalid data type at array index 0 for bind ":i"
947+
(err.message).should.startWith('NJS-037:');
948+
(err.message).should.match(/^NJS-037:.*\sindex\s0\s.*\sbind\s":i"$/);
949+
done();
950+
}
951+
);
952+
}); // 74.1.27
953+
954+
it('74.1.28 bind error: NJS-037, bind by name 2', function(done) {
955+
var sequence = insertID++;
956+
var bindVar = {
957+
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
958+
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
959+
};
960+
connection.execute(
961+
sqlRun,
962+
bindVar,
963+
{ autoCommit: true },
964+
function(err) {
965+
should.exist(err);
966+
// NJS-037: invalid data type at array index 0 for bind ":c"
967+
(err.message).should.startWith('NJS-037:');
968+
(err.message).should.match(/^NJS-037:.*\sindex\s0\s.*\sbind\s":c"$/);
969+
done();
970+
}
971+
);
972+
}); // 74.1.28
973+
974+
it('74.1.29 bind error: NJS-037, bind by name 3', function(done) {
975+
var bindVar = {
976+
i: { val: [1, "sequence"], type: oracledb.NUMBER, dir: oracledb.BIND_IN },
977+
c: { val: "sequence", type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
978+
};
979+
connection.execute(
980+
sqlRun,
981+
bindVar,
982+
{ autoCommit: true },
983+
function(err) {
984+
should.exist(err);
985+
// NJS-037: invalid data type at array index 1 for bind ":i"
986+
(err.message).should.startWith('NJS-037:');
987+
(err.message).should.match(/^NJS-037:.*\sindex\s1\s.*\sbind\s":i"$/);
988+
done();
989+
}
990+
);
991+
}); // 74.1.29
992+
993+
it('74.1.30 bind error: NJS-037, bind by name 4', function(done) {
994+
var bindVar = {
995+
i: { val: [1, 2], type: oracledb.NUMBER, dir: oracledb.BIND_IN },
996+
c: { val: ["sequence", "ab", 3], type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
997+
};
998+
connection.execute(
999+
sqlRun,
1000+
bindVar,
1001+
{ autoCommit: true },
1002+
function(err) {
1003+
should.exist(err);
1004+
// NJS-037: invalid data type at array index 2 for bind ":c"
1005+
(err.message).should.startWith('NJS-037:');
1006+
(err.message).should.match(/^NJS-037:.*\sindex\s2\s.*\sbind\s":c"$/);
1007+
done();
1008+
}
1009+
);
1010+
}); // 74.1.30
1011+
1012+
it('74.1.31 bind error: NJS-052, bind by pos 1', function(done) {
1013+
var sequence = insertID++;
1014+
var bindVar = [ sequence, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 } ] ;
1015+
connection.execute(
1016+
sqlRun,
1017+
bindVar,
1018+
{ autoCommit: true },
1019+
function(err) {
1020+
should.exist(err);
1021+
// NJS-052: invalid data type at array index 0 for bind position 2
1022+
(err.message).should.startWith('NJS-052:');
1023+
(err.message).should.match(/^NJS-052:.*\sindex\s0\s.*\sposition\s2$/);
1024+
done();
1025+
}
1026+
);
1027+
}); // 74.1.31
1028+
1029+
it('74.1.32 bind error: NJS-052, bind by pos 2', function(done) {
1030+
var bindVar = [ { val: ["sequence"], type: oracledb.NUMBER, dir: oracledb.BIND_IN }, { val: "sequence", type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 } ] ;
1031+
connection.execute(
1032+
sqlRun,
1033+
bindVar,
1034+
{ autoCommit: true },
1035+
function(err) {
1036+
should.exist(err);
1037+
// NJS-052: invalid data type at array index 0 for bind position 1
1038+
(err.message).should.startWith('NJS-052:');
1039+
(err.message).should.match(/^NJS-052:.*\sindex\s0\s.*\sposition\s1$/);
1040+
done();
1041+
}
1042+
);
1043+
}); // 74.1.32
1044+
1045+
it('74.1.33 bind error: NJS-052, bind by pos 3', function(done) {
1046+
var bindVar = [ { val: [1, 2, "sequence"], type: oracledb.NUMBER, dir: oracledb.BIND_IN }, { val: "sequence", type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 } ] ;
1047+
connection.execute(
1048+
sqlRun,
1049+
bindVar,
1050+
{ autoCommit: true },
1051+
function(err) {
1052+
should.exist(err);
1053+
// NJS-052: invalid data type at array index 2 for bind position 1
1054+
(err.message).should.startWith('NJS-052:');
1055+
(err.message).should.match(/^NJS-052:.*\sindex\s2\s.*\sposition\s1$/);
1056+
done();
1057+
}
1058+
);
1059+
}); // 74.1.33
1060+
1061+
it('74.1.35 bind error: NJS-052, bind by pos 4', function(done) {
1062+
var bindVar = [ { val: [1, 2], type: oracledb.NUMBER, dir: oracledb.BIND_IN }, { val: ["sequence", 1], type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 } ] ;
1063+
connection.execute(
1064+
sqlRun,
1065+
bindVar,
1066+
{ autoCommit: true },
1067+
function(err) {
1068+
should.exist(err);
1069+
// NJS-052: invalid data type at array index 1 for bind position 2
1070+
(err.message).should.startWith('NJS-052:');
1071+
(err.message).should.match(/^NJS-052:.*\sindex\s1\s.*\sposition\s2$/);
1072+
done();
1073+
}
1074+
);
1075+
}); // 74.1.35
1076+
9351077
}); // 74.1
9361078

9371079
describe('74.2 CLOB, PLSQL, BIND_IN to VARCHAR2', function() {

test/list.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,15 @@ Overview of node-oracledb functional tests
628628
43.2.2 maxArraySize is mandatory for BIND_INOUT
629629
43.2.3 maxArraySize cannot smaller than the number of array elements
630630
43.2.4 DATE type indexed table has not been supported yet
631-
43.2.5 negative case (string): incorrect type of array elements
632-
43.2.6 negative case (number): incorrect type of array element
633-
43.2.7 supports binding by position
634-
43.2.8 negative case: incorrect type of array elements - bind by pos1
635-
43.2.9 negative case: incorrect type of array elements - bind by pos2
631+
43.2.5 negative case: incorrect type of array element - bind by name 1
632+
43.2.6 negative case: incorrect type of array element - bind by name 2
633+
43.2.7 negative case: incorrect type of array element - bind by name 3
634+
43.2.8 negative case: incorrect type of array element - bind by name 4
635+
43.2.9 supports binding by position
636+
43.2.10 negative case: incorrect type of array elements - bind by pos 1
637+
43.2.11 negative case: incorrect type of array elements - bind by pos 2
638+
43.2.12 negative case: incorrect type of array elements - bind by pos 3
639+
43.2.13 negative case: incorrect type of array elements - bind by pos 4
636640
43.3 binding PL/SQL scalar
637641
43.3.1 binding PL/SQL scalar IN
638642
43.3.2 binding PL/SQL scalar IN/OUT
@@ -1150,6 +1154,14 @@ Overview of node-oracledb functional tests
11501154
74.1.24 works with bind in maxSize smaller than string length
11511155
74.1.25 RETURN with bind type STRING
11521156
74.1.26 works with UPDATE
1157+
74.1.27 bind error: NJS-037, bind by name 1
1158+
74.1.28 bind error: NJS-037, bind by name 2
1159+
74.1.29 bind error: NJS-037, bind by name 3
1160+
74.1.30 bind error: NJS-037, bind by name 4
1161+
74.1.31 bind error: NJS-052, bind by pos 1
1162+
74.1.32 bind error: NJS-052, bind by pos 2
1163+
74.1.33 bind error: NJS-052, bind by pos 3
1164+
74.1.35 bind error: NJS-052, bind by pos 4
11531165
74.2 CLOB, PLSQL, BIND_IN to VARCHAR2
11541166
74.2.1 works with EMPTY_CLOB
11551167
74.2.2 works with EMPTY_CLOB and bind in maxSize set to 1

0 commit comments

Comments
 (0)