Skip to content

Commit 2bee2b9

Browse files
committed
Add tests for maxSize for Bind OUT/INOUT
1 parent 554a3c5 commit 2bee2b9

File tree

3 files changed

+104
-123
lines changed

3 files changed

+104
-123
lines changed

test/list.txt

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,30 +3635,28 @@ Overview of node-oracledb functional tests
36353635

36363636
142. urowidFunctionBindAsString3.js
36373637
142.1 FUNCTION BIND_IN/OUT as UROWID
3638-
142.1.1 urowid length > 50
3639-
142.1.2 urowid length > 100
3640-
- 142.1.3 urowid length > 200
3638+
142.1.1 urowid length > 200
3639+
142.1.2 urowid length > 500
3640+
142.1.3 urowid length > 2000
36413641
142.2 FUNCTION BIND_IN/OUT as string
3642-
142.2.1 urowid length > 50
3643-
142.2.2 urowid length > 100
3644-
- 142.2.3 urowid length > 200
3642+
142.2.1 urowid length > 200
3643+
142.2.2 urowid length > 500
3644+
142.2.3 urowid length > 2000
36453645
142.3 FUNCTION BIND_IN, UPDATE
3646-
142.3.1 update with UROWID > 50
3647-
142.3.2 update with UROWID > 100
3648-
- 142.3.3 update with UROWID > 200
3646+
142.3.1 update with UROWID > 200
3647+
142.3.2 update with UROWID > 500
3648+
142.3.3 update with UROWID > 2000
36493649

36503650
143. urowidFunctionBindAsString4.js
36513651
143.1 FUNCTION BIND_INOUT as UROWID
3652-
143.1.1 urowid length > 50
3653-
143.1.2 urowid length > 100
3654-
- 143.1.3 urowid length > 200
3655-
- 143.1.4 urowid length > 500
3652+
143.1.1 urowid length > 200
3653+
143.1.2 urowid length > 500
3654+
143.1.3 urowid length > 2000
36563655
143.2 FUNCTION BIND_INOUT as string
3657-
143.2.1 urowid length > 50
3658-
143.2.2 urowid length > 100
3659-
- 143.2.3 urowid length > 200
3660-
- 143.2.4 urowid length > 500
3656+
143.2.1 urowid length > 200
3657+
143.2.2 urowid length > 500
3658+
143.2.3 urowid length > 2000
36613659
143.3 FUNCTION BIND_INOUT, UPDATE
3662-
143.3.1 update with UROWID > 50
3663-
143.3.2 update with UROWID > 100
3664-
- 143.3.3 update with UROWID > 200
3660+
143.3.1 update with UROWID > 200
3661+
143.3.2 update with UROWID > 500
3662+
143.3.3 update with UROWID > 2000

