Skip to content

Commit 0ea4a31

Browse files
committed
add maxRow 200 test case
1 parent 1a478d6 commit 0ea4a31

File tree

4 files changed

+105
-27
lines changed

4 files changed

+105
-27
lines changed

test/binding.js

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ var oracledb = require('oracledb');
3838
var should = require('should');
3939
var async = require('async');
4040
var dbConfig = require('./dbConfig.js');
41+
var assist = require('./dataTypeAssist.js');
4142

4243
describe('4. binding.js', function() {
4344

@@ -662,20 +663,32 @@ describe('4. binding.js', function() {
662663
], done);
663664
})
664665

665-
it.skip('4.4.2 default value is 200', function(done) {
666+
it('4.4.2 default value is 200', function(done) {
667+
connection.execute(
668+
"BEGIN :o := lpad('A', 200, 'x'); END;",
669+
{ o: { type: oracledb.STRING, dir: oracledb.BIND_OUT } },
670+
function(err, result) {
671+
should.not.exist(err);
672+
(result.outBinds.o.length).should.be.exactly(200);
673+
done();
674+
}
675+
);
676+
})
677+
678+
it.skip('4.4.3 Negative - bind out data exceeds default length', function(done) {
666679
connection.execute(
667680
"BEGIN :o := lpad('A',201,'x'); END;",
668681
{ o: { type: oracledb.STRING, dir : oracledb.BIND_OUT } },
669682
function (err, result) {
670683
should.exist(err);
671684
err.message.should.startWith('ORA-06502:');
672-
console.log(result.outBinds.o.length);
685+
// console.log(result.outBinds.o.length);
673686
done();
674687
}
675688
);
676689
})
677690

678-
it.skip('4.4.3 maximum value is 32767', function(done) {
691+
it.skip('4.4.4 maximum value is 32767', function(done) {
679692
connection.execute(
680693
"BEGIN :o := lpad('A',32767,'x'); END;",
681694
{ o: { type: oracledb.STRING, dir : oracledb.BIND_OUT, maxSize:50000 } },
@@ -686,5 +699,51 @@ describe('4. binding.js', function() {
686699
}
687700
);
688701
})
689-
})
702+
}) // 4.4
703+
704+
describe.skip('4.5 The default direction for binding is BIND_IN', function() {
705+
var connection = null;
706+
var tableName = "oracledb_raw";
707+
708+
before(function(done) {
709+
oracledb.getConnection(credential, function(err, conn) {
710+
if(err) { console.error(err.message); return; }
711+
connection = conn;
712+
assist.createTable(connection, tableName, done);
713+
});
714+
})
715+
716+
after(function(done) {
717+
async.series([
718+
function(callback) {
719+
connection.execute(
720+
"DROP TABLE " + tableName,
721+
function(err) {
722+
should.not.exist(err);
723+
callback();
724+
}
725+
);
726+
},
727+
function(callback) {
728+
connection.release( function(err) {
729+
should.not.exist(err);
730+
callback();
731+
});
732+
}
733+
], done);
734+
})
735+
736+
737+
it('4.5.1',function(done) {
738+
connection.execute(
739+
"insert into oracledb_raw (num) values (:id)",
740+
{ id: { val: 1, type: oracledb.NUMBER } }, // fails with error NJS-013: invalid bind direction
741+
// { id: { val: 1, type: oracledb.NUMBER, dir: oracledb.BIND_IN } }, // works
742+
function(err, result) {
743+
should.not.exist(err);
744+
done();
745+
}
746+
);
747+
})
748+
}) // 4.5
690749
})

test/dataTypeRaw.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* 51 - are for other tests
3232
*
3333
*****************************************************************************/
34-
"use strict";
34+
"use strict";
3535

