Skip to content

Commit 83b8fc7

Browse files
committed
Add PL/SQL Index-by array tests
1 parent 4fa6461 commit 83b8fc7

File tree

3 files changed

+303
-23
lines changed

3 files changed

+303
-23
lines changed

test/list.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,29 +418,34 @@
418418
43.2.2 maxArraySize is mandatory for BIND_INOUT
419419
42.2.3 maxArraySize cannot smaller than the number of array elements
420420
42.2.4 DATE type has not been supported yet
421-
42.2.5 the type of the array element should be compatible with binding type declaration
422-
42.2.6 type compatibility
423-
42.2.7 dose not allow array syntax of bindings
421+
42.2.5 negative case (string): incorrect type of array element
422+
42.2.6 negative case (number): incorrect type of array element
423+
42.2.7 supports binding by position
424424
43.3 binding PL/SQL scalar
425425
43.3.1 binding PL/SQL scalar IN
426426
- 43.3.2 binding PL/SQL scalar IN/OUT
427-
43.3.3 binding PL/SQL scalar OUT
427+
43.3.3 binding PL/SQL scalar OUT by name
428+
43.3.4 binding PL/SQL scalar OUT by position
428429
43.4 test attribute - maxArraySize
429430
43.4.1 maxArraySize property is ignored for BIND_IN
430431
43.4.2 maxArraySize is mandatory for BIND_INOUT
431432
43.4.3 maxArraySize cannot smaller than the number of array elements
432433
43.4.4 maxArraySize can be equal to the number of array elements
433434
- 43.4.5 negative case: large value
434-
43.4.6 negative case: <0
435+
43.4.6 negative case: < 0
435436
43.4.7 negative case: = 0
436-
43.4.8 negative case: assigning it to be a string
437+
43.4.8 negative case: assigning a string to it
437438
43.4.9 negative case: NaN
438439

439440
44. plsqlBinding2.js
440441
44.1 example case
441-
44.2 null elements in String and Number arrays
442-
44.3 NJS-039: empty array is not allowed for IN bind
443-
- 44.4 maxSize option applies to each elements of an array
442+
44.2 example case binding by position
443+
- 44.3 default binding type and direction with binding by name
444+
44.4 default binding type and direction with binding by position
445+
44.5 null elements in String and Number arrays
446+
44.6 NJS-039: empty array is not allowed for IN bind
447+
- 44.7 maxSize option applies to each elements of an array
448+
444449

445450
51. accessTerminatedPoolAttributes.js
446451
can not access attributes of terminated pool

test/plsqlBinding1.js

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ describe('43. plsqlBinding1.js', function() {
427427
);
428428
})
429429

430-
it('42.2.5 the type of the array element should be compatible with binding type declaration', function(done) {
430+
it('42.2.5 negative case (string): incorrect type of array elements', function(done) {
431431
var bindvars = {
432432
p: {type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['hello', 1]}
433433
};
@@ -444,7 +444,7 @@ describe('43. plsqlBinding1.js', function() {
444444
);
445445
})
446446

447-
it('42.2.6 type compatibility', function(done) {
447+
it('42.2.6 negative case (number): incorrect type of array element', function(done) {
448448
var bindvars = {
449449
p: {type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: [1, 'hello']}
450450
};
@@ -461,7 +461,7 @@ describe('43. plsqlBinding1.js', function() {
461461
);
462462
})
463463

464-
it('42.2.7 dose not allow array syntax of bindings', function(done) {
464+
it('42.2.7 supports binding by position', function(done) {
465465
var bindvars = [
466466
{type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['hello', 'node.js']}
467467
];
@@ -578,7 +578,7 @@ describe('43. plsqlBinding1.js', function() {
578578
bindvars,
579579
function(err, result) {
580580
should.not.exist(err);
581-
console.log(result);
581+
// console.log(result);
582582
result.outBinds.stringValue.should.be.exactly('(Space odyssey)');
583583
result.outBinds.numberValue.should.be.exactly(2101);
584584
//result.outBinds.dateValue.should.eql(releaseDate)
@@ -598,7 +598,7 @@ describe('43. plsqlBinding1.js', function() {
598598
], done);
599599
});
600600

601-
it('43.3.3 binding PL/SQL scalar OUT', function(done) {
601+
it('43.3.3 binding PL/SQL scalar OUT by name', function(done) {
602602
async.series([
603603
function(callback) {
604604
var proc = "CREATE OR REPLACE\n" +
@@ -632,7 +632,7 @@ describe('43. plsqlBinding1.js', function() {
632632
// console.log(result);
633633
result.outBinds.stringValue.should.be.exactly('Space odyssey');
634634
result.outBinds.numberValue.should.be.exactly(2001);
635-
(typeof (result.outBinds.dateValue)).should.eql('object');
635+
(Object.prototype.toString.call(result.outBinds.dateValue)).should.eql('[object Date]');
636636
callback();
637637
}
638638
);
@@ -649,6 +649,57 @@ describe('43. plsqlBinding1.js', function() {
649649
], done);
650650
});
651651

652+
it('43.3.4 binding PL/SQL scalar OUT by postion', function(done) {
653+
async.series([
654+
function(callback) {
655+
var proc = "CREATE OR REPLACE\n" +
656+
"PROCEDURE test(stringValue OUT VARCHAR2, numberValue OUT NUMBER, dateValue OUT DATE)\n" +
657+
"IS\n" +
658+
"BEGIN\n" +
659+
" stringValue := 'Space odyssey';\n" +
660+
" numberValue := 2001;\n" +
661+
" dateValue := TO_DATE('04-02-1968', 'MM-DD-YYYY');" +
662+
"END test;\n";
663+
connection.should.be.ok;
664+
connection.execute(
665+
proc,
666+
function(err) {
667+
should.not.exist(err);
668+
callback();
669+
}
670+
);
671+
},
672+
function(callback) {
673+
var bindvars = [
674+
{type: oracledb.STRING, dir: oracledb.BIND_OUT},
675+
{type: oracledb.NUMBER, dir: oracledb.BIND_OUT},
676+
{type: oracledb.DATE, dir: oracledb.BIND_OUT}
677+
];
678+
connection.execute(
679+
"BEGIN test(:1, :2, :3); END;",
680+
bindvars,
681+
function(err, result) {
682+
should.not.exist(err);
683+
// console.log(result);
684+
result.outBinds[0].should.be.exactly('Space odyssey');
685+
result.outBinds[1].should.be.exactly(2001);
686+
(Object.prototype.toString.call(result.outBinds[2])).should.eql('[object Date]');
687+
callback();
688+
}
689+
);
690+
},
691+
function(callback) {
692+
connection.execute(
693+
"DROP PROCEDURE test",
694+
function(err) {
695+
should.not.exist(err);
696+
callback();
697+
}
698+
);
699+
}
700+
], done);
701+
})
702+
652703
}) // 43.3
653704

654705
describe('43.4 test attribute - maxArraySize', function() {
@@ -805,7 +856,7 @@ describe('43. plsqlBinding1.js', function() {
805856
);
806857
})
807858

808-
it('43.4.6 negative case: <0', function(done) {
859+
it('43.4.6 negative case: < 0', function(done) {
809860
var bindvars = {
810861
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: -9}
811862
};
@@ -837,7 +888,7 @@ describe('43. plsqlBinding1.js', function() {
837888
);
838889
})
839890

840-
it('43.4.8 negative case: assigning it to be a string', function(done) {
891+
it('43.4.8 negative case: assign a string to it', function(done) {
841892
var bindvars = {
842893
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 'foobar'}
843894
};

0 commit comments

Comments
 (0)