test/urowidFunctionBindAsString3.js

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* 142. urowidFunctionBindAsString3.js
2323
*
2424
* DESCRIPTION
25-
* Testing UROWID(> 50 bytes) plsql function bind in/out as String.
25+
* Testing UROWID(> 200 bytes) plsql function bind in/out as String.
2626
*
2727
* NUMBERING RULE
2828
* Test numbers follow this numbering rule:
@@ -59,7 +59,7 @@ describe('142. urowidFunctionBindAsString3.js', function() {
5959
" EXECUTE IMMEDIATE ( ' \n" +
6060
" CREATE TABLE " + tableName_indexed + " ( \n" +
6161
" c1 NUMBER, \n" +
62-
" c2 VARCHAR2(3000), \n" +
62+
" c2 VARCHAR2(3189), \n" +
6363
" primary key(c1, c2) \n" +
6464
" ) organization index \n" +
6565
" '); \n" +
@@ -146,18 +146,18 @@ describe('142. urowidFunctionBindAsString3.js', function() {
146146
sql.executeSql(connection, fun_drop, {}, {}, done);
147147
});
148148

149-
it('142.1.1 urowid length > 50', function(done) {
150-
var exceptedLen = 50;
149+
it('142.1.1 urowid length > 200', function(done) {
150+
var exceptedLen = 200;
151151
funBindOut(fun_execute, exceptedLen, done);
152152
});
153153

154-
it('142.1.2 urowid length > 100', function(done) {
155-
var exceptedLen = 100;
154+
it('142.1.2 urowid length > 500', function(done) {
155+
var exceptedLen = 500;
156156
funBindOut(fun_execute, exceptedLen, done);
157157
});
158158

159-
it.skip('142.1.3 urowid length > 200', function(done) {
160-
var exceptedLen = 200;
159+
it('142.1.3 urowid length > 2000', function(done) {
160+
var exceptedLen = 2000;
161161
funBindOut(fun_execute, exceptedLen, done);
162162
});
163163

@@ -183,25 +183,25 @@ describe('142. urowidFunctionBindAsString3.js', function() {
183183
sql.executeSql(connection, fun_drop, {}, {}, done);
184184
});
185185

186-
it('142.2.1 urowid length > 50', function(done) {
187-
var exceptedLen = 50;
186+
it('142.2.1 urowid length > 200', function(done) {
187+
var exceptedLen = 200;
188188
funBindOut(fun_execute, exceptedLen, done);
189189
});
190190

191-
it('142.2.2 urowid length > 100', function(done) {
192-
var exceptedLen = 100;
191+
it('142.2.2 urowid length > 500', function(done) {
192+
var exceptedLen = 500;
193193
funBindOut(fun_execute, exceptedLen, done);
194194
});
195195

196-
it.skip('142.2.3 urowid length > 200', function(done) {
197-
var exceptedLen = 200;
196+
it('142.2.3 urowid length > 2000', function(done) {
197+
var exceptedLen = 2000;
198198
funBindOut(fun_execute, exceptedLen, done);
199199
});
200200

201201
});
202202

203203
describe('142.3 FUNCTION BIND_IN, UPDATE', function() {
204-
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN STRING, content_2 IN UROWID) RETURN UROWID\n" +
204+
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN VARCHAR2, content_2 IN UROWID) RETURN UROWID\n" +
205205
"IS \n" +
206206
" tmp UROWID; \n" +
207207
"BEGIN \n" +
@@ -221,21 +221,21 @@ describe('142. urowidFunctionBindAsString3.js', function() {
221221
sql.executeSql(connection, fun_drop, {}, {}, done);
222222
});
223223

224-
it('142.3.1 update with UROWID > 50', function(done) {
224+
it('142.3.1 update with UROWID > 200', function(done) {
225225
var contentLen_1 = 10;
226-
var contentLen_2 = 50;
226+
var contentLen_2 = 200;
227227
funBindOut_update(fun_exec, contentLen_1, contentLen_2, done);
228228
});
229229

230-
it('142.3.2 update with UROWID > 100', function(done) {
230+
it('142.3.2 update with UROWID > 500', function(done) {
231231
var contentLen_1 = 50;
232-
var contentLen_2 = 100;
232+
var contentLen_2 = 500;
233233
funBindOut_update(fun_exec, contentLen_1, contentLen_2, done);
234234
});
235235

236-
it.skip('142.3.3 update with UROWID > 200', function(done) {
236+
it('142.3.3 update with UROWID > 2000', function(done) {
237237
var contentLen_1 = 50;
238-
var contentLen_2 = 200;
238+
var contentLen_2 = 2000;
239239
funBindOut_update(fun_exec, contentLen_1, contentLen_2, done);
240240
});
241241

@@ -265,22 +265,16 @@ describe('142. urowidFunctionBindAsString3.js', function() {
265265
var bindVar_in = {
266266
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
267267
c: { val: urowid, type: oracledb.STRING, dir: oracledb.BIND_IN },
268-
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
268+
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 5000 }
269269
};
270270
connection.execute(
271271
fun_exec,
272272
bindVar_in,
273273
function(err, result) {
274-
if(urowidLen > 200) {
275-
should.exist(err);
276-
// When excuting same function in SQLPLUS, will get PLS-00114: identifier 'XXX' too long
277-
// ORA-06502: PL/SQL: numeric or value error: character string buffer too small
278-
(err.message).should.startWith('ORA-06502:');
279-
} else {
280-
should.not.exist(err);
281-
var resultVal = result.outBinds.o;
282-
should.strictEqual(resultVal, urowid);
283-
}
274+
should.not.exist(err);
275+
var resultVal = result.outBinds.o;
276+
should.strictEqual(resultVal.length, urowidLen);
277+
should.strictEqual(resultVal, urowid);
284278
cb();
285279
}
286280
);
@@ -292,7 +286,7 @@ describe('142. urowidFunctionBindAsString3.js', function() {
292286
var funBindOut_update = function(fun_exec, contentLen_1, contentLen_2, callback) {
293287
var str_1 = random.getRandomLengthString(contentLen_1);
294288
var str_2 = random.getRandomLengthString(contentLen_2);
295-
var urowid_1, urowid_2, urowidLen_2, id_1, id_2;
289+
var urowid_1, urowid_2, urowidLen_1, urowidLen_2, id_1, id_2;
296290
async.series([
297291
function(cb) {
298292
id_1 = insertID;
@@ -305,12 +299,14 @@ describe('142. urowidFunctionBindAsString3.js', function() {
305299
function(err, result) {
306300
should.not.exist(err);
307301
urowid_1 = result.rows[0][0];
302+
urowidLen_1 = urowid_1.length;
303+
urowidLen_1.should.be.above(contentLen_1);
308304
cb();
309305
}
310306
);
311307
},
312308
function(cb) {
313-
id_2 = insertID++;
309+
id_2 = insertID + 1;
314310
var sql_insert = "insert into " + tableName_indexed + " values (" + id_2 + ", '" + str_2 + "')";
315311
sql.executeInsert(connection, sql_insert, {}, {}, cb);
316312
},
@@ -321,6 +317,7 @@ describe('142. urowidFunctionBindAsString3.js', function() {
321317
should.not.exist(err);
322318
urowid_2 = result.rows[0][0];
323319
urowidLen_2 = urowid_2.length;
320+
urowidLen_2.should.be.above(contentLen_2);
324321
cb();
325322
}
326323
);
@@ -330,21 +327,17 @@ describe('142. urowidFunctionBindAsString3.js', function() {
330327
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
331328
c1: { val: urowid_1, type: oracledb.STRING, dir: oracledb.BIND_IN },
332329
c2: { val: urowid_2, type: oracledb.STRING, dir: oracledb.BIND_IN },
333-
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
330+
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 5000 }
334331
};
335332
connection.execute(
336333
fun_exec,
337334
bindVar_in,
338335
function(err, result) {
339-
if(urowidLen_2 > 200) {
340-
should.exist(err);
341-
// ORA-06502: PL/SQL: numeric or value error: character string buffer too small
342-
(err.message).should.startWith('ORA-06502:');
343-
} else {
344-
should.not.exist(err);
345-
var resultVal = result.outBinds.o;
346-
should.strictEqual(resultVal, urowid_2);
347-
}
336+
should.not.exist(err);
337+
var resultVal = result.outBinds.o;
338+
should.strictEqual(resultVal.length, urowidLen_2);
339+
should.strictEqual(resultVal, urowid_2);
340+
insertID = insertID + 10;
348341
cb();
349342
}
350343
);

0 commit comments

Comments
 (0)