Skip to content

Commit 3f60b6e

Browse files
committed
Add DATE bind tests
1 parent da11cfc commit 3f60b6e

File tree

3 files changed

+229
-31
lines changed

3 files changed

+229
-31
lines changed

test/binding.js

Lines changed: 204 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,11 @@ var assist = require('./dataTypeAssist.js');
4343

4444
describe('4. binding.js', function() {
4545

46-
var credentials = {
47-
user: dbConfig.user,
48-
password: dbConfig.password,
49-
connectString: dbConfig.connectString
50-
};
51-
5246
describe('4.1 test STRING, NUMBER, ARRAY & JSON format', function() {
5347

5448
var connection = null;
5549
before(function(done) {
56-
oracledb.getConnection(credentials, function(err, conn) {
50+
oracledb.getConnection(dbConfig, function(err, conn) {
5751
if(err) { console.error(err.message); return; }
5852
connection = conn;
5953
done();
@@ -179,7 +173,7 @@ describe('4. binding.js', function() {
179173
);
180174
}
181175
], done);
182-
})
176+
}); // 4.1.2
183177

184178
it('4.1.3 Multiple binding values, Object & Array formats', function(done) {
185179
async.series([
@@ -353,7 +347,7 @@ describe('4. binding.js', function() {
353347
var options = { autoCommit: true, outFormat: oracledb.OBJECT };
354348

355349
beforeEach(function(done) {
356-
oracledb.getConnection(credentials, function(err, conn) {
350+
oracledb.getConnection(dbConfig, function(err, conn) {
357351
should.not.exist(err);
358352
connection = conn;
359353
conn.execute(
@@ -454,7 +448,7 @@ describe('4. binding.js', function() {
454448
END; ";
455449

456450
beforeEach(function(done) {
457-
oracledb.getConnection(credentials, function(err, conn) {
451+
oracledb.getConnection(dbConfig, function(err, conn) {
458452
should.not.exist(err);
459453
connection = conn;
460454
conn.execute(
@@ -589,7 +583,7 @@ describe('4. binding.js', function() {
589583
var connection = null;
590584

591585
before(function(done) {
592-
oracledb.getConnection(credentials, function(err, conn) {
586+
oracledb.getConnection(dbConfig, function(err, conn) {
593587
if(err) { console.error(err.message); return; }
594588
connection = conn;
595589
done();
@@ -705,7 +699,7 @@ describe('4. binding.js', function() {
705699
var tableName = "nodb_raw";
706700

707701
before(function(done) {
708-
oracledb.getConnection(credentials, function(err, conn) {
702+
oracledb.getConnection(dbConfig, function(err, conn) {
709703
if(err) { console.error(err.message); return; }
710704
connection = conn;
711705
assist.createTable(connection, tableName, done);
@@ -758,7 +752,7 @@ describe('4. binding.js', function() {
758752
var options = {};
759753

760754
oracledb.getConnection(
761-
credentials,
755+
dbConfig,
762756
function(err, connection)
763757
{
764758
should.not.exist(err);
@@ -792,7 +786,7 @@ describe('4. binding.js', function() {
792786
var binds = [ 1, 456 ];
793787

794788
oracledb.getConnection (
795-
credentials,
789+
dbConfig,
796790
function (err, connection ){
797791

798792
should.not.exist ( err ) ;
@@ -814,7 +808,7 @@ describe('4. binding.js', function() {
814808
var binds = [ 1, { val : 456 } ];
815809

816810
oracledb.getConnection (
817-
credentials,
811+
dbConfig,
818812
function (err, connection ){
819813

820814
should.not.exist ( err ) ;
@@ -835,7 +829,7 @@ describe('4. binding.js', function() {
835829
var binds = [ {val : 1}, 456 ];
836830

837831
oracledb.getConnection (
838-
credentials,
832+
dbConfig,
839833
function (err, connection ){
840834

841835
should.not.exist ( err ) ;
@@ -856,7 +850,7 @@ describe('4. binding.js', function() {
856850
var binds = [ {val : 1}, {val : 456 } ];
857851

858852
oracledb.getConnection (
859-
credentials,
853+
dbConfig,
860854
function (err, connection ){
861855

862856
should.not.exist ( err ) ;
@@ -877,7 +871,7 @@ describe('4. binding.js', function() {
877871
var binds = [ {val : 1}, { c: {val : 456 } } ];
878872

879873
oracledb.getConnection (
880-
credentials,
874+
dbConfig,
881875
function (err, connection ){
882876
should.not.exist ( err ) ;
883877
connection.execute (
@@ -897,7 +891,7 @@ describe('4. binding.js', function() {
897891
var binds = [ { b: {val : 1} }, {val : 456 } ];
898892

899893
oracledb.getConnection (
900-
credentials,
894+
dbConfig,
901895
function (err, connection ){
902896
should.not.exist ( err ) ;
903897
connection.execute (
@@ -917,7 +911,7 @@ describe('4. binding.js', function() {
917911
var binds = [ { b: {val : 1} }, { c: {val : 456 } } ];
918912

919913
oracledb.getConnection (
920-
credentials,
914+
dbConfig,
921915
function (err, connection ){
922916
should.not.exist ( err ) ;
923917
connection.execute (
@@ -931,4 +925,193 @@ describe('4. binding.js', function() {
931925
});
932926
}); // 4.7.7
933927
}); // 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+
});

test/list.txt

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,21 @@ Overview of node-oracledb functional tests
120120
4.4.3 Negative - bind out data exceeds default length
121121
- 4.4.4 maximum value is 32767
122122
4.5 The default direction for binding is BIND_IN
123-
- 4.5.1
123+
4.5.1
124+
4.6 PL/SQL block with empty outBinds
125+
4.6.1
126+
4.7 Value as JSON named/unamed test cases
127+
4.7.1 valid case when numeric values are passed as it is
128+
4.7.2 Valid values when one of the value is passed as JSON
129+
4.7.3 Valid test case when one of the value is passed as JSON
130+
4.7.4 Valid Test case when both values are passed as JSON
131+
4.7.5 Invalid Test case when value is passed as named JSON
132+
4.7.6 Invalid Test case when other-value is passed as named JSON
133+
4.7.7 Invalid Test case when all values is passed as named JSON
134+
4.8 bind DATE
135+
4.8.1 binding out in Object & Array formats
136+
4.8.2 BIND_IN
137+
- 4.8.3 BIND_INOUT
124138

125139
5. externalAuth.js
126140
5.1 tests that work both when DB has configured externalAuth and not configured
@@ -609,10 +623,10 @@ Overview of node-oracledb functional tests
609623
43.2.1 maxArraySize is ignored when specifying BIND_IN
610624
43.2.2 maxArraySize is mandatory for BIND_INOUT
611625
42.2.3 maxArraySize cannot smaller than the number of array elements
612-
42.2.4 DATE type has not been supported yet
613-
42.2.5 negative case (string): incorrect type of array element
614-
42.2.6 negative case (number): incorrect type of array element
615-
42.2.7 supports binding by position
626+
43.2.4 DATE type has not been supported yet
627+
43.2.5 negative case (string): incorrect type of array element
628+
43.2.6 negative case (number): incorrect type of array element
629+
43.2.7 supports binding by position
616630
43.3 binding PL/SQL scalar
617631
43.3.1 binding PL/SQL scalar IN
618632
- 43.3.2 binding PL/SQL scalar IN/OUT

0 commit comments

Comments
 (0)