Add new LOB tests
This commit is contained in:
parent
5b9be5e197
commit
fa8cd0b127
|
@ -0,0 +1,851 @@
|
|||
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* You may not use the identified files except in compliance with the Apache
|
||||
* License, Version 2.0 (the "License.")
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
|
||||
* See LICENSE.md for relevant licenses.
|
||||
*
|
||||
* NAME
|
||||
* 78. blobDMLBindAsBuffer.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing BLOB binding as Buffer with DML.
|
||||
*
|
||||
* NUMBERING RULE
|
||||
* Test numbers follow this numbering rule:
|
||||
* 1 - 20 are reserved for basic functional tests
|
||||
* 21 - 50 are reserved for data type supporting tests
|
||||
* 51 onwards are for other tests
|
||||
*
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var random = require('./random.js');
|
||||
var fs = require('fs');
|
||||
|
||||
describe('78.blobDMLBindAsBuffer.js', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
var connection = null;
|
||||
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
|
||||
var node6plus = false; // assume node runtime version is lower than 6
|
||||
var proc_blob_1 = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_dml_blob_1 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_dml_blob_1 ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" blob BLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var sql2DropTable1 = "DROP TABLE nodb_dml_blob_1 PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
// Check whether instant client runtime version is smaller than 12.1.0.2
|
||||
if(oracledb.oracleClientVersion < 1201000200)
|
||||
client11gPlus = false;
|
||||
// Check whether node runtime version is >= 6 or not
|
||||
if ( process.versions["node"].substring (0, 1) >= "6")
|
||||
node6plus = true;
|
||||
|
||||
done();
|
||||
});
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}); // after
|
||||
|
||||
var executeSQL = function(sql, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var insertIntoBlobTable1 = function(id, content, callback, case64KPlus) {
|
||||
if(content == "EMPTY_BLOB") {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, EMPTY_BLOB())",
|
||||
[ id ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER }
|
||||
},
|
||||
function(err, result) {
|
||||
if(case64KPlus === true && client11gPlus === false) {
|
||||
should.exist(err);
|
||||
// NJS-050: data must be shorter than 65535
|
||||
(err.message).should.startWith('NJS-050:');
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
}
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
var updateBlobTable1 = function(id, content, case64KPlus, callback) {
|
||||
if(content == "EMPTY_BLOB") {
|
||||
connection.execute(
|
||||
"UPDATE nodb_dml_blob_1 set blob = EMPTY_BLOB() where id = :ID",
|
||||
{ ID: id },
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
connection.execute(
|
||||
"UPDATE nodb_dml_blob_1 set blob = :C where id = :ID",
|
||||
{ ID: id, C: content },
|
||||
function(err, result){
|
||||
if(case64KPlus === true && client11gPlus === false) {
|
||||
should.exist(err);
|
||||
// NJS-050: data must be shorter than 65535
|
||||
(err.message).should.startWith('NJS-050:');
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
}
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// compare the inserted blob with orginal content
|
||||
var verifyBlobValueWithBuffer = function(selectSql, originalBuffer, specialStr, callback) {
|
||||
connection.execute(
|
||||
selectSql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var lob = result.rows[0][0];
|
||||
if(originalBuffer == '' || originalBuffer == undefined) {
|
||||
should.not.exist(lob);
|
||||
return callback();
|
||||
} else {
|
||||
should.exist(lob);
|
||||
var blobData = node6plus ? Buffer.alloc(0) : new Buffer(0);
|
||||
var totalLength = 0;
|
||||
|
||||
lob.on('data', function(chunk) {
|
||||
totalLength = totalLength + chunk.length;
|
||||
blobData = Buffer.concat([blobData, chunk], totalLength);
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.not.exist(err, "lob.on 'error' event.");
|
||||
});
|
||||
|
||||
lob.on('end', function() {
|
||||
if(originalBuffer == "EMPTY_BLOB") {
|
||||
var nullBuffer = node6plus ? Buffer.from('', "utf-8") : new Buffer('', "utf-8");
|
||||
should.strictEqual(blobData.equals(nullBuffer), true);
|
||||
} else {
|
||||
should.strictEqual(totalLength, originalBuffer.length);
|
||||
var specStrLength = specialStr.length;
|
||||
should.strictEqual(blobData.toString('utf8', 0, specStrLength), specialStr);
|
||||
should.strictEqual(blobData.toString('utf8', (totalLength - specStrLength), totalLength), specialStr);
|
||||
should.strictEqual(blobData.equals(originalBuffer), true);
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var checkInsertResult = function(id, content, specialStr, case64KPlus, callback) {
|
||||
if(case64KPlus === true && client11gPlus === false) {
|
||||
callback();
|
||||
} else {
|
||||
var sql = "select blob from nodb_dml_blob_1 where id = " + id;
|
||||
verifyBlobValueWithBuffer(sql, content, specialStr, callback);
|
||||
}
|
||||
};
|
||||
|
||||
// Generate id for insert blob into db
|
||||
var insertID = 0;
|
||||
var getID = function() {
|
||||
insertID = insertID + 1;
|
||||
return insertID;
|
||||
};
|
||||
|
||||
describe('78.1 BLOB, INSERT', function() {
|
||||
before(function(done) {
|
||||
executeSQL(proc_blob_1, done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
executeSQL(sql2DropTable1, done);
|
||||
}); // after
|
||||
|
||||
it('78.1.1 works with EMPTY_BLOB', function(done) {
|
||||
var id = getID();
|
||||
var content = "EMPTY_BLOB";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.1
|
||||
|
||||
it('78.1.2 works with empty buffer', function(done) {
|
||||
var id = getID();
|
||||
var bigStr = '';
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.2
|
||||
|
||||
it('78.1.3 works with empty buffer and bind in maxSize set to 32767', function(done) {
|
||||
var id = getID();
|
||||
var bigStr = '';
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER, maxSize: 32767 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.3
|
||||
|
||||
it('78.1.4 works with empty buffer and bind in maxSize set to 50000', function(done) {
|
||||
var id = getID();
|
||||
var bigStr = '';
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER, maxSize: 50000 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.4
|
||||
|
||||
it('78.1.5 works with undefined', function(done) {
|
||||
var id = getID();
|
||||
var content = undefined;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.5
|
||||
|
||||
it('78.1.6 works with null', function(done) {
|
||||
var id = getID();
|
||||
var content = null;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.6
|
||||
|
||||
it('78.1.7 works with null and bind in maxSize set to 32767', function(done) {
|
||||
var id = getID();
|
||||
var content = null;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER, maxSize: 32767 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.7
|
||||
|
||||
it('78.1.8 works with null and bind in maxSize set to 50000', function(done) {
|
||||
var id = getID();
|
||||
var content = null;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER, maxSize: 50000 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.8
|
||||
|
||||
it('78.1.9 works with NaN', function(done) {
|
||||
var id = getID();
|
||||
var content = NaN;
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER }
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-011: encountered bind value and type mismatch in parameter 2
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 78.1.9
|
||||
|
||||
it('78.1.10 works with 0', function(done) {
|
||||
var id = getID();
|
||||
var content = 0;
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER }
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-011: encountered bind value and type mismatch in parameter 2
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 78.1.10
|
||||
|
||||
it('78.1.11 works with Buffer length 32K', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 32768;
|
||||
var specialStr = "78.1.11";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.11
|
||||
|
||||
it('78.1.12 works with Buffer length (64K - 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 65535;
|
||||
var specialStr = "78.1.12";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.12
|
||||
|
||||
it('78.1.13 works with Buffer length (64K + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 65537;
|
||||
var specialStr = "78.1.13";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.13
|
||||
|
||||
it('78.1.14 works with Buffer length (1MB + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 1048577; // 1 * 1024 * 1024 + 1;
|
||||
var specialStr = "78.1.14";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.14
|
||||
|
||||
it('78.1.15 works with Buffer length (5MB + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 5242881; // 5 * 1024 * 1024 + 1;
|
||||
var specialStr = "78.1.15";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.15
|
||||
|
||||
it('78.1.16 works with Buffer length (10MB + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 10485761; // 10 * 1024 * 1024 + 1;
|
||||
var specialStr = "78.1.16";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.16
|
||||
|
||||
it('78.1.17 bind value and type mismatch', function(done) {
|
||||
var id = getID();
|
||||
var content = 100;
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER }
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-011: encountered bind value and type mismatch in parameter 2
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 78.1.17
|
||||
|
||||
it('78.1.18 mixing named with positional binding', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 40000;
|
||||
var specialStr = "78.1.18";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:1, :2)",
|
||||
[
|
||||
id, { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER }
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.18
|
||||
|
||||
it('78.1.19 bind with invalid BLOB', function(done) {
|
||||
var id = getID();
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:1, :2)",
|
||||
[
|
||||
id, { val : {}, dir : oracledb.BIND_IN, type : oracledb.BUFFER }
|
||||
],
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-012: encountered invalid bind datatype in parameter 2
|
||||
(err.message).should.startWith('NJS-012:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 78.1.19
|
||||
|
||||
it('78.1.20 Negative: RETURNING INTO with bind type BUFFER', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 400;
|
||||
var specialStr = "78.1.20";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var sql = "INSERT INTO nodb_dml_blob_1 (id, blob) VALUES (:i, :c) RETURNING blob INTO :lobbv";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql,
|
||||
{
|
||||
i: id,
|
||||
c: { val: content, type: oracledb.BUFFER, dir: oracledb.BIND_IN },
|
||||
lobbv: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: contentLength }
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-028: RAW database type is not supported with DML Returning statements
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.20
|
||||
|
||||
it('78.1.21 Negative: RETURNING INTO with autocommit on', function(done) {
|
||||
var id = getID();
|
||||
var sql = "INSERT INTO nodb_dml_blob_1 (id, blob) VALUES (:i, EMPTY_BLOB()) RETURNING blob INTO :lobbv";
|
||||
var inFileName = './test/tree.jpg';
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql,
|
||||
{
|
||||
i: id,
|
||||
lobbv: { type: oracledb.BLOB, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ autoCommit: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var inStream = fs.createReadStream(inFileName);
|
||||
var lob = result.outBinds.lobbv[0];
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.exist(err);
|
||||
// ORA-22990: LOB locators cannot span transactions
|
||||
(err.message).should.startWith('ORA-22990:');
|
||||
});
|
||||
|
||||
inStream.on('error', function(err) {
|
||||
should.not.exist(err, "inStream.on 'error' event");
|
||||
});
|
||||
|
||||
lob.on('close', function(err) {
|
||||
should.not.exist(err);
|
||||
connection.commit( function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
|
||||
inStream.pipe(lob); // copies the text to the CLOB
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.21
|
||||
|
||||
it('78.1.22 works with bind in maxSize smaller than buffer size', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 32768;
|
||||
var specialStr = "78.1.22";
|
||||
var bigStr = random.getRandomString(contentLength, specialStr);
|
||||
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.BUFFER, maxSize: 1 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.1.22
|
||||
|
||||
}); // 78.1
|
||||
|
||||
describe('78.2 BLOB, UPDATE', function() {
|
||||
insertID = 0;
|
||||
|
||||
before(function(done) {
|
||||
executeSQL(proc_blob_1, done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
executeSQL(sql2DropTable1, done);
|
||||
}); // after
|
||||
|
||||
it('78.2.1 update EMPTY_BLOB column', function(done) {
|
||||
var id = getID();
|
||||
var content_1 = "EMPTY_BLOB";
|
||||
var contentLength_2 = 32768;
|
||||
var specialStr_2 = "78.2.1";
|
||||
var bigStr_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, null, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateBlobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, specialStr_2, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.2.1
|
||||
|
||||
it('78.2.2 update a cloumn with EMPTY_BLOB', function(done) {
|
||||
var id = getID();
|
||||
var contentLength_1 = 50000;
|
||||
var specialStr_1 = "78.2.2";
|
||||
var bigStr_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
var content_2 = "EMPTY_BLOB";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, specialStr_1, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateBlobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.2.2
|
||||
|
||||
it('78.2.3 update EMPTY_BLOB column with empty buffer', function(done) {
|
||||
var id = getID();
|
||||
var content_1 = "EMPTY_BLOB";
|
||||
var content_2 = "";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, null, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateBlobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.2.3
|
||||
|
||||
it('78.2.4 update empty buffer column', function(done) {
|
||||
var id = getID();
|
||||
var bigStr_1 = "";
|
||||
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
var contentLength_2 = 54321;
|
||||
var specialStr_2 = "78.2.4";
|
||||
var bigStr_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, null, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateBlobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, specialStr_2, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.2.4
|
||||
|
||||
it('78.2.5 update a column with empty buffer', function(done) {
|
||||
var id = getID();
|
||||
var contentLength_1 = 50000;
|
||||
var specialStr_1 = "78.2.2";
|
||||
var bigStr_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
var content_2 = "";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, specialStr_1, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateBlobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.2.5
|
||||
|
||||
it('78.2.6 update a column with (10MB + 1) buffer', function(done) {
|
||||
var id = getID();
|
||||
var contentLength_1 = 50000;
|
||||
var specialStr_1 = "78.2.6_1";
|
||||
var bigStr_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
var contentLength_2 = 10485761; // 10 * 1024 * 1024 + 1;
|
||||
var specialStr_2 = "78.2.6_2";
|
||||
var bigStr_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, specialStr_1, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateBlobTable1(id, content_2, true, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, specialStr_2, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 78.2.6
|
||||
|
||||
}); // 78.2
|
||||
});
|
|
@ -38,6 +38,7 @@ var should = require('should');
|
|||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var fs = require('fs');
|
||||
var random = require('./random.js');
|
||||
|
||||
describe('75.blobPlsqlBindAsBuffer.js', function() {
|
||||
var connection = null;
|
||||
|
@ -289,15 +290,6 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
);
|
||||
};
|
||||
|
||||
var getRandomString = function(length, specialStr) {
|
||||
var str='';
|
||||
var strLength = length - specialStr.length * 2;
|
||||
for( ; str.length < strLength; str += Math.random().toString(36).slice(2));
|
||||
str = str.substr(0, strLength);
|
||||
str = specialStr + str + specialStr;
|
||||
return str;
|
||||
};
|
||||
|
||||
describe('75.1 BLOB, PLSQL, BIND_IN', function() {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_blobs_in_751 (blob_id IN NUMBER, blob_in IN BLOB)\n" +
|
||||
"AS \n" +
|
||||
|
@ -321,7 +313,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 32768;
|
||||
var sequence = 1;
|
||||
var specialStr = "75.1.1";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -355,7 +347,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 65535;
|
||||
var sequence = 2;
|
||||
var specialStr = "75.1.2";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -524,7 +516,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 50000;
|
||||
var sequence = 6;
|
||||
var specialStr = "75.1.9";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = [ sequence, { val: bufferStr, type: oracledb.BUFFER, dir: oracledb.BIND_IN, maxSize: size } ];
|
||||
|
||||
|
@ -551,7 +543,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 65535;
|
||||
var sequence = 7;
|
||||
var specialStr = "75.1.10";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -622,7 +614,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 32768;
|
||||
var sequence = 11;
|
||||
var specialStr = "75.2.1";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -664,7 +656,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 65535;
|
||||
var sequence = 12;
|
||||
var specialStr = "75.2.2";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -778,7 +770,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 50000;
|
||||
var sequence = 16;
|
||||
var specialStr = "75.2.6";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = [ sequence, { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: size } ];
|
||||
|
||||
|
@ -813,7 +805,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 50000;
|
||||
var sequence = 17;
|
||||
var specialStr = "75.2.7";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = [ sequence, { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: size - 1 } ];
|
||||
|
||||
|
@ -844,7 +836,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size = 50000;
|
||||
var sequence = 18;
|
||||
var specialStr = "75.2.8";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -885,6 +877,14 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
"END nodb_blob_in_out_753;";
|
||||
var sqlRun = "begin nodb_blob_in_out_753(lob_in_out => :lob_in_out); end;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_blob_in_out_753";
|
||||
var blob_proc_inout_7531 = "CREATE OR REPLACE PROCEDURE nodb_blob_in_out_7531 (lob_id IN NUMBER, lob_in_out IN OUT RAW) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into nodb_tab_blob_in (id, blob_1) values (lob_id, lob_in_out); \n" +
|
||||
" select blob_1 into lob_in_out from nodb_tab_blob_in where id = lob_id; \n" +
|
||||
"END nodb_blob_in_out_7531;";
|
||||
var sqlRun_7531 = "begin nodb_blob_in_out_7531(:i, :io); end;";
|
||||
var proc_drop_7531 = "DROP PROCEDURE nodb_blob_in_out_7531";
|
||||
|
||||
before(function(done) {
|
||||
executeSQL(blob_proc_inout, done);
|
||||
|
@ -897,7 +897,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
it('75.3.1 PLSQL, BIND_INOUT with Buffer size 32K', function(done) {
|
||||
var size = 32768;
|
||||
var specialStr = "75.3.1";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.BUFFER, val: bufferStr, maxSize: size }
|
||||
|
@ -921,7 +921,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
it('75.3.2 PLSQL, BIND_INOUT with Buffer size 32K - 1', function(done) {
|
||||
var size = 32767;
|
||||
var specialStr = "75.3.2";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.BUFFER, val: bufferStr, maxSize: size }
|
||||
|
@ -945,7 +945,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
it('75.3.3 PLSQL, BIND_INOUT with Buffer size 64K - 1', function(done) {
|
||||
var size = 65535;
|
||||
var specialStr = "75.3.3";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.BUFFER, val: bufferStr, maxSize: size }
|
||||
|
@ -966,7 +966,98 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
);
|
||||
}); // 75.3.3
|
||||
|
||||
});
|
||||
it('75.3.4 PLSQL, BIND_INOUT with OUT data > maxSize', function(done) {
|
||||
var specialStr = "75.3.4";
|
||||
var len = 65535;
|
||||
var bigStr = random.getRandomString(len, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.BUFFER, val: bufferStr, maxSize: len - 1 }
|
||||
};
|
||||
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
bindVar,
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-016: buffer is too small for OUT binds
|
||||
(err.message).should.startWith('NJS-016');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 75.3.4
|
||||
|
||||
it('75.3.5 PLSQL, bind out to varchar2 with OUT data < maxSize', function(done) {
|
||||
var sequence = 30;
|
||||
var specialStr = "75.3.5";
|
||||
var len = 300;
|
||||
var bigStr = random.getRandomString(len, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
executeSQL(blob_proc_inout_7531, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar_7531 = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
io: { val:bufferStr, type: oracledb.BUFFER, dir: oracledb.BIND_INOUT, maxSize: len }
|
||||
};
|
||||
connection.execute(
|
||||
sqlRun_7531,
|
||||
bindVar_7531,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.io.toString('utf8');
|
||||
var resultLength = resultVal.length;
|
||||
var specStrLength = specialStr.length;
|
||||
should.strictEqual(resultLength, len);
|
||||
should.strictEqual(resultVal.substring(0, specStrLength), specialStr);
|
||||
should.strictEqual(resultVal.substring(resultLength - specStrLength, resultLength), specialStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
executeSQL(proc_drop_7531, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 75.3.5
|
||||
|
||||
it('75.3.6 PLSQL, bind out to varchar2 with OUT data > maxSize', function(done) {
|
||||
var sequence = 30;
|
||||
var specialStr = "75.3.6";
|
||||
var len = 300;
|
||||
var bigStr = random.getRandomString(len, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
executeSQL(blob_proc_inout_7531, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar_7531 = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
io: { val:bufferStr, type: oracledb.BUFFER, dir: oracledb.BIND_INOUT, maxSize: len - 1 }
|
||||
};
|
||||
connection.execute(
|
||||
sqlRun_7531,
|
||||
bindVar_7531,
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// ORA-01460: unimplemented or unreasonable conversion requested
|
||||
(err.message).should.startWith('ORA-01460');
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
executeSQL(proc_drop_7531, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 75.3.6
|
||||
|
||||
}); // 75.3
|
||||
|
||||
describe('75.4 Multiple BLOBs, BIND_IN', function() {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_blobs_in_754 (blob_id IN NUMBER, blob_1 IN BLOB, blob_2 IN BLOB)\n" +
|
||||
|
@ -989,8 +1080,8 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size_1 = 32768;
|
||||
var size_2 = 50000;
|
||||
var specialStr = "75.4.1";
|
||||
var bigStr_1 = getRandomString(size_1, specialStr);
|
||||
var bigStr_2 = getRandomString(size_2, specialStr);
|
||||
var bigStr_1 = random.getRandomString(size_1, specialStr);
|
||||
var bigStr_2 = random.getRandomString(size_2, specialStr);
|
||||
var bufferStr_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
var bufferStr_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
|
||||
var sequence = 51;
|
||||
|
@ -1028,7 +1119,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var preparedCLOBID = 301;
|
||||
var sequence = 52;
|
||||
var size_1 = 32768;
|
||||
var bigStr_1 = getRandomString(size_1, specialStr);
|
||||
var bigStr_1 = random.getRandomString(size_1, specialStr);
|
||||
var bufferStr_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
|
||||
async.series([
|
||||
|
@ -1115,8 +1206,8 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var size_1 = 32768;
|
||||
var size_2 = 50000;
|
||||
var sequence = 111;
|
||||
var bigStr_1 = getRandomString(size_1, specialStr);
|
||||
var bigStr_2 = getRandomString(size_2, specialStr);
|
||||
var bigStr_1 = random.getRandomString(size_1, specialStr);
|
||||
var bigStr_2 = random.getRandomString(size_2, specialStr);
|
||||
var bufferStr_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
var bufferStr_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
|
||||
var bindVar = {
|
||||
|
@ -1163,7 +1254,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
it('75.5.2 PLSQL, BIND_OUT, bind a JPG file and a Buffer', function(done) {
|
||||
var specialStr = "75.5.2";
|
||||
var size_1 = 32768;
|
||||
var bigStr_1 = getRandomString(size_1, specialStr);
|
||||
var bigStr_1 = random.getRandomString(size_1, specialStr);
|
||||
var bufferStr_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
var sequence = 112;
|
||||
var bindVar = {
|
||||
|
@ -1264,7 +1355,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var preparedCLOBID = 500;
|
||||
var size_1 = 32768;
|
||||
var specialStr = "75.6.1";
|
||||
var bigStr_1 = getRandomString(size_1, specialStr);
|
||||
var bigStr_1 = random.getRandomString(size_1, specialStr);
|
||||
var bufferStr_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
|
||||
async.series([
|
||||
|
@ -1326,7 +1417,7 @@ describe('75.blobPlsqlBindAsBuffer.js', function() {
|
|||
var preparedCLOBID = 501;
|
||||
var size_1 = 65535;
|
||||
var specialStr = "75.6.2";
|
||||
var bigStr_1 = getRandomString(size_1, specialStr);
|
||||
var bigStr_1 = random.getRandomString(size_1, specialStr);
|
||||
var bufferStr_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
|
||||
|
||||
async.series([
|
||||
|
|
|
@ -0,0 +1,832 @@
|
|||
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* You may not use the identified files except in compliance with the Apache
|
||||
* License, Version 2.0 (the "License.")
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
|
||||
* See LICENSE.md for relevant licenses.
|
||||
*
|
||||
* NAME
|
||||
* 77. clobDMLBindAsString.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing CLOB binding as String with DML.
|
||||
*
|
||||
* NUMBERING RULE
|
||||
* Test numbers follow this numbering rule:
|
||||
* 1 - 20 are reserved for basic functional tests
|
||||
* 21 - 50 are reserved for data type supporting tests
|
||||
* 51 onwards are for other tests
|
||||
*
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var random = require('./random.js');
|
||||
var fs = require('fs');
|
||||
|
||||
describe('77.clobDMLBindAsString.js', function() {
|
||||
this.timeout(100000);
|
||||
|
||||
var connection = null;
|
||||
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
|
||||
var proc_clob_1 = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_dml_clob_1 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_dml_clob_1 ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" clob CLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var sql2DropTable1 = "DROP TABLE nodb_dml_clob_1 PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
// Check whether instant client runtime version is smaller than 12.1.0.2
|
||||
if(oracledb.oracleClientVersion < 1201000200)
|
||||
client11gPlus = false;
|
||||
|
||||
done();
|
||||
});
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}); // after
|
||||
|
||||
var executeSQL = function(sql, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var insertIntoClobTable1 = function(id, content, callback, case64KPlus) {
|
||||
if(content == "EMPTY_CLOB") {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, EMPTY_CLOB())",
|
||||
[ id ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
},
|
||||
function(err, result) {
|
||||
if(case64KPlus === true && client11gPlus === false) {
|
||||
should.exist(err);
|
||||
// NJS-050: data must be shorter than 65535
|
||||
(err.message).should.startWith('NJS-050:');
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
}
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
var updateClobTable1 = function(id, content, case64KPlus, callback) {
|
||||
if(content == "EMPTY_CLOB") {
|
||||
connection.execute(
|
||||
"UPDATE nodb_dml_clob_1 set clob = EMPTY_CLOB() where id = :ID",
|
||||
{ ID: id },
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
connection.execute(
|
||||
"UPDATE nodb_dml_clob_1 set clob = :C where id = :ID",
|
||||
{ ID: id, C: content },
|
||||
function(err, result){
|
||||
if(case64KPlus === true && client11gPlus === false) {
|
||||
should.exist(err);
|
||||
// NJS-050: data must be shorter than 65535
|
||||
(err.message).should.startWith('NJS-050:');
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
}
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// compare the inserted clob with orginal content
|
||||
var verifyClobValueWithString = function(selectSql, originalString, specialStr, callback) {
|
||||
connection.execute(
|
||||
selectSql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var lob = result.rows[0][0];
|
||||
if(originalString == '' || originalString == undefined || originalString == null) {
|
||||
should.not.exist(lob);
|
||||
return callback();
|
||||
} else {
|
||||
should.exist(lob);
|
||||
// set the encoding so we get a 'string' not a 'buffer'
|
||||
lob.setEncoding('utf8');
|
||||
var clobData = '';
|
||||
|
||||
lob.on('data', function(chunk) {
|
||||
clobData += chunk;
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.not.exist(err, "lob.on 'error' event.");
|
||||
});
|
||||
|
||||
lob.on('end', function(err) {
|
||||
should.not.exist(err);
|
||||
if (originalString == "EMPTY_CLOB") {
|
||||
should.strictEqual(clobData, "");
|
||||
} else {
|
||||
var resultLength = clobData.length;
|
||||
var specStrLength = specialStr.length;
|
||||
should.strictEqual(resultLength, originalString.length);
|
||||
should.strictEqual(clobData.substring(0, specStrLength), specialStr);
|
||||
should.strictEqual(clobData.substring(resultLength - specStrLength, resultLength), specialStr);
|
||||
}
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var checkInsertResult = function(id, content, specialStr, case64KPlus, callback) {
|
||||
if(case64KPlus === true && client11gPlus === false) {
|
||||
callback();
|
||||
} else {
|
||||
var sql = "select clob from nodb_dml_clob_1 where id = " + id;
|
||||
verifyClobValueWithString(sql, content, specialStr, callback);
|
||||
}
|
||||
};
|
||||
|
||||
// Generate id for insert clob into db
|
||||
var insertID = 0;
|
||||
var getID = function() {
|
||||
insertID = insertID + 1;
|
||||
return insertID;
|
||||
};
|
||||
|
||||
describe('77.1 CLOB, INSERT', function() {
|
||||
before(function(done) {
|
||||
executeSQL(proc_clob_1, done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
executeSQL(sql2DropTable1, done);
|
||||
}); // after
|
||||
|
||||
it('77.1.1 works with EMPTY_CLOB', function(done) {
|
||||
var id = getID();
|
||||
var content = "EMPTY_CLOB";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.1
|
||||
|
||||
it('77.1.2 works with empty string', function(done) {
|
||||
var id = getID();
|
||||
var content = '';
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.2
|
||||
|
||||
it('77.1.3 works with empty string and bind in maxSize set to 32767', function(done) {
|
||||
var id = getID();
|
||||
var content = "";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 32767 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.3
|
||||
|
||||
it('77.1.4 works with empty string and bind in maxSize set to 50000', function(done) {
|
||||
var id = getID();
|
||||
var content = "";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 50000 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.4
|
||||
|
||||
it('77.1.5 works with undefined', function(done) {
|
||||
var id = getID();
|
||||
var content = undefined;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.5
|
||||
|
||||
it('77.1.6 works with null', function(done) {
|
||||
var id = getID();
|
||||
var content = null;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.6
|
||||
|
||||
it('77.1.7 works with null and bind in maxSize set to 32767', function(done) {
|
||||
var id = getID();
|
||||
var content = null;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 32767 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.7
|
||||
|
||||
it('77.1.8 works with null and bind in maxSize set to 50000', function(done) {
|
||||
var id = getID();
|
||||
var content = null;
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 50000 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.8
|
||||
|
||||
it('77.1.9 works with NaN', function(done) {
|
||||
var id = getID();
|
||||
var content = NaN;
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-011: encountered bind value and type mismatch in parameter 2
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 77.1.9
|
||||
|
||||
it('77.1.10 works with 0', function(done) {
|
||||
var id = getID();
|
||||
var content = 0;
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-011: encountered bind value and type mismatch in parameter 2
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 77.1.10
|
||||
|
||||
it('77.1.11 works with String length 32K', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 32768;
|
||||
var specialStr = "77.1.11";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.11
|
||||
|
||||
it('77.1.12 works with String length (64K - 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 65535;
|
||||
var specialStr = "77.1.12";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.12
|
||||
|
||||
it('77.1.13 works with String length (64K + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 65537;
|
||||
var specialStr = "77.1.13";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.13
|
||||
|
||||
it('77.1.14 works with String length (1MB + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 1048577; // 1 * 1024 * 1024 + 1;
|
||||
var specialStr = "77.1.14";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.14
|
||||
|
||||
it('77.1.15 works with String length (5MB + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 5242881; // 5 * 1024 * 1024 + 1;
|
||||
var specialStr = "77.1.15";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.15
|
||||
|
||||
it('77.1.16 works with String length (10MB + 1)', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 10485761; // 10 * 1024 * 1024 + 1;
|
||||
var specialStr = "77.1.16";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content, cb, true);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.16
|
||||
|
||||
it('77.1.17 bind value and type mismatch', function(done) {
|
||||
var id = getID();
|
||||
var content = 100;
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-011: encountered bind value and type mismatch in parameter 2
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 77.1.17
|
||||
|
||||
it('77.1.18 mixing named with positional binding', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 40000;
|
||||
var specialStr = "77.1.18";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:1, :2)",
|
||||
[
|
||||
id, { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.18
|
||||
|
||||
it('77.1.19 bind with invalid CLOB', function(done) {
|
||||
var id = getID();
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:1, :2)",
|
||||
[
|
||||
id, { val : {}, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
],
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-012: encountered invalid bind datatype in parameter 2
|
||||
(err.message).should.startWith('NJS-012:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 77.1.19
|
||||
|
||||
it('77.1.20 RETURNING INTO with bind type STRING', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 400;
|
||||
var specialStr = "77.1.20";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
var sql = "INSERT INTO nodb_dml_clob_1 (id, clob) VALUES (:i, :c) RETURNING clob INTO :lobbv";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql,
|
||||
{
|
||||
i: id,
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
lobbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: contentLength }
|
||||
},
|
||||
{ autoCommit: false },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
(result.outBinds.lobbv.length).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.20
|
||||
|
||||
it('77.1.21 Negative: RETURNING INTO with autocommit on', function(done) {
|
||||
var id = getID();
|
||||
var sql = "INSERT INTO nodb_dml_clob_1 (id, clob) VALUES (:i, EMPTY_CLOB()) RETURNING clob INTO :lobbv";
|
||||
var inFileName = './test/clobexample.txt';
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql,
|
||||
{
|
||||
i: id,
|
||||
lobbv: { type: oracledb.CLOB, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ autoCommit: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var inStream = fs.createReadStream(inFileName);
|
||||
var lob = result.outBinds.lobbv[0];
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.exist(err);
|
||||
// ORA-22990: LOB locators cannot span transactions
|
||||
(err.message).should.startWith('ORA-22990:');
|
||||
});
|
||||
|
||||
inStream.on('error', function(err) {
|
||||
should.not.exist(err, "inStream.on 'error' event");
|
||||
});
|
||||
|
||||
lob.on('close', function(err) {
|
||||
should.not.exist(err);
|
||||
connection.commit( function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
});
|
||||
});
|
||||
|
||||
inStream.pipe(lob); // copies the text to the CLOB
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.21
|
||||
|
||||
it('77.1.22 works with bind in maxSize smaller than string length', function(done) {
|
||||
var id = getID();
|
||||
var contentLength = 32768;
|
||||
var specialStr = "77.1.22";
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dml_clob_1 VALUES (:ID, :C)",
|
||||
{
|
||||
ID : { val : id },
|
||||
C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 1 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content, specialStr, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.1.22
|
||||
|
||||
}); // 77.1
|
||||
|
||||
describe('77.2 CLOB, UPDATE', function() {
|
||||
insertID = 0;
|
||||
|
||||
before(function(done) {
|
||||
executeSQL(proc_clob_1, done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
executeSQL(sql2DropTable1, done);
|
||||
}); // after
|
||||
|
||||
it('77.2.1 update EMPTY_CLOB column', function(done) {
|
||||
var id = getID();
|
||||
var content_1 = "EMPTY_CLOB";
|
||||
var contentLength_2 = 32768;
|
||||
var specialStr_2 = "77.2.1";
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, null, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateClobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, specialStr_2, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.2.1
|
||||
|
||||
it('77.2.2 update a cloumn with EMPTY_CLOB', function(done) {
|
||||
var id = getID();
|
||||
var contentLength_1 = 50000;
|
||||
var specialStr_1 = "77.2.2";
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var content_2 = "EMPTY_CLOB";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, specialStr_1, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateClobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.2.2
|
||||
|
||||
it('77.2.3 update EMPTY_CLOB column with empty string', function(done) {
|
||||
var id = getID();
|
||||
var content_1 = "EMPTY_CLOB";
|
||||
var content_2 = "";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, null, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateClobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.2.3
|
||||
|
||||
it('77.2.4 update empty string column', function(done) {
|
||||
var id = getID();
|
||||
var content_1 = "";
|
||||
var contentLength_2 = 54321;
|
||||
var specialStr_2 = "77.2.4";
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, null, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateClobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, specialStr_2, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.2.4
|
||||
|
||||
it('77.2.5 update a column with empty string', function(done) {
|
||||
var id = getID();
|
||||
var contentLength_1 = 50000;
|
||||
var specialStr_1 = "77.2.2";
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var content_2 = "";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, specialStr_1, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateClobTable1(id, content_2, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, null, false, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.2.5
|
||||
|
||||
it('77.2.6 update a column with (10MB + 1) string', function(done) {
|
||||
var id = getID();
|
||||
var contentLength_1 = 50000;
|
||||
var specialStr_1 = "77.2.6_1";
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var contentLength_2 = 10485761; // 10 * 1024 * 1024 + 1;
|
||||
var specialStr_2 = "77.2.6_2";
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable1(id, content_1, cb, false);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_1, specialStr_1, false, cb);
|
||||
},
|
||||
function(cb) {
|
||||
updateClobTable1(id, content_2, true, cb);
|
||||
},
|
||||
function(cb) {
|
||||
checkInsertResult(id, content_2, specialStr_2, true, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 77.2.6
|
||||
|
||||
}); // 77.2
|
||||
});
|
|
@ -38,6 +38,7 @@ var should = require('should');
|
|||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var fs = require('fs');
|
||||
var random = require('./random.js');
|
||||
|
||||
describe('74.clobPlsqlBindAsString.js', function() {
|
||||
var connection = null;
|
||||
|
@ -289,15 +290,6 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
);
|
||||
};
|
||||
|
||||
var getRandomString = function(length, specialStr) {
|
||||
var str='';
|
||||
var strLength = length - specialStr.length * 2;
|
||||
for( ; str.length < strLength; str += Math.random().toString(36).slice(2));
|
||||
str = str.substr(0, strLength);
|
||||
str = specialStr + str + specialStr;
|
||||
return str;
|
||||
};
|
||||
|
||||
describe('74.1 CLOB, PLSQL, BIND_IN', function() {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_in_741 (clob_id IN NUMBER, clob_in IN CLOB)\n" +
|
||||
"AS \n" +
|
||||
|
@ -321,7 +313,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var len = 32768;
|
||||
var sequence = 1;
|
||||
var specialStr = "74.1.1";
|
||||
var clobStr = getRandomString(len, specialStr);
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
|
@ -353,7 +345,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var len = 65535;
|
||||
var sequence = 2;
|
||||
var specialStr = "74.1.2";
|
||||
var clobStr = getRandomString(len, specialStr);
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
|
@ -517,7 +509,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var len = 50000;
|
||||
var sequence = 6;
|
||||
var specialStr = "74.1.9";
|
||||
var clobStr = getRandomString(len, specialStr);
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
var bindVar = [ sequence, { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 } ];
|
||||
|
||||
async.series([
|
||||
|
@ -584,7 +576,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var len = 32768;
|
||||
var sequence = 11;
|
||||
var specialStr = "74.2.1";
|
||||
var clobStr = getRandomString(len, specialStr);
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
|
@ -617,7 +609,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
|
||||
}); // 74.2.1
|
||||
|
||||
it('74.2.2 PLSQL, BIND_OUT with String length 34K - 1', function(done) {
|
||||
it('74.2.2 PLSQL, BIND_OUT with String length 64K - 1', function(done) {
|
||||
// The upper limit on the number of bytes of data that can be bound as
|
||||
// `STRING` or `BUFFER` when node-oracledb is linked with Oracle Client
|
||||
// 11.2 libraries is 64 Kb. With Oracle Client 12, the limit is 1 Gb
|
||||
|
@ -625,7 +617,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var len = 65535;
|
||||
var sequence = 12;
|
||||
var specialStr = "74.2.2";
|
||||
var clobStr = getRandomString(len, specialStr);
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
|
@ -761,7 +753,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var len = 50000;
|
||||
var sequence = 17;
|
||||
var specialStr = "74.2.7";
|
||||
var clobStr = getRandomString(len, specialStr);
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
var bindVar = [ sequence, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len } ];
|
||||
|
||||
async.series([
|
||||
|
@ -795,7 +787,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var len = 50000;
|
||||
var sequence = 18;
|
||||
var specialStr = "74.2.8";
|
||||
var clobStr = getRandomString(len, specialStr);
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
var bindVar = [ sequence, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len - 1 } ];
|
||||
|
||||
async.series([
|
||||
|
@ -881,6 +873,14 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
"END nodb_clob_in_out_743;";
|
||||
var sqlRun = "begin nodb_clob_in_out_743(lob_in_out => :lob_in_out); end;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_clob_in_out_743";
|
||||
var clob_proc_inout_7431 = "CREATE OR REPLACE PROCEDURE nodb_clob_in_out_7431 (lob_id IN NUMBER, lob_in_out IN OUT VARCHAR2) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into nodb_tab_clob_in (id, clob_1) values (lob_id, lob_in_out); \n" +
|
||||
" select clob_1 into lob_in_out from nodb_tab_clob_in where id = lob_id; \n" +
|
||||
"END nodb_clob_in_out_7431;";
|
||||
var sqlRun_7431 = "begin nodb_clob_in_out_7431(:i, :io); end;";
|
||||
var proc_drop_7431 = "DROP PROCEDURE nodb_clob_in_out_7431";
|
||||
|
||||
before(function(done) {
|
||||
executeSQL(clob_proc_inout, done);
|
||||
|
@ -893,7 +893,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
it('74.3.1 PLSQL, BIND_INOUT with String length 32K', function(done) {
|
||||
var specialStr = "74.3.1";
|
||||
var len = 32768;
|
||||
var clobVal = getRandomString(len, specialStr);
|
||||
var clobVal = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, val: clobVal, maxSize: len }
|
||||
};
|
||||
|
@ -916,7 +916,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
it('74.3.2 PLSQL, BIND_INOUT with String length 32K - 1', function(done) {
|
||||
var specialStr = "74.3.2";
|
||||
var len = 32767;
|
||||
var clobVal = getRandomString(len, specialStr);
|
||||
var clobVal = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, val: clobVal, maxSize: len }
|
||||
};
|
||||
|
@ -939,7 +939,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
it('74.3.3 PLSQL, BIND_INOUT with String length 64K - 1', function(done) {
|
||||
var specialStr = "74.3.3";
|
||||
var len = 65535;
|
||||
var clobVal = getRandomString(len, specialStr);
|
||||
var clobVal = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, val: clobVal, maxSize: len }
|
||||
};
|
||||
|
@ -959,6 +959,94 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
);
|
||||
}); // 74.3.3
|
||||
|
||||
it('74.3.4 PLSQL, BIND_INOUT with OUT data > maxSize', function(done) {
|
||||
var specialStr = "74.3.4";
|
||||
var len = 65535;
|
||||
var clobVal = random.getRandomString(len, specialStr);
|
||||
var bindVar = {
|
||||
lob_in_out: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, val: clobVal, maxSize: len - 1 }
|
||||
};
|
||||
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
bindVar,
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// NJS-016: buffer is too small for OUT binds
|
||||
(err.message).should.startWith('NJS-016');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}); // 74.3.4
|
||||
|
||||
it('74.3.5 PLSQL, bind out to varchar2 with OUT data < maxSize', function(done) {
|
||||
var sequence = 30;
|
||||
var specialStr = "74.3.5";
|
||||
var len = 300;
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
executeSQL(clob_proc_inout_7431, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar_7431 = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
io: { val:clobStr, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: len }
|
||||
};
|
||||
connection.execute(
|
||||
sqlRun_7431,
|
||||
bindVar_7431,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.io;
|
||||
var resultLength = resultVal.length;
|
||||
var specStrLength = specialStr.length;
|
||||
should.strictEqual(resultLength, len);
|
||||
should.strictEqual(resultVal.substring(0, specStrLength), specialStr);
|
||||
should.strictEqual(resultVal.substring(resultLength - specStrLength, resultLength), specialStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
executeSQL(proc_drop_7431, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 74.3.5
|
||||
|
||||
it('74.3.6 PLSQL, bind out to varchar2 with OUT data > maxSize', function(done) {
|
||||
var sequence = 30;
|
||||
var specialStr = "74.3.6";
|
||||
var len = 300;
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
executeSQL(clob_proc_inout_7431, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar_7431 = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
io: { val:clobStr, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: len - 1 }
|
||||
};
|
||||
connection.execute(
|
||||
sqlRun_7431,
|
||||
bindVar_7431,
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// ORA-01460: unimplemented or unreasonable conversion requested
|
||||
(err.message).should.startWith('ORA-01460');
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
executeSQL(proc_drop_7431, cb);
|
||||
}
|
||||
], done);
|
||||
}); // 74.3.6
|
||||
|
||||
}); // 74.3
|
||||
|
||||
describe('74.4 Multiple CLOBs, BIND_IN', function() {
|
||||
|
@ -982,9 +1070,9 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var specialStr = "74.4.1";
|
||||
var sequence = 100;
|
||||
var len1 = 50000;
|
||||
var clobStr_1 = getRandomString(len1, specialStr);
|
||||
var clobStr_1 = random.getRandomString(len1, specialStr);
|
||||
var len2 = 10000;
|
||||
var clobStr_2 = getRandomString(len2, specialStr);
|
||||
var clobStr_2 = random.getRandomString(len2, specialStr);
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr_1, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len1 },
|
||||
|
@ -1018,7 +1106,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var preparedCLOBID = 200;
|
||||
var len1 = 50000;
|
||||
var specialStr = "74.4.2";
|
||||
var clobStr_1 = getRandomString(len1, specialStr);
|
||||
var clobStr_1 = random.getRandomString(len1, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -1105,8 +1193,8 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var sequence = 110;
|
||||
var len1 = 50000;
|
||||
var len2 = 10000;
|
||||
var clobStr_1 = getRandomString(len1, specialStr);
|
||||
var clobStr_2 = getRandomString(len2, specialStr);
|
||||
var clobStr_1 = random.getRandomString(len1, specialStr);
|
||||
var clobStr_2 = random.getRandomString(len2, specialStr);
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len1 },
|
||||
|
@ -1152,7 +1240,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
var specialStr = "74.5.2";
|
||||
var sequence = 111;
|
||||
var len1 = 50000;
|
||||
var clobStr_1 = getRandomString(len1, specialStr);
|
||||
var clobStr_1 = random.getRandomString(len1, specialStr);
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len1 },
|
||||
|
@ -1248,7 +1336,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
it('74.6.1 PLSQL, BIND_INOUT, bind a txt file and a 32K string', function(done) {
|
||||
var specialStr = "74.6.1";
|
||||
var len1 = 32768;
|
||||
var clobVal = getRandomString(len1, specialStr);
|
||||
var clobVal = random.getRandomString(len1, specialStr);
|
||||
var preparedCLOBID = 200;
|
||||
|
||||
async.series([
|
||||
|
@ -1308,7 +1396,7 @@ describe('74.clobPlsqlBindAsString.js', function() {
|
|||
it('74.6.2 PLSQL, BIND_INOUT, bind a txt file and a 64K - 1 string', function(done) {
|
||||
var specialStr = "74.6.2";
|
||||
var len1 = 65535;
|
||||
var clobVal = getRandomString(len1, specialStr);
|
||||
var clobVal = random.getRandomString(len1, specialStr);
|
||||
var preparedCLOBID = 201;
|
||||
|
||||
async.series([
|
||||
|
|
|
@ -39,6 +39,7 @@ var oracledb = require('oracledb');
|
|||
var async = require('async');
|
||||
var should = require('should');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var random = require('./random.js');
|
||||
|
||||
describe('78. fetchClobAsString.js', function() {
|
||||
this.timeout(100000);
|
||||
|
@ -146,15 +147,6 @@ describe('78. fetchClobAsString.js', function() {
|
|||
);
|
||||
};
|
||||
|
||||
var getRandomString = function(length, specialStr) {
|
||||
var str='';
|
||||
var strLength = length - specialStr.length * 2;
|
||||
for( ; str.length < strLength; str += Math.random().toString(36).slice(2));
|
||||
str = str.substr(0, strLength);
|
||||
str = specialStr + str + specialStr;
|
||||
return str;
|
||||
};
|
||||
|
||||
describe('78.1 fetch CLOB columns by setting oracledb.fetchAsString', function() {
|
||||
|
||||
before('create Table and populate', function(done) {
|
||||
|
@ -214,7 +206,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 2;
|
||||
var specialStr = '78.1.2';
|
||||
var contentLength = 26;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -242,11 +234,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 3;
|
||||
var specialStr_1 = '78.1.3_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 4;
|
||||
var specialStr_2 = '78.1.3_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -282,11 +274,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 5;
|
||||
var specialStr_1 = '78.1.4_1';
|
||||
var contentLength_1 = 20;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 6;
|
||||
var specialStr_2 = '78.1.4_2';
|
||||
var contentLength_2 = 36;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -328,7 +320,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 7;
|
||||
var specialStr = '78.1.5';
|
||||
var contentLength = 65535;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -357,7 +349,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var specialStr = '78.1.6';
|
||||
var specialStrLen = specialStr.length;
|
||||
var contentLength = 100;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -405,7 +397,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 10;
|
||||
var specialStr = '78.1.8';
|
||||
var contentLength = 40;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -454,7 +446,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 11;
|
||||
var specialStr = '78.1.9';
|
||||
var contentLength = 26;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -514,10 +506,10 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 12;
|
||||
var specialStr_1 = '78.1.10_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var specialStr_2 = '78.1.10_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -561,11 +553,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 13;
|
||||
var specialStr_1 = '78.1.11_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 14;
|
||||
var specialStr_2 = '78.1.11_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 1;
|
||||
|
||||
|
@ -600,11 +592,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 15;
|
||||
var specialStr_1 = '78.1.12_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 16;
|
||||
var specialStr_2 = '78.1.12_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 20;
|
||||
|
||||
|
@ -689,7 +681,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 2;
|
||||
var specialStr = '78.2.2';
|
||||
var contentLength = 26;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -718,11 +710,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 3;
|
||||
var specialStr_1 = '78.2.3_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 4;
|
||||
var specialStr_2 = '78.2.3_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -760,11 +752,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 5;
|
||||
var specialStr_1 = '78.2.4_1';
|
||||
var contentLength_1 = 20;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 6;
|
||||
var specialStr_2 = '78.2.4_2';
|
||||
var contentLength_2 = 36;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -811,7 +803,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 7;
|
||||
var specialStr = '78.2.5';
|
||||
var contentLength = 65535;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -841,7 +833,7 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var specialStr = '78.2.6';
|
||||
var specialStrLen = specialStr.length;
|
||||
var contentLength = 100;
|
||||
var content = getRandomString(contentLength, specialStr);
|
||||
var content = random.getRandomString(contentLength, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -891,10 +883,10 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 10;
|
||||
var specialStr_1 = '78.2.10_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var specialStr_2 = '78.2.10_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -942,11 +934,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 11;
|
||||
var specialStr_1 = '78.2.9_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 12;
|
||||
var specialStr_2 = '78.2.9_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 1;
|
||||
|
||||
|
@ -983,11 +975,11 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id_1 = 13;
|
||||
var specialStr_1 = '78.2.10_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var id_2 = 14;
|
||||
var specialStr_2 = '78.2.10_2';
|
||||
var contentLength_2 = 30;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 20;
|
||||
|
||||
|
@ -1062,10 +1054,10 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 1;
|
||||
var specialStr_1 = '78.3.1_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var specialStr_2 = '78.3.1_2';
|
||||
var contentLength_2 = 100;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -1099,10 +1091,10 @@ describe('78. fetchClobAsString.js', function() {
|
|||
var id = 2;
|
||||
var specialStr_1 = '78.3.2_1';
|
||||
var contentLength_1 = 30;
|
||||
var content_1 = getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var specialStr_2 = '78.3.2_2';
|
||||
var contentLength_2 = 50;
|
||||
var content_2 = getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
|
|
@ -1125,7 +1125,7 @@ Overview of node-oracledb functional tests
|
|||
74.1.10 PLSQL, BIND_IN with invalid CLOB
|
||||
74.2 CLOB, PLSQL, BIND_OUT
|
||||
74.2.1 PLSQL, BIND_OUT with String length 32K
|
||||
74.2.2 PLSQL, BIND_OUT with String length 34K - 1
|
||||
74.2.2 PLSQL, BIND_OUT with String length 64K - 1
|
||||
74.2.3 PLSQL, BIND_OUT for null with small maxsize
|
||||
74.2.4 PLSQL, BIND_OUT for null with 64k maxsize
|
||||
74.2.5 PLSQL, BIND_OUT with empty string
|
||||
|
@ -1138,6 +1138,9 @@ Overview of node-oracledb functional tests
|
|||
74.3.1 PLSQL, BIND_INOUT with String length 32K
|
||||
74.3.2 PLSQL, BIND_INOUT with String length 32K - 1
|
||||
74.3.3 PLSQL, BIND_INOUT with String length 64K - 1
|
||||
74.3.4 PLSQL, BIND_INOUT with OUT data > maxSize
|
||||
74.3.5 PLSQL, bind out to varchar2 with OUT data < maxSize
|
||||
74.3.6 PLSQL, bind out to varchar2 with OUT data > maxSize
|
||||
74.4 Multiple CLOBs, BIND_IN
|
||||
74.4.1 PLSQL, BIND_IN, bind two string
|
||||
74.4.2 PLSQL, BIND_IN, bind a txt file and a string
|
||||
|
@ -1175,6 +1178,9 @@ Overview of node-oracledb functional tests
|
|||
75.3.1 PLSQL, BIND_INOUT with Buffer size 32K
|
||||
75.3.2 PLSQL, BIND_INOUT with Buffer size 32K - 1
|
||||
75.3.3 PLSQL, BIND_INOUT with Buffer size 64K - 1
|
||||
75.3.4 PLSQL, BIND_INOUT with OUT data > maxSize
|
||||
75.3.5 PLSQL, bind out to varchar2 with OUT data < maxSize
|
||||
75.3.6 PLSQL, bind out to varchar2 with OUT data > maxSize
|
||||
75.4 Multiple BLOBs, BIND_IN
|
||||
75.4.1 PLSQL, BIND_IN, bind two Buffer
|
||||
75.4.2 PLSQL, BIND_IN, bind a JPG file and a Buffer
|
||||
|
@ -1198,6 +1204,70 @@ Overview of node-oracledb functional tests
|
|||
76.3.1 PLSQL, BIND_INOUT, bind a 32K string and a 32K buffer
|
||||
76.3.2 PLSQL, BIND_INOUT, bind a 64K - 1 string and a 64K - 1 buffer
|
||||
|
||||
77.clobDMLBindAsString.js
|
||||
77.1 CLOB, INSERT
|
||||
77.1.1 works with EMPTY_CLOB
|
||||
77.1.2 works with empty string
|
||||
77.1.3 works with empty string and bind in maxSize set to 32767
|
||||
77.1.4 works with empty string and bind in maxSize set to 50000
|
||||
77.1.5 works with undefined
|
||||
77.1.6 works with null
|
||||
77.1.7 works with null and bind in maxSize set to 32767
|
||||
77.1.8 works with null and bind in maxSize set to 50000
|
||||
77.1.9 works with NaN
|
||||
77.1.10 works with 0
|
||||
77.1.11 works with String length 32K
|
||||
77.1.12 works with String length (64K - 1)
|
||||
77.1.13 works with String length (64K + 1)
|
||||
77.1.14 works with String length (1MB + 1)
|
||||
77.1.15 works with String length (5MB + 1)
|
||||
77.1.16 works with String length (10MB + 1)
|
||||
77.1.17 bind value and type mismatch
|
||||
77.1.18 mixing named with positional binding
|
||||
77.1.19 bind with invalid CLOB
|
||||
77.1.20 RETURNING INTO with bind type STRING
|
||||
77.1.21 Negative: RETURNING INTO with autocommit on
|
||||
77.1.22 works with bind in maxSize smaller than string length
|
||||
77.2 CLOB, UPDATE
|
||||
77.2.1 update EMPTY_CLOB column
|
||||
77.2.2 update a cloumn with EMPTY_CLOB
|
||||
77.2.3 update EMPTY_CLOB column with empty string
|
||||
77.2.4 update empty string column
|
||||
77.2.5 update a column with empty string
|
||||
77.2.6 update a column with (10MB + 1) string
|
||||
|
||||
78.blobDMLBindAsBuffer.js
|
||||
78.1 BLOB, INSERT
|
||||
78.1.1 works with EMPTY_BLOB
|
||||
78.1.2 works with empty buffer
|
||||
78.1.3 works with empty buffer and bind in maxSize set to 32767
|
||||
78.1.4 works with empty buffer and bind in maxSize set to 50000
|
||||
78.1.5 works with undefined
|
||||
78.1.6 works with null
|
||||
78.1.7 works with null and bind in maxSize set to 32767
|
||||
78.1.8 works with null and bind in maxSize set to 50000
|
||||
78.1.9 works with NaN
|
||||
78.1.10 works with 0
|
||||
78.1.11 works with Buffer length 32K
|
||||
78.1.12 works with Buffer length (64K - 1)
|
||||
78.1.13 works with Buffer length (64K + 1)
|
||||
78.1.14 works with Buffer length (1MB + 1)
|
||||
78.1.15 works with Buffer length (5MB + 1)
|
||||
78.1.16 works with Buffer length (10MB + 1)
|
||||
78.1.17 bind value and type mismatch
|
||||
78.1.18 mixing named with positional binding
|
||||
78.1.19 bind with invalid BLOB
|
||||
78.1.20 Negative: RETURNING INTO with bind type BUFFER
|
||||
78.1.21 Negative: RETURNING INTO with autocommit on
|
||||
78.1.22 works with bind in maxSize smaller than buffer size
|
||||
78.2 BLOB, UPDATE
|
||||
78.2.1 update EMPTY_BLOB column
|
||||
78.2.2 update a cloumn with EMPTY_BLOB
|
||||
78.2.3 update EMPTY_BLOB column with empty buffer
|
||||
78.2.4 update empty buffer column
|
||||
78.2.5 update a column with empty buffer
|
||||
78.2.6 update a column with (10MB + 1) buffer
|
||||
|
||||
77. lobProperties2.js
|
||||
77.1 CLOB: chunkSize (read-only)
|
||||
77.2 BLOB: chunkSize (read-only)
|
||||
|
|
|
@ -38,6 +38,7 @@ var should = require('should');
|
|||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var fs = require('fs');
|
||||
var random = require('./random.js');
|
||||
|
||||
describe('76.lobBindAsStringBuffer.js', function() {
|
||||
var connection = null;
|
||||
|
@ -335,15 +336,6 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
);
|
||||
};
|
||||
|
||||
var getRandomString = function(length, specialStr) {
|
||||
var str='';
|
||||
var strLength = length - specialStr.length * 2;
|
||||
for( ; str.length < strLength; str += Math.random().toString(36).slice(2));
|
||||
str = str.substr(0, strLength);
|
||||
str = specialStr + str + specialStr;
|
||||
return str;
|
||||
};
|
||||
|
||||
describe('76.1 Multiple LOBs, BIND_IN', function() {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_lobs_in_761 (id IN NUMBER, clob_in IN CLOB, blob_in IN BLOB)\n" +
|
||||
"AS \n" +
|
||||
|
@ -364,7 +356,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
it('76.1.1 PLSQL, CLOB&BLOB, bind a string and a buffer', function(done) {
|
||||
var specialStr = "76.1.1";
|
||||
var length = 50000;
|
||||
var bigStr = getRandomString(length, specialStr);
|
||||
var bigStr = random.getRandomString(length, specialStr);
|
||||
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var sequence = 700;
|
||||
var bindVar = {
|
||||
|
@ -401,7 +393,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
var sequence = 2;
|
||||
var size = 40000;
|
||||
var specialStr = "76.1.2";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
|
@ -447,7 +439,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
var sequence = 303;
|
||||
var size = 40000;
|
||||
var specialStr = "76.1.3";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
|
||||
async.series([
|
||||
|
@ -533,7 +525,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
var length = 50000;
|
||||
var specialStr = "76.2.1";
|
||||
var sequence = 311;
|
||||
var bigStr = getRandomString(length, specialStr);
|
||||
var bigStr = random.getRandomString(length, specialStr);
|
||||
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -578,7 +570,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
it('76.2.2 PLSQL, CLOB&BLOB, bind a string and a JPG file', function(done) {
|
||||
var size = 40000;
|
||||
var specialStr = "76.2.2";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var sequence = 312;
|
||||
var bindVar = {
|
||||
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
|
@ -657,7 +649,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
it('76.2.3 PLSQL, CLOB&BLOB, bind a txt file and a buffer', function(done) {
|
||||
var size = 40000;
|
||||
var specialStr = "76.2.3";
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var sequence = 313;
|
||||
var bindVar = {
|
||||
|
@ -752,7 +744,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
it('76.3.1 PLSQL, BIND_INOUT, bind a 32K string and a 32K buffer', function(done) {
|
||||
var specialStr = "76.3.1";
|
||||
var size = 32768;
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
clob: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, val: bigStr, maxSize: size },
|
||||
|
@ -785,7 +777,7 @@ describe('76.lobBindAsStringBuffer.js', function() {
|
|||
it('76.3.2 PLSQL, BIND_INOUT, bind a 64K - 1 string and a 64K - 1 buffer', function(done) {
|
||||
var specialStr = "76.3.2";
|
||||
var size = 65535;
|
||||
var bigStr = getRandomString(size, specialStr);
|
||||
var bigStr = random.getRandomString(size, specialStr);
|
||||
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
|
||||
var bindVar = {
|
||||
clob: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, val: bigStr, maxSize: size },
|
||||
|
|
|
@ -75,6 +75,10 @@ test/plsqlBindScalar.js
|
|||
test/lobBind1.js
|
||||
test/lobBind2.js
|
||||
test/poolPing.js
|
||||
test/clobPlsqlBindAsString.js
|
||||
test/blobPlsqlBindAsBuffer.js
|
||||
test/lobBindAsStringBuffer.js
|
||||
test/clobDMLBindAsString.js
|
||||
test/blobDMLBindAsBuffer.js
|
||||
test/lobProperties2.js
|
||||
test/fetchClobAsString.js
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* You may not use the identified files except in compliance with the Apache
|
||||
* License, Version 2.0 (the "License.")
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
|
||||
* See LICENSE.md for relevant licenses.
|
||||
*
|
||||
* NAME
|
||||
* random.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* generate a random string which length is 'length', with specialStr
|
||||
* in it's head and tail
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
var random = exports;
|
||||
module.exports = random;
|
||||
|
||||
// generate a random string which length is 'length', with specialStr in it's head and tail
|
||||
random.getRandomString = function (length, specialStr) {
|
||||
var str='';
|
||||
var strLength = length - specialStr.length * 2;
|
||||
for( ; str.length < strLength; str += Math.random().toString(36).slice(2));
|
||||
str = str.substr(0, strLength);
|
||||
str = specialStr + str + specialStr;
|
||||
return str;
|
||||
};
|
Loading…
Reference in New Issue