Skip to content

Commit d4069f4

Browse files
committed
Add tests for REF CURSOR BIND_INOUT case
1 parent 6b6264f commit d4069f4

File tree

6 files changed

+77
-23
lines changed

6 files changed

+77
-23
lines changed

test/dataTypeAssist.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ assist.data = {
110110
'o', 'p', 'q', 'r', 's',
111111
't', 'u', 'v', 'w', 'x',
112112
'y', 'z'
113+
],
114+
dates: [
115+
new Date(-100000000),
116+
new Date(0),
117+
new Date(10000000000),
118+
new Date(100000000000),
119+
new Date(1995, 11, 17),
120+
new Date('1995-12-17T03:24:00'),
121+
new Date('2015-07-23 21:00:00'),
122+
new Date('2015-07-23 22:00:00'),
123+
new Date('2015-07-23 23:00:00'),
124+
new Date('2015-07-24 00:00:00')
113125
]
114126
};
115127

@@ -187,10 +199,10 @@ assist.dataTypeSupport = function(connection, tableName, array, done) {
187199
// console.log(result);
188200
for(var i = 0; i < array.length; i++) {
189201
if( (typeof result.rows[i].CONTENT) === 'string' )
190-
result.rows[i].CONTENT.trim().should.eql(array[result.rows[i].NUM]);
202+
result.rows[i].CONTENT.trim().should.eql(array[result.rows[i].NUM]);
191203
else if( (typeof result.rows[i].CONTENT) === 'number' )
192204
result.rows[i].CONTENT.should.eql(array[result.rows[i].NUM]);
193-
else
205+
else
194206
result.rows[i].CONTENT.toUTCString().should.eql(array[result.rows[i].NUM].toUTCString());
195207
}
196208
done();

test/dataTypeDate.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('32. dataTypeDate.js', function() {
4444
var credential = dbConfig;
4545
}
4646

47-
var connection = false;
47+
var connection = null;
4848
var tableName = "oracledb_datatype_date";
4949
var sqlCreate =
5050
"BEGIN " +
@@ -65,12 +65,7 @@ describe('32. dataTypeDate.js', function() {
6565
" '); " +
6666
"END; ";
6767

68-
var dates = [
69-
new Date(-100000000),
70-
new Date(0),
71-
new Date(10000000000),
72-
new Date(100000000000)
73-
];
68+
var dates = assist.data.dates;
7469

7570
before(function(done) {
7671
oracledb.getConnection(credential, function(err, conn) {

test/dataTypeTimestamp1.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('33. dataTypeTimestamp1.js', function() {
4646
var credential = dbConfig;
4747
}
4848

49-
var connection = false;
49+
var connection = null;
5050
var tableName = "oracledb_datatype_timestamp";
5151
var sqlCreate =
5252
"BEGIN " +
@@ -66,12 +66,8 @@ describe('33. dataTypeTimestamp1.js', function() {
6666
" )" +
6767
" '); " +
6868
"END; ";
69-
var timestamps = [
70-
new Date(-100000000),
71-
new Date(0),
72-
new Date(10000000000),
73-
new Date(100000000000)
74-
];
69+
70+
var timestamps = assist.data.dates;
7571

7672
before(function(done) {
7773
oracledb.getConnection(credential, function(err, conn) {

test/dataTypeTimestamp2.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('34. dataTypeTimestamp2.js', function() {
4444
var credential = dbConfig;
4545
}
4646

47-
var connection = false;
47+
var connection = null;
4848
var tableName = "oracledb_datatype_timestamp";
4949
var sqlCreate =
5050
"BEGIN " +
@@ -64,12 +64,8 @@ describe('34. dataTypeTimestamp2.js', function() {
6464
" )" +
6565
" '); " +
6666
"END; ";
67-
var timestamps = [
68-
new Date(-100000000),
69-
new Date(0),
70-
new Date(10000000000),
71-
new Date(100000000000)
72-
];
67+
68+
var timestamps = assist.data.dates;
7369

7470
before(function(done) {
7571
oracledb.getConnection(credential, function(err, conn) {

test/list.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@
327327
55.9.1
328328
55.10 calls getRows() once and then close RS before getting more rows
329329
55.10.1
330+
55.11 deals with unsupported database with result set
331+
55.11.1 RAW data type
332+
55.11.2 ROWID date type
333+
55.12 bind a cursor BIND_INOUT
334+
- 55.12.1 should work
335+
330336

331337
56. fetchAs.js
332338
56.1 FetchAs - DATE type as STRING

test/resultSet2.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,4 +829,53 @@ describe('55. resultSet2.js', function() {
829829
})
830830
})
831831

832+
describe.skip('55.12 bind a cursor BIND_INOUT', function() {
833+
it('55.12.1 should work', function(done) {
834+
var proc =
835+
"CREATE OR REPLACE PROCEDURE get_emp_rs_inout (p_in IN NUMBER, p_out IN OUT SYS_REFCURSOR) \
836+
AS \
837+
BEGIN \
838+
OPEN p_out FOR \
839+
SELECT * FROM oracledb_employees \
840+
WHERE employees_id > p_in; \
841+
END; ";
842+
843+
async.series([
844+
function(callback) {
845+
connection.execute(
846+
proc,
847+
function(err) {
848+
should.not.exist(err);
849+
callback();
850+
}
851+
);
852+
},
853+
function(callback) {
854+
connection.execute(
855+
"BEGIN get_emp_rs_inout(:in, :out); END;",
856+
{
857+
in: 200,
858+
out: { type: oracledb.CURSOR, dir: oracledb.BIND_INOUT }
859+
},
860+
function(err, result) {
861+
should.not.exist(err);
862+
console.log(result);
863+
callback();
864+
}
865+
);
866+
},
867+
function(callback) {
868+
connection.execute(
869+
"DROP PROCEDURE get_emp_rs_inout",
870+
function(err) {
871+
should.not.exist(err);
872+
callback();
873+
}
874+
);
875+
}
876+
], done);
877+
})
878+
879+
})
880+
832881
})

0 commit comments

Comments
 (0)