3636
var oracledb = require('oracledb');
3737
var should = require('should');
@@ -47,7 +47,7 @@ describe('42. dataTypeRaw.js', function() {
4747
var credential = dbConfig;
4848
}
4949

50-
var connection = false;
50+
var connection = null;
5151
var tableName = "oracledb_raw";
5252

5353
var bufLen = [10 ,100, 1000, 2000]; // buffer length
@@ -98,6 +98,35 @@ describe('42. dataTypeRaw.js', function() {
9898
assist.verifyRefCursor(connection, tableName, bufs, done);
9999
})
100100

101+
it('42.1.4 result set getRow() function works well with RAW', function(done) {
102+
103+
var sql1 = "select dummy, HEXTORAW('0123456789ABCDEF0123456789ABCDEF') from dual";
104+
connection.execute(
105+
sql1,
106+
[],
107+
{ resultSet: true },
108+
function(err, result) {
109+
should.not.exist(err);
110+
fetchOneRowFromRS(result.resultSet, done);
111+
}
112+
);
113+
114+
function fetchOneRowFromRS(rs, cb)
115+
{
116+
rs.getRow(function(err, row) {
117+
should.not.exist(err);
118+
if(row) {
119+
fetchOneRowFromRS(rs, cb);
120+
} else {
121+
rs.close( function(err) {
122+
should.not.exist(err);
123+
cb();
124+
});
125+
}
126+
});
127+
}
128+
})
129+
101130
})
102131

103132
describe('42.2 stores null value correctly', function() {

test/list.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@
9393
4.3.4 should pass but fail in array syntax with returning into
9494
4.4 test maxSize option
9595
4.4.1 outBind & maxSize restriction
96-
- 4.4.2 default value is 200
97-
- 4.4.3 maximum value is 32767
96+
4.4.2 default value is 200
97+
- 4.4.3 Negative - bind out data exceeds default length
98+
- 4.4.4 maximum value is 32767
99+
4.5 The default direction for binding is BIND_IN
100+
- 4.5.1
98101

99102
5. externalAuthentication.js
100103
5.1 connection should succeed when setting externalAuth to be false and providing user/password
@@ -404,9 +407,8 @@
404407
55.9.1
405408
55.10 calls getRows() once and then close RS before getting more rows
406409
55.10.1
407-
55.11 deals with unsupported database with result set
408-
55.11.1 RAW data type
409-
55.11.2 ROWID date type
410+
55.11 result set with unsupported data types
411+
55.11.1 ROWID data type
410412
55.12 bind a cursor BIND_INOUT
411413
- 55.12.1 should work
412414

test/resultSet2.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,8 @@ describe('55. resultSet2.js', function() {
749749
})
750750
})
751751

752-
describe('55.11 deals with unsupported database with result set', function() {
753-
var sql1 = "select dummy, HEXTORAW('0123456789ABCDEF0123456789ABCDEF') from dual";
752+
describe('55.11 result set with unsupported data types', function() {
753+
754754
var sql2 = "SELECT dummy, rowid FROM dual";
755755

756756
function fetchOneRowFromRS(rs, cb) {
@@ -759,6 +759,7 @@ describe('55. resultSet2.js', function() {
759759
* the result set can still be created.
760760
*/
761761
// Error at accessing RS
762+
should.exist(err);
762763
if(err) {
763764
// console.error("Error at accessing RS: " + err.message);
764765
// NJS-010: unsupported data type in select list
@@ -779,20 +780,7 @@ describe('55. resultSet2.js', function() {
779780
});
780781
}
781782

782-
it('55.11.1 RAW data type', function(done) {
783-
connection.should.be.ok;
784-
connection.execute(
785-
sql1,
786-
[],
787-
{ resultSet: true },
788-
function(err, result) {
789-
should.not.exist(err);
790-
fetchOneRowFromRS(result.resultSet, done);
791-
}
792-
);
793-
})
794-
795-
it('55.11.2 ROWID date type', function(done) {
783+
it('55.11.1 ROWID date type', function(done) {
796784
connection.execute(
797785
sql2,
798786
[],

0 commit comments

Comments
 (0)