More refactoring and test file changes
This commit is contained in:
parent
ac5d0d9c6d
commit
231830b1ff
|
@ -746,10 +746,10 @@ describe('4. binding.js', function() {
|
|||
nullable: true,
|
||||
byteSize: 1
|
||||
};
|
||||
assert.deepEqual(cursor.metaData, [expectedBind]);
|
||||
assert.deepStrictEqual(cursor.metaData, [expectedBind]);
|
||||
|
||||
const rows = await cursor.getRows();
|
||||
assert.deepEqual(rows, [ [ 'X' ] ]);
|
||||
assert.deepStrictEqual(rows, [ [ 'X' ] ]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
* NAME
|
||||
* 263.binding_buffer_string.js
|
||||
* 270.binding_buffer_string.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Test case for bug 33943738
|
||||
|
@ -34,7 +34,7 @@
|
|||
const oracledb = require('oracledb');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('263. binding_buffer_string.js', function() {
|
||||
describe('270. binding_buffer_string.js', function() {
|
||||
let connection = null;
|
||||
|
||||
const proc_blob_in_tab = "BEGIN \n" +
|
||||
|
@ -65,9 +65,9 @@ describe('263. binding_buffer_string.js', function() {
|
|||
await connection.close();
|
||||
});
|
||||
|
||||
describe('263.1 BLOB, PLSQL, BIND_IN', function() {
|
||||
describe('270.1 BLOB, PLSQL, BIND_IN', function() {
|
||||
|
||||
it('263.1.1 works with buffer', async function() {
|
||||
it('270.1.1 works with buffer', async function() {
|
||||
const data = [
|
||||
{a: 1, b: Buffer.from("Dummy data 1".repeat(5000), "utf-8")},
|
||||
{a: 2, b: Buffer.from("Dummy data 2".repeat(7500), "utf-8")}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const sql = require('./sqlClone.js');
|
||||
const sql = require('./sql.js');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('100.binding_defaultBindIn.js', function() {
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const sql = require('./sqlClone.js');
|
||||
const sql = require('./sql.js');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const sql = require('./sqlClone.js');
|
||||
const sql = require('./sql.js');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const sql = require('./sqlClone.js');
|
||||
const sql = require('./sql.js');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const sql = require('./sqlClone.js');
|
||||
const sql = require('./sql.js');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const sql = require('./sqlClone.js');
|
||||
const sql = require('./sql.js');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const sql = require('./sqlClone.js');
|
||||
const sql = require('./sql.js');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sql.js');
|
||||
|
||||
describe('137. blobDMLReturningMultipleRowsAsBuffer.js', function() {
|
||||
|
||||
|
@ -73,12 +72,12 @@ describe('137. blobDMLReturningMultipleRowsAsBuffer.js', function() {
|
|||
let tabsize = 10;
|
||||
|
||||
before(async function() {
|
||||
await sql.executeSql(connection, blob_table_create, {}, {});
|
||||
await connection.execute(blob_table_create);
|
||||
await insertData(tabsize);
|
||||
});
|
||||
|
||||
after(async function() {
|
||||
await sql.executeSql(connection, blob_table_drop, {}, {});
|
||||
await connection.execute(blob_table_drop);
|
||||
});
|
||||
|
||||
it('137.1.1 BLOB DML returning multiple rows as buffer', async function() {
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sql.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('138. blobDMLReturningMultipleRowsAsStream.js', function() {
|
||||
|
||||
|
@ -71,13 +69,12 @@ describe('138. blobDMLReturningMultipleRowsAsStream.js', function() {
|
|||
|
||||
describe('138.1 BLOB DML returning multiple rows as stream', function() {
|
||||
before(async function() {
|
||||
|
||||
await sql.executeSql(connection, blob_table_create, {}, {});
|
||||
insertData(10);
|
||||
await connection.execute(blob_table_create);
|
||||
await insertData(10);
|
||||
});
|
||||
|
||||
after(async function() {
|
||||
await sql.executeSql(connection, blob_table_drop, {}, {});
|
||||
await connection.execute(blob_table_drop);
|
||||
});
|
||||
|
||||
it('138.1.1 BLOB DML returning multiple rows as stream', async function() {
|
||||
|
@ -140,7 +137,7 @@ describe('138. blobDMLReturningMultipleRowsAsStream.js', function() {
|
|||
lob.on('end', function(err) {
|
||||
assert(err);
|
||||
let expected = Buffer.from(String(id - 10), "utf-8");
|
||||
assert.strictEqual(assist.compare2Buffers(blobData, expected), true);
|
||||
assert.deepStrictEqual(blobData, expected);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -36,7 +36,6 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('77. blobPlsqlBindAsBuffer_bindin.js', function() {
|
||||
|
||||
|
@ -203,7 +202,7 @@ describe('77. blobPlsqlBindAsBuffer_bindin.js', function() {
|
|||
assert.strictEqual(resultVal.toString('utf8', 0, specStrLength), specialStr);
|
||||
assert.strictEqual(resultVal.toString('utf8', (totalLength - specStrLength), totalLength), specialStr);
|
||||
}
|
||||
assert.strictEqual(assist.compare2Buffers(resultVal, originalBuffer), true);
|
||||
assert.strictEqual(resultVal, originalBuffer);
|
||||
};
|
||||
|
||||
// execute the bind in plsql procedure
|
||||
|
|
|
@ -36,7 +36,6 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('79. blobPlsqlBindAsBuffer_bindinout.js', function() {
|
||||
|
||||
|
@ -152,7 +151,7 @@ describe('79. blobPlsqlBindAsBuffer_bindinout.js', function() {
|
|||
assert.strictEqual(resultVal.toString('utf8', 0, specStrLength), specialStr);
|
||||
assert.strictEqual(resultVal.toString('utf8', (resultLength - specStrLength), resultLength), specialStr);
|
||||
}
|
||||
assert.strictEqual(assist.compare2Buffers(resultVal, originalBuffer), true);
|
||||
assert.deepStrictEqual(resultVal, originalBuffer);
|
||||
};
|
||||
|
||||
// execute plsql bind in out procedure, and verify the plsql bind out buffer
|
||||
|
|
|
@ -36,7 +36,6 @@ const assert = require('assert');
|
|||
const fs = require('fs');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('78. blobPlsqlBindAsBuffer_bindout.js', function() {
|
||||
|
||||
|
@ -116,7 +115,7 @@ describe('78. blobPlsqlBindAsBuffer_bindout.js', function() {
|
|||
b: { val: insertBuffer, dir: oracledb.BIND_IN, type: oracledb.BUFFER }
|
||||
};
|
||||
|
||||
if (insertBuffer == 'EMPTY_LOB') {
|
||||
if (insertBuffer === 'EMPTY_LOB') {
|
||||
sql = "INSERT INTO nodb_tab_blob_in (id, blob_1) VALUES (:i, EMPTY_BLOB())";
|
||||
bindVar = {
|
||||
i: { val: id, dir: oracledb.BIND_IN, type: oracledb.NUMBER }
|
||||
|
@ -160,10 +159,10 @@ describe('78. blobPlsqlBindAsBuffer_bindout.js', function() {
|
|||
assert.deepEqual(originalData, blobData);
|
||||
};
|
||||
|
||||
const verifyBlobValueWithBuffer = async function(selectSql, oraginalBuffer, specialStr) {
|
||||
const verifyBlobValueWithBuffer = async function(selectSql, originalBuffer, specialStr) {
|
||||
const result = await connection.execute(selectSql);
|
||||
const lob = result.rows[0][0];
|
||||
if (oraginalBuffer == null | oraginalBuffer == '' || oraginalBuffer == undefined) {
|
||||
if (originalBuffer == null | originalBuffer == '' || originalBuffer == undefined) {
|
||||
assert(lob);
|
||||
} else {
|
||||
const blobData = await lob.getData();
|
||||
|
@ -183,12 +182,12 @@ describe('78. blobPlsqlBindAsBuffer_bindout.js', function() {
|
|||
assert.strictEqual(resultVal.toString('utf8', 0, specStrLength), specialStr);
|
||||
assert.strictEqual(resultVal.toString('utf8', (resultLength - specStrLength), resultLength), specialStr);
|
||||
}
|
||||
assert.strictEqual(assist.compare2Buffers(resultVal, originalBuffer), true);
|
||||
assert.deepStrictEqual(resultVal, originalBuffer);
|
||||
};
|
||||
|
||||
const verifyBindOutResult = async function(sqlRun, bindVar, originalBuf, specialStr) {
|
||||
const result = await connection.execute(sqlRun, bindVar);
|
||||
if (originalBuf == "EMPTY_LOB" || originalBuf == undefined || originalBuf == null || originalBuf == "") {
|
||||
if (originalBuf === "EMPTY_LOB" || originalBuf == undefined || originalBuf == null || originalBuf == "") {
|
||||
assert.strictEqual(result.outBinds.b, null);
|
||||
} else {
|
||||
const resultVal = result.outBinds.b;
|
||||
|
|
227
test/cqn01.js
227
test/cqn01.js
|
@ -1,227 +0,0 @@
|
|||
/* Copyright (c) 2019, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This software is dual-licensed to you under the Universal Permissive License
|
||||
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
|
||||
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
|
||||
* either license.
|
||||
*
|
||||
* If you elect to accept the software under the Apache License, Version 2.0,
|
||||
* the following applies:
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://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.
|
||||
*
|
||||
* NAME
|
||||
* 224. cqn01.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Test CQN client initiated connections.
|
||||
*
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const events = require('events');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
describe('224. cqn01.js', function() {
|
||||
|
||||
let isRunnable = false;
|
||||
let conn, connAsDBA;
|
||||
|
||||
before(async function() {
|
||||
|
||||
const prep = await testsUtil.checkPrerequisites(1904000000, 1904000000);
|
||||
isRunnable = prep && dbConfig.test.DBA_PRIVILEGE;
|
||||
|
||||
if (!isRunnable) {
|
||||
this.skip();
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
||||
let credential = {
|
||||
user: dbConfig.test.DBA_user,
|
||||
password: dbConfig.test.DBA_password,
|
||||
connectString: dbConfig.connectString,
|
||||
privilege: oracledb.SYSDBA
|
||||
};
|
||||
connAsDBA = await oracledb.getConnection(credential);
|
||||
|
||||
let sql = `GRANT CHANGE NOTIFICATION TO ${dbConfig.user}`;
|
||||
await connAsDBA.execute(sql);
|
||||
|
||||
conn = await oracledb.getConnection({
|
||||
...dbConfig,
|
||||
events: true
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
}
|
||||
|
||||
}
|
||||
}); // before()
|
||||
|
||||
after(async function() {
|
||||
if (!isRunnable) {
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
let sql = `REVOKE CHANGE NOTIFICATION FROM ${dbConfig.user}`;
|
||||
await connAsDBA.execute(sql);
|
||||
|
||||
await conn.close();
|
||||
await connAsDBA.close();
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
}
|
||||
}
|
||||
}); // after()
|
||||
|
||||
it('224.1 client initiated CQN', async () => {
|
||||
try {
|
||||
const TABLE = 'nodb_tab_cqn_001';
|
||||
let sql =
|
||||
`CREATE TABLE ${TABLE} (
|
||||
k NUMBER
|
||||
)`;
|
||||
let plsql = testsUtil.sqlCreateTable(TABLE, sql);
|
||||
await conn.execute(plsql);
|
||||
const eventEmitter = new events.EventEmitter();
|
||||
|
||||
const myCallback = function(message) {
|
||||
// should.strictEqual(message.type, oracledb.SUBSCR_EVENT_TYPE_QUERY_CHANGE);
|
||||
// should.strictEqual(message.registered, true);
|
||||
// const table = message.queries[0].tables[0];
|
||||
// const tableName = dbConfig.user.toUpperCase() + '.' + TABLE.toUpperCase();
|
||||
// should.strictEqual(table.name, tableName);
|
||||
// should.strictEqual(table.operation, oracledb.CQN_OPCODE_INSERT);
|
||||
console.log(message);
|
||||
eventEmitter.emit("received");
|
||||
};
|
||||
|
||||
const options = {
|
||||
callback : myCallback,
|
||||
sql: `SELECT * FROM ${TABLE} WHERE k > :bv`,
|
||||
binds: { bv : 100 },
|
||||
timeout : 20,
|
||||
qos : oracledb.SUBSCR_QOS_QUERY | oracledb.SUBSCR_QOS_ROWIDS,
|
||||
clientInitiated: true
|
||||
};
|
||||
|
||||
console.log("Message 1:");
|
||||
await conn.subscribe('nodb_sub_001', options);
|
||||
|
||||
sql = `INSERT INTO ${TABLE} VALUES (101)`;
|
||||
await conn.execute(sql);
|
||||
|
||||
sql = `INSERT INTO ${TABLE} VALUES (99)`;
|
||||
await conn.execute(sql);
|
||||
|
||||
sql = `INSERT INTO ${TABLE} VALUES (102)`;
|
||||
await conn.execute(sql);
|
||||
|
||||
await conn.commit();
|
||||
|
||||
await new Promise(function(resolve, reject) {
|
||||
const timeout = setTimeout(function() {
|
||||
reject(new Error("Timed out!"));
|
||||
}, 25000);
|
||||
eventEmitter.on("received", function() {
|
||||
console.log("Received message!");
|
||||
clearTimeout(timeout);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
await conn.unsubscribe('nodb_sub_001');
|
||||
|
||||
sql = `DROP TABLE ${TABLE} PURGE`;
|
||||
await conn.execute(sql);
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
}
|
||||
|
||||
}); // 224.1
|
||||
|
||||
it('224.2 previous CQN', async () => {
|
||||
try {
|
||||
const TABLE = 'nodb_tab_cqn_002';
|
||||
let sql =
|
||||
`CREATE TABLE ${TABLE} (
|
||||
k NUMBER
|
||||
)`;
|
||||
let plsql = testsUtil.sqlCreateTable(TABLE, sql);
|
||||
await conn.execute(plsql);
|
||||
|
||||
const eventEmitter = new events.EventEmitter();
|
||||
|
||||
const myCallback = function(message) {
|
||||
// should.strictEqual(message.type, oracledb.SUBSCR_EVENT_TYPE_QUERY_CHANGE);
|
||||
// should.strictEqual(message.registered, true);
|
||||
// const table = message.queries[0].tables[0];
|
||||
// const tableName = dbConfig.user.toUpperCase() + '.' + TABLE.toUpperCase();
|
||||
// should.strictEqual(table.name, tableName);
|
||||
// should.strictEqual(table.operation, oracledb.CQN_OPCODE_INSERT);
|
||||
console.log(message);
|
||||
eventEmitter.emit("received");
|
||||
};
|
||||
|
||||
const options = {
|
||||
callback : myCallback,
|
||||
sql: `SELECT * FROM ${TABLE} WHERE k > :bv`,
|
||||
binds: { bv : 100 },
|
||||
timeout : 20,
|
||||
qos : oracledb.SUBSCR_QOS_QUERY | oracledb.SUBSCR_QOS_ROWIDS
|
||||
};
|
||||
|
||||
console.log("Message 2:");
|
||||
await conn.subscribe('nodb_sub_002', options);
|
||||
|
||||
await testsUtil.sleep();
|
||||
|
||||
sql = `INSERT INTO ${TABLE} VALUES (101)`;
|
||||
await conn.execute(sql);
|
||||
|
||||
sql = `INSERT INTO ${TABLE} VALUES (99)`;
|
||||
await conn.execute(sql);
|
||||
|
||||
sql = `INSERT INTO ${TABLE} VALUES (102)`;
|
||||
await conn.execute(sql);
|
||||
|
||||
await conn.commit();
|
||||
|
||||
await new Promise(function(resolve, reject) {
|
||||
const timeout = setTimeout(function() {
|
||||
reject(new Error("Timed out!"));
|
||||
}, 25000);
|
||||
eventEmitter.on("received", function() {
|
||||
console.log("Received message!");
|
||||
clearTimeout(timeout);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
await conn.unsubscribe('nodb_sub_002');
|
||||
|
||||
sql = `DROP TABLE ${TABLE} PURGE`;
|
||||
await conn.execute(sql);
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
}
|
||||
}); // 224.2
|
||||
});
|
|
@ -1,94 +0,0 @@
|
|||
/* Copyright (c) 2019, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This software is dual-licensed to you under the Universal Permissive License
|
||||
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
|
||||
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
|
||||
* either license.
|
||||
*
|
||||
* If you elect to accept the software under the Apache License, Version 2.0,
|
||||
* the following applies:
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://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.
|
||||
*
|
||||
* NAME
|
||||
* 225. cqn02.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Negative test of CQN client initiated connections.
|
||||
*
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
describe('225. cqn02.js', function() {
|
||||
|
||||
let isRunnable = true;
|
||||
before(async function() {
|
||||
const prep = await testsUtil.checkPrerequisites(1904000000, 1904000000);
|
||||
isRunnable = !prep;
|
||||
|
||||
if (!isRunnable) {
|
||||
this.skip();
|
||||
}
|
||||
}); // before()
|
||||
|
||||
it('225.1 Negative - DB version or client version is less than 19.4', async () => {
|
||||
try {
|
||||
const conn = await oracledb.getConnection({
|
||||
...dbConfig,
|
||||
events: true
|
||||
});
|
||||
const TABLE = 'nodb_tab_cqn02';
|
||||
let sql =
|
||||
`CREATE TABLE ${TABLE} (
|
||||
k NUMBER
|
||||
)`;
|
||||
let plsql = testsUtil.sqlCreateTable(TABLE, sql);
|
||||
await conn.execute(plsql);
|
||||
|
||||
const myCallback = function(message) {
|
||||
console.log(message);
|
||||
};
|
||||
|
||||
const options = {
|
||||
callback : myCallback,
|
||||
sql: `SELECT * FROM ${TABLE} WHERE k > :bv`,
|
||||
binds: { bv : 100 },
|
||||
timeout : 20,
|
||||
qos : oracledb.SUBSCR_QOS_QUERY | oracledb.SUBSCR_QOS_ROWIDS,
|
||||
clientInitiated: true
|
||||
};
|
||||
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await conn.subscribe('sub1', options);
|
||||
},
|
||||
/DPI-1050/
|
||||
);
|
||||
// DPI-1050: Oracle Client library is at version 19.3 but version 19.4 or higher is needed
|
||||
|
||||
sql = `DROP TABLE ${TABLE} PURGE`;
|
||||
await conn.execute(sql);
|
||||
await conn.close();
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
}
|
||||
}); // 225.1
|
||||
});
|
|
@ -464,6 +464,6 @@ describe('42. dataTypeRaw.js', function() {
|
|||
let fetch = async function(expected) {
|
||||
let sql = "select content from " + tableName + " where num = " + insertID;
|
||||
let result = await connection.execute(sql);
|
||||
assist.compare2Buffers(result.rows[0][0], expected);
|
||||
assert.deepStrictEqual(result.rows[0][0], expected);
|
||||
};
|
||||
});
|
||||
|
|
|
@ -32,160 +32,138 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("148. fetchArraySize1.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var defaultVal = oracledb.fetchArraySize;
|
||||
let defaultVal = oracledb.fetchArraySize;
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(defaultVal, 100);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(defaultVal, 100);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe("148.1 oracledb.fetchArraySize", function() {
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = defaultVal;
|
||||
done();
|
||||
});
|
||||
|
||||
it("148.1.1 oracledb.fetchArraySize = 0", function(done) {
|
||||
checkError(0, done);
|
||||
it("148.1.1 oracledb.fetchArraySize = 0", function() {
|
||||
checkError(0);
|
||||
});
|
||||
|
||||
it("148.1.2 oracledb.fetchArraySize = 1", function(done) {
|
||||
checkGlobalOptionValue(1, 1, done);
|
||||
it("148.1.2 oracledb.fetchArraySize = 1", async function() {
|
||||
await checkGlobalOptionValue(1, 1);
|
||||
});
|
||||
|
||||
it("148.1.3 Negative: oracledb.fetchArraySize = undefined", function(done) {
|
||||
checkError(undefined, done);
|
||||
it("148.1.3 Negative: oracledb.fetchArraySize = undefined", function() {
|
||||
checkError(undefined);
|
||||
});
|
||||
|
||||
it("148.1.4 Negative: oracledb.fetchArraySize = null", function(done) {
|
||||
checkError(null, done);
|
||||
it("148.1.4 Negative: oracledb.fetchArraySize = null", function() {
|
||||
checkError(null);
|
||||
});
|
||||
|
||||
it("148.1.5 Negative: oracledb.fetchArraySize = random string", function(done) {
|
||||
checkError("random string", done);
|
||||
it("148.1.5 Negative: oracledb.fetchArraySize = random string", function() {
|
||||
checkError("random string");
|
||||
});
|
||||
|
||||
it("148.1.6 Negative: oracledb.fetchArraySize = Boolean", function(done) {
|
||||
checkError(true, done);
|
||||
it("148.1.6 Negative: oracledb.fetchArraySize = Boolean", function() {
|
||||
checkError(true);
|
||||
});
|
||||
|
||||
it("148.1.7 Negative: oracledb.fetchArraySize = NaN", function(done) {
|
||||
checkError(NaN, done);
|
||||
it("148.1.7 Negative: oracledb.fetchArraySize = NaN", function() {
|
||||
checkError(NaN);
|
||||
});
|
||||
|
||||
it("148.1.8 oracledb.fetchArraySize = big number", function(done) {
|
||||
checkGlobalOptionValue(1000000, 1000000, done);
|
||||
it("148.1.8 oracledb.fetchArraySize = big number", async function() {
|
||||
await checkGlobalOptionValue(1000000, 1000000);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("148.2 execute() option fetchArraySize", function() {
|
||||
|
||||
it("148.2.1 fetchArraySize = 0", function(done) {
|
||||
queryExpectsError(0, done);
|
||||
it("148.2.1 fetchArraySize = 0", async function() {
|
||||
await queryExpectsError(0);
|
||||
});
|
||||
|
||||
it("148.2.2 fetchArraySize = 1", function(done) {
|
||||
checkExecOptionValue(1, done);
|
||||
it("148.2.2 fetchArraySize = 1", async function() {
|
||||
await checkExecOptionValue(1);
|
||||
});
|
||||
|
||||
it("148.2.3 fetchArraySize = undefined works as default value 100", function(done) {
|
||||
checkExecOptionValue(undefined, done);
|
||||
it("148.2.3 fetchArraySize = undefined works as default value 100", async function() {
|
||||
await checkExecOptionValue(undefined);
|
||||
});
|
||||
|
||||
it("148.2.4 Negative: fetchArraySize = null", function(done) {
|
||||
queryExpectsError(null, done);
|
||||
it("148.2.4 Negative: fetchArraySize = null", async function() {
|
||||
await queryExpectsError(null);
|
||||
});
|
||||
|
||||
it("148.2.5 Negative: fetchArraySize = random string", function(done) {
|
||||
queryExpectsError("random string", done);
|
||||
it("148.2.5 Negative: fetchArraySize = random string", async function() {
|
||||
await queryExpectsError("random string");
|
||||
});
|
||||
|
||||
it("148.2.6 Negative: fetchArraySize = Boolean", function(done) {
|
||||
queryExpectsError(false, done);
|
||||
it("148.2.6 Negative: fetchArraySize = Boolean", async function() {
|
||||
await queryExpectsError(false);
|
||||
});
|
||||
|
||||
it("148.2.7 Negative: fetchArraySize = NaN", function(done) {
|
||||
queryExpectsError(NaN, done);
|
||||
it("148.2.7 Negative: fetchArraySize = NaN", async function() {
|
||||
await queryExpectsError(NaN);
|
||||
});
|
||||
|
||||
it("148.2.8 fetchArraySize = big number", function(done) {
|
||||
checkExecOptionValue(1000000, done);
|
||||
it("148.2.8 fetchArraySize = big number", async function() {
|
||||
await checkExecOptionValue(1000000);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var checkGlobalOptionValue = function(values, expectedFetchArraySize, cb) {
|
||||
should.doesNotThrow(
|
||||
const checkGlobalOptionValue = async function(values, expectedFetchArraySize) {
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
oracledb.fetchArraySize = values;
|
||||
}
|
||||
);
|
||||
|
||||
connection.execute(
|
||||
"select 'oracledb.fetchArraySize' from dual",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows[0][0], "oracledb.fetchArraySize");
|
||||
should.strictEqual(oracledb.fetchArraySize, expectedFetchArraySize);
|
||||
cb();
|
||||
}
|
||||
let result = await connection.execute(
|
||||
"select 'oracledb.fetchArraySize' from dual"
|
||||
);
|
||||
assert.strictEqual(result.rows[0][0], "oracledb.fetchArraySize");
|
||||
assert.strictEqual(oracledb.fetchArraySize, expectedFetchArraySize);
|
||||
};
|
||||
|
||||
var checkError = function(values, cb) {
|
||||
should.throws(
|
||||
const checkError = function(values) {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchArraySize = values;
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
cb();
|
||||
};
|
||||
|
||||
var checkExecOptionValue = function(values, cb) {
|
||||
connection.execute(
|
||||
const checkExecOptionValue = async function(values) {
|
||||
let result = await connection.execute(
|
||||
"select 'fetchArraySize' from dual",
|
||||
[],
|
||||
{ fetchArraySize: values },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(oracledb.fetchArraySize, 100);
|
||||
should.strictEqual(result.rows[0][0], "fetchArraySize");
|
||||
cb();
|
||||
}
|
||||
{ fetchArraySize: values }
|
||||
);
|
||||
assert.strictEqual(oracledb.fetchArraySize, 100);
|
||||
assert.strictEqual(result.rows[0][0], "fetchArraySize");
|
||||
};
|
||||
|
||||
var queryExpectsError = function(values, cb) {
|
||||
connection.execute(
|
||||
"select 'fetchArraySize' from dual",
|
||||
[],
|
||||
{ fetchArraySize: values },
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.not.exist(result);
|
||||
should.strictEqual(err.message, "NJS-007: invalid value for \"fetchArraySize\" in parameter 3");
|
||||
cb();
|
||||
}
|
||||
const queryExpectsError = async function(values) {
|
||||
const sql = "select 'fetchArraySize' from dual";
|
||||
const options = { fetchArraySize: values };
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(sql, [], options),
|
||||
/NJS-007:/
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -38,8 +38,7 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("149. fetchArraySize2.js", function() {
|
||||
|
@ -76,210 +75,166 @@ describe("149. fetchArraySize2.js", function() {
|
|||
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_fetcArraySize, 100);
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_fetcArraySize, 100);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe("149.1 basic fetch with different maxRows and oracledb.fetchArraySize", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
const basicFetch = function(fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
const basicFetch = async function(fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName + " WHERE id > " + affectedID + " ORDER BY id",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
should.strictEqual(result.rows.length, resultLenExpected);
|
||||
verifyResult(result.rows, affectedID, cb);
|
||||
}
|
||||
let result = await connection.execute(
|
||||
"SELECT * FROM " + tableName + " WHERE id > " + affectedID + " ORDER BY id"
|
||||
);
|
||||
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
assert.strictEqual(result.rows.length, resultLenExpected);
|
||||
verifyResult(result.rows, affectedID);
|
||||
};
|
||||
|
||||
const verifyResult = function(result, affectedID, callback) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
const index = result.indexOf(element);
|
||||
verifyEachRow(index + 1 + affectedID, element);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
const verifyResult = function(result, affectedID) {
|
||||
for (let element of result) {
|
||||
const index = result.indexOf(element) + 1 + affectedID;
|
||||
assert.strictEqual(element[1], String(index));
|
||||
assert.strictEqual(element[0], index);
|
||||
}
|
||||
};
|
||||
|
||||
const verifyEachRow = function(index, element) {
|
||||
should.strictEqual(element[1], String(index));
|
||||
should.strictEqual(element[0], index);
|
||||
};
|
||||
|
||||
it("149.1.1 maxRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
it("149.1.1 maxRows > table size > oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = tableSize - 1;
|
||||
const maxRowsVal = tableSize + 1;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.2 maxRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
it("149.1.2 maxRows > oracledb.fetchArraySize > table size", async function() {
|
||||
const fetchArraySizeVal = tableSize - 99;
|
||||
const maxRowsVal = tableSize - 7;
|
||||
const affectedID = 20;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.3 table size > maxRows > oracledb.fetchArraySize", function(done) {
|
||||
it("149.1.3 table size > maxRows > oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = tableSize - 100;
|
||||
const maxRowsVal = tableSize - 2;
|
||||
const affectedID = 10;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
it("149.1.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
const fetchArraySizeVal = tableSize - 3;
|
||||
const maxRowsVal = tableSize - 77;
|
||||
const affectedID = 50;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.5 maxRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
it("149.1.5 maxRows = oracledb.fetchArraySize < table size", async function() {
|
||||
const fetchArraySizeVal = tableSize - 110;
|
||||
const maxRowsVal = tableSize - 110;
|
||||
const affectedID = 20;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.6 maxRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
it("149.1.6 maxRows = oracledb.fetchArraySize = table size", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = tableSize;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.7 maxRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
it("149.1.7 maxRows = oracledb.fetchArraySize > table size", async function() {
|
||||
const fetchArraySizeVal = tableSize + 9999;
|
||||
const maxRowsVal = tableSize + 9999;
|
||||
const affectedID = 10;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.8 maxRows = oracledb.fetchArraySize/10", function(done) {
|
||||
it("149.1.8 maxRows = oracledb.fetchArraySize/10", async function() {
|
||||
const fetchArraySizeVal = tableSize / 10 - 1;
|
||||
const maxRowsVal = tableSize / 10;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.9 maxRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
it("149.1.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = 90;
|
||||
const maxRowsVal = 900;
|
||||
const affectedID = 50;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
it("149.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
const fetchArraySizeVal = tableSize / 10;
|
||||
const maxRowsVal = tableSize / 10 + 1;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.11 maxRows = 0, fetchArraySize = table size ", function(done) {
|
||||
it("149.1.11 maxRows = 0, fetchArraySize = table size ", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = 0;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.12 maxRows = 9999999, fetchArraySize = table size ", function(done) {
|
||||
it("149.1.12 maxRows = 9999999, fetchArraySize = table size ", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = 9999999;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.13 maxRows = (table size - 1), fetchArraySize = table size ", function(done) {
|
||||
it("149.1.13 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = tableSize - 1;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.1.14 fetchArraySize = (table size - 1), maxRows = table size ", function(done) {
|
||||
it("149.1.14 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
|
||||
const fetchArraySizeVal = tableSize - 1;
|
||||
const maxRowsVal = tableSize;
|
||||
const affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
describe("149.2 REF CURSORS with different numRows and oracledb.fetchArraySize", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
const testRefCursor = function(fetchArraySizeVal, numRowsVal, cb) {
|
||||
const testRefCursor = async function(fetchArraySizeVal, numRowsVal) {
|
||||
const create_ref = `CREATE OR REPLACE PROCEDURE testrefproc (p_out OUT SYS_REFCURSOR)
|
||||
AS
|
||||
BEGIN
|
||||
|
@ -289,294 +244,249 @@ describe("149. fetchArraySize2.js", function() {
|
|||
const drop_ref = "DROP PROCEDURE testrefproc";
|
||||
const exec_ref = "BEGIN testrefproc(:o); END;";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
create_ref,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
connection.execute(
|
||||
exec_ref,
|
||||
[
|
||||
{ type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
const rowCount = 0;
|
||||
fetchRowsFromRS(result.outBinds[0], numRowsVal, rowCount, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
drop_ref,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], cb);
|
||||
await connection.execute(create_ref);
|
||||
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
let result = await connection.execute(
|
||||
exec_ref,
|
||||
[
|
||||
{ type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
const rowCount = 0;
|
||||
fetchRowsFromRS(result.outBinds[0], numRowsVal, rowCount);
|
||||
|
||||
await connection.execute(drop_ref);
|
||||
};
|
||||
|
||||
function fetchRowsFromRS(rs, numRowsVal, rowCount, cb) {
|
||||
rs.getRows(numRowsVal, function(err, rows) {
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal);
|
||||
rowCount = rowCount + 1;
|
||||
// console.log(rows[i][0]);
|
||||
should.strictEqual(rows[i].ID, rowCount);
|
||||
should.strictEqual(rows[i].CONTENT, rowCount.toString());
|
||||
}
|
||||
return fetchRowsFromRS(rs, numRowsVal, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
async function fetchRowsFromRS(rs, numRowsVal, rowCount) {
|
||||
let rows = await rs.getRows(numRowsVal);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
assert(rows.length <= numRowsVal);
|
||||
rowCount++;
|
||||
assert.strictEqual(rows[i].ID, rowCount);
|
||||
assert.strictEqual(rows[i].CONTENT, rowCount.toString());
|
||||
}
|
||||
});
|
||||
return fetchRowsFromRS(rs, numRowsVal, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
it("149.2.1 numRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
it("149.2.1 numRows > table size > oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = tableSize - 1;
|
||||
const numRowsVal = tableSize + 1;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.2 numRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
it("149.2.2 numRows > oracledb.fetchArraySize > table size", async function() {
|
||||
const fetchArraySizeVal = tableSize + 7;
|
||||
const numRowsVal = tableSize + 77;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.3 table size > numRows > oracledb.fetchArraySize", function(done) {
|
||||
it("149.2.3 table size > numRows > oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = tableSize - 11;
|
||||
const numRowsVal = tableSize - 2;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
it("149.2.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
const fetchArraySizeVal = tableSize - 90;
|
||||
const numRowsVal = tableSize - 150;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.5 numRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
it("149.2.5 numRows = oracledb.fetchArraySize < table size", async function() {
|
||||
const fetchArraySizeVal = tableSize - 110;
|
||||
const numRowsVal = tableSize - 110;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.6 numRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
it("149.2.6 numRows = oracledb.fetchArraySize = table size", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const numRowsVal = tableSize;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.7 numRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
it("149.2.7 numRows = oracledb.fetchArraySize > table size", async function() {
|
||||
const fetchArraySizeVal = tableSize + 9999;
|
||||
const numRowsVal = tableSize + 9999;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.8 numRows = oracledb.fetchArraySize/10", function(done) {
|
||||
it("149.2.8 numRows = oracledb.fetchArraySize/10", async function() {
|
||||
const fetchArraySizeVal = tableSize / 10 + 1;
|
||||
const numRowsVal = tableSize / 10;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.9 numRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
it("149.2.9 numRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = 90;
|
||||
const numRowsVal = 900;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
it("149.2.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
const fetchArraySizeVal = tableSize / 10;
|
||||
const numRowsVal = tableSize / 10 + 1;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.11 numRows = (table size - 1), fetchArraySize = table size", function(done) {
|
||||
it("149.2.11 numRows = (table size - 1), fetchArraySize = table size", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const numRowsVal = tableSize - 1;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("149.2.12 fetchArraySize = (table size - 1), numRows = table size", function(done) {
|
||||
it("149.2.12 fetchArraySize = (table size - 1), numRows = table size", async function() {
|
||||
const fetchArraySizeVal = tableSize - 1;
|
||||
const numRowsVal = tableSize;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
});
|
||||
|
||||
describe("149.3 queryStream() with different maxRows and oracledb.fetchArraySize", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
const testQueryStream = function(fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
const testQueryStream = async function(fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
const resultLenExpected = tableSize - affectedID;
|
||||
const querySql = "select * from " + tableName + " where id > " + affectedID + " order by id";
|
||||
const stream = connection.queryStream(querySql);
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.fail(error, null, 'Error event should not be triggered');
|
||||
});
|
||||
|
||||
const stream = await connection.queryStream(querySql);
|
||||
let counter = 0;
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
counter = counter + 1;
|
||||
verifyResult(data, counter, affectedID);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
should.equal(counter, resultLenExpected);
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
cb();
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.on('error', reject);
|
||||
stream.on('end', function() {
|
||||
assert.strictEqual(counter, resultLenExpected);
|
||||
stream.destroy();
|
||||
});
|
||||
stream.on('close', resolve);
|
||||
stream.on('data', function(data) {
|
||||
assert(data);
|
||||
counter++;
|
||||
verifyResult(data, counter, affectedID);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const verifyResult = function(data, counter, affectedID) {
|
||||
should.strictEqual(data[0], counter + affectedID);
|
||||
should.strictEqual(data[1], String(counter + affectedID));
|
||||
assert.strictEqual(data[0], counter + affectedID);
|
||||
assert.strictEqual(data[1], String(counter + affectedID));
|
||||
};
|
||||
|
||||
it("149.3.1 maxRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
it("149.3.1 maxRows > table size > oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = tableSize - 1;
|
||||
const maxRowsVal = tableSize + 1;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.2 maxRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
it("149.3.2 maxRows > oracledb.fetchArraySize > table size", async function() {
|
||||
const fetchArraySizeVal = tableSize + 101;
|
||||
const maxRowsVal = tableSize + 1000;
|
||||
const affectedID = 20;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.3 table size > maxRows > oracledb.fetchArraySize", function(done) {
|
||||
it("149.3.3 table size > maxRows > oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = tableSize - 11;
|
||||
const maxRowsVal = tableSize - 2;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
it("149.3.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
const fetchArraySizeVal = tableSize - 90;
|
||||
const maxRowsVal = tableSize - 150;
|
||||
const affectedID = 50;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.5 maxRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
it("149.3.5 maxRows = oracledb.fetchArraySize < table size", async function() {
|
||||
const fetchArraySizeVal = tableSize - 110;
|
||||
const maxRowsVal = tableSize - 110;
|
||||
const affectedID = 20;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.6 maxRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
it("149.3.6 maxRows = oracledb.fetchArraySize = table size", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = tableSize;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.7 maxRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
it("149.3.7 maxRows = oracledb.fetchArraySize > table size", async function() {
|
||||
const fetchArraySizeVal = tableSize + 9999;
|
||||
const maxRowsVal = tableSize + 9999;
|
||||
const affectedID = 10;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.8 maxRows = oracledb.fetchArraySize/10", function(done) {
|
||||
it("149.3.8 maxRows = oracledb.fetchArraySize/10", async function() {
|
||||
const fetchArraySizeVal = tableSize / 10 + 1;
|
||||
const maxRowsVal = tableSize / 10;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.9 maxRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
it("149.3.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
const fetchArraySizeVal = 90;
|
||||
const maxRowsVal = 900;
|
||||
const affectedID = 50;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
it("149.3.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
const fetchArraySizeVal = tableSize / 10;
|
||||
const maxRowsVal = tableSize / 10 + 1;
|
||||
const affectedID = 50;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.11 maxRows = 0, fetchArraySize = table size", function(done) {
|
||||
it("149.3.11 maxRows = 0, fetchArraySize = table size", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = 0;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.12 maxRows = 9999999, fetchArraySize = table size", function(done) {
|
||||
it("149.3.12 maxRows = 9999999, fetchArraySize = table size", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = 9999999;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.13 maxRows = (table size - 1), fetchArraySize = table size ", function(done) {
|
||||
it("149.3.13 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
|
||||
const fetchArraySizeVal = tableSize;
|
||||
const maxRowsVal = tableSize - 1;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("149.3.14 fetchArraySize = (table size - 1), maxRows = table size ", function(done) {
|
||||
it("149.3.14 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
|
||||
const fetchArraySizeVal = tableSize - 1;
|
||||
const maxRowsVal = tableSize;
|
||||
const affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -36,17 +36,16 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("150. fetchArraySize3.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var default_fetcArraySize = oracledb.fetchArraySize;
|
||||
var default_maxRows = oracledb.maxRows;
|
||||
var tableName = "nodb_fetchArraySize_150";
|
||||
var tableSize = 1000;
|
||||
let default_fetcArraySize = oracledb.fetchArraySize;
|
||||
let default_maxRows = oracledb.maxRows;
|
||||
let tableName = "nodb_fetchArraySize_150";
|
||||
let tableSize = 1000;
|
||||
|
||||
const create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -74,342 +73,233 @@ describe("150. fetchArraySize3.js", function() {
|
|||
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_fetcArraySize, 100);
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_fetcArraySize, 100);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe("150.1 DML binding", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var dmlBinding = function(fetchArraySize, affectedRowId, cb) {
|
||||
const dmlBinding = async function(fetchArraySize, affectedRowId) {
|
||||
oracledb.fetchArraySize = fetchArraySize;
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"update " + tableName + " set content = :c where id > :num",
|
||||
{
|
||||
num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: "something", dir: oracledb.BIND_IN, type: oracledb.STRING }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, tableSize - affectedRowId);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id > :num order by id",
|
||||
{ num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER } },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows.length, tableSize - affectedRowId);
|
||||
verifyResult(result.rows, affectedRowId);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
let result = await connection.execute(
|
||||
"update " + tableName + " set content = :c where id > :num",
|
||||
{
|
||||
num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: "something", dir: oracledb.BIND_IN, type: oracledb.STRING }
|
||||
}
|
||||
], cb);
|
||||
);
|
||||
assert.strictEqual(result.rowsAffected, tableSize - affectedRowId);
|
||||
|
||||
result = await connection.execute(
|
||||
"select * from " + tableName + " where id > :num order by id",
|
||||
{ num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER } }
|
||||
);
|
||||
assert.strictEqual(result.rows.length, tableSize - affectedRowId);
|
||||
verifyResult(result.rows, affectedRowId);
|
||||
};
|
||||
|
||||
var verifyResult = function(result, affectedRowId) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
let verifyResult = function(result, affectedRowId) {
|
||||
for (let element of result) {
|
||||
let index = result.indexOf(element);
|
||||
verifyEachRow(index + 1 + affectedRowId, element);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var verifyEachRow = function(index, element) {
|
||||
should.strictEqual(element[0], index);
|
||||
should.strictEqual(element[1], "something");
|
||||
let verifyEachRow = function(index, element) {
|
||||
assert.strictEqual(element[0], index);
|
||||
assert.strictEqual(element[1], "something");
|
||||
};
|
||||
|
||||
it("150.1.1 oracledb.fetchArraySize = 1", function(done) {
|
||||
dmlBinding(1, 50, done);
|
||||
it("150.1.1 oracledb.fetchArraySize = 1", async function() {
|
||||
await dmlBinding(1, 50);
|
||||
});
|
||||
|
||||
it("150.1.2 oracledb.fetchArraySize = tableSize/20", function(done) {
|
||||
dmlBinding(tableSize / 20, 0, done);
|
||||
it("150.1.2 oracledb.fetchArraySize = tableSize/20", async function() {
|
||||
await dmlBinding(tableSize / 20, 0);
|
||||
});
|
||||
|
||||
it("150.1.3 oracledb.fetchArraySize = tableSize/10", function(done) {
|
||||
dmlBinding(tableSize / 10, 2, done);
|
||||
it("150.1.3 oracledb.fetchArraySize = tableSize/10", async function() {
|
||||
await dmlBinding(tableSize / 10, 2);
|
||||
});
|
||||
|
||||
it("150.1.4 oracledb.fetchArraySize = tableSize", function(done) {
|
||||
dmlBinding(tableSize, 1, done);
|
||||
it("150.1.4 oracledb.fetchArraySize = tableSize", async function() {
|
||||
await dmlBinding(tableSize, 1);
|
||||
});
|
||||
|
||||
it("150.1.5 oracledb.fetchArraySize = (table size - 1)", function(done) {
|
||||
dmlBinding(tableSize - 1, 0, done);
|
||||
it("150.1.5 oracledb.fetchArraySize = (table size - 1)", async function() {
|
||||
await dmlBinding(tableSize - 1, 0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("150.2 procedure binding", function() {
|
||||
|
||||
var proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_pkg IS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE array_out(ids OUT idType);\n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType); \n" +
|
||||
"END;";
|
||||
const proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_pkg IS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE array_out(ids OUT idType);\n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType); \n" +
|
||||
"END;";
|
||||
|
||||
var proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_pkg IS \n" +
|
||||
" PROCEDURE array_out(ids OUT idType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" SELECT id BULK COLLECT INTO ids from " + tableName + " order by 1; \n" +
|
||||
" END; \n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" update " + tableName + " set content = (contents(1)||' '||to_char(id)) where id > id_in; \n" +
|
||||
" SELECT content BULK COLLECT INTO contents FROM " + tableName + " where id > id_in ORDER BY id; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
var proc_drop = "DROP PACKAGE nodb_ref_pkg";
|
||||
const proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_pkg IS \n" +
|
||||
" PROCEDURE array_out(ids OUT idType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" SELECT id BULK COLLECT INTO ids from " + tableName + " order by 1; \n" +
|
||||
" END; \n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" update " + tableName + " set content = (contents(1)||' '||to_char(id)) where id > id_in; \n" +
|
||||
" SELECT content BULK COLLECT INTO contents FROM " + tableName + " where id > id_in ORDER BY id; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
const proc_drop = "DROP PACKAGE nodb_ref_pkg";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package_body,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
await connection.execute(proc_package);
|
||||
await connection.execute(proc_package_body);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_drop,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_drop);
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var proc_query_inout = function(updateFromId, maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
const proc_query_inout = async function(updateFromId, maxArraySizeVal, fetchArraySizeVal) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"BEGIN nodb_ref_pkg.array_inout(:id_in, :c); END;",
|
||||
{
|
||||
id_in: { type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: updateFromId },
|
||||
c: { type: oracledb.STRING, dir: oracledb.BIND_INOUT, val: ["something new"], maxArraySize: maxArraySizeVal },
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowsAffected = tableSize - updateFromId;
|
||||
should.strictEqual(result.outBinds.c.length, rowsAffected);
|
||||
proc_verifyResult_inout(result.outBinds.c, updateFromId, cb);
|
||||
}
|
||||
);
|
||||
const rowsAffected = tableSize - updateFromId;
|
||||
const outVal = result.outBinds.c;
|
||||
assert.strictEqual(outVal.length, rowsAffected);
|
||||
for (let element of outVal) {
|
||||
const index = outVal.indexOf(element) + updateFromId + 1;
|
||||
assert.strictEqual(element, "something new " + index);
|
||||
}
|
||||
};
|
||||
|
||||
var proc_verifyResult_inout = function(result, updateFromId, callback) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
proc_verifyEachRows_inout(index, element, updateFromId);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var proc_verifyEachRows_inout = function(index, element, updateFromId) {
|
||||
var expectedTail = index + updateFromId + 1;
|
||||
should.strictEqual(element, "something new " + expectedTail);
|
||||
};
|
||||
|
||||
var proc_query_out = function(maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
const proc_query_out = async function(maxArraySizeVal, fetchArraySizeVal) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
connection.execute(
|
||||
const result = await connection.execute(
|
||||
"BEGIN nodb_ref_pkg.array_out(:c); END;",
|
||||
{
|
||||
c: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT, maxArraySize: maxArraySizeVal },
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.outBinds.c.length, tableSize);
|
||||
proc_verifyResult_out(result.outBinds.c);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
const outVal = result.outBinds.c;
|
||||
assert.strictEqual(outVal.length, tableSize);
|
||||
for (let element of outVal) {
|
||||
const index = outVal.indexOf(element);
|
||||
assert.strictEqual(element, index + 1);
|
||||
}
|
||||
};
|
||||
|
||||
var proc_verifyResult_out = function(result) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
proc_verifyEachRow_out(index, element);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
};
|
||||
|
||||
var proc_verifyEachRow_out = function(index, element) {
|
||||
should.strictEqual(element, index + 1);
|
||||
};
|
||||
|
||||
it("150.2.1 Bind OUT with oracledb.fetchArraySize = 1", function(done) {
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.1 Bind OUT with oracledb.fetchArraySize = 1", async function() {
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.2 Bind OUT with oracledb.fetchArraySize = tableSize/20", function(done) {
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.2 Bind OUT with oracledb.fetchArraySize = tableSize/20", async function() {
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.3 Bind OUT with oracledb.fetchArraySize = tableSize/10", function(done) {
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.3 Bind OUT with oracledb.fetchArraySize = tableSize/10", async function() {
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.4 Bind OUT with oracledb.fetchArraySize = tableSize", function(done) {
|
||||
var maxArraySizeVal = tableSize + 1;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.4 Bind OUT with oracledb.fetchArraySize = tableSize", async function() {
|
||||
let maxArraySizeVal = tableSize + 1;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.5 Bind OUT with oracledb.fetchArraySize = (table size - 1)", function(done) {
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.5 Bind OUT with oracledb.fetchArraySize = (table size - 1)", async function() {
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.6 Bind IN OUT with oracledb.fetchArraySize = 1", function(done) {
|
||||
var updateFromId = 20;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.6 Bind IN OUT with oracledb.fetchArraySize = 1", async function() {
|
||||
let updateFromId = 20;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.7 Bind IN OUT with oracledb.fetchArraySize = tableSize/20", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.7 Bind IN OUT with oracledb.fetchArraySize = tableSize/20", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.8 Bind IN OUT with oracledb.fetchArraySize = tableSize/10", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.8 Bind IN OUT with oracledb.fetchArraySize = tableSize/10", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.9 Bind IN OUT with oracledb.fetchArraySize = tableSize", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize + 10;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.9 Bind IN OUT with oracledb.fetchArraySize = tableSize", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize + 10;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.2.10 Bind IN OUT with oracledb.fetchArraySize = (table size - 1)", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.2.10 Bind IN OUT with oracledb.fetchArraySize = (table size - 1)", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("150.3 function binding", function() {
|
||||
|
||||
var proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_fun_pkg AS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" FUNCTION array_out(id_in IN NUMBER) RETURN idType;\n" +
|
||||
" FUNCTION array_inout(id_in IN NUMBER, contents IN OUT stringType) RETURN idType; \n" +
|
||||
"END;";
|
||||
const proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_fun_pkg AS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" FUNCTION array_out(id_in IN NUMBER) RETURN idType;\n" +
|
||||
" FUNCTION array_inout(id_in IN NUMBER, contents IN OUT stringType) RETURN idType; \n" +
|
||||
"END;";
|
||||
|
||||
var proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_fun_pkg AS \n" +
|
||||
let proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_fun_pkg AS \n" +
|
||||
" FUNCTION array_out(id_in IN NUMBER) RETURN idType AS \n" +
|
||||
" tmp_id1 idType; \n" +
|
||||
" BEGIN \n" +
|
||||
|
@ -425,207 +315,136 @@ describe("150. fetchArraySize3.js", function() {
|
|||
" RETURN tmp_id2; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
var proc_drop = "DROP PACKAGE nodb_ref_fun_pkg";
|
||||
const proc_drop = "DROP PACKAGE nodb_ref_fun_pkg";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package_body,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
await connection.execute(proc_package);
|
||||
await connection.execute(proc_package_body);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_drop,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_drop);
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var fun_query_inout = function(updateFromId, maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
const fun_query_inout = async function(updateFromId, maxArraySizeVal, fetchArraySizeVal) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"BEGIN :output := nodb_ref_fun_pkg.array_inout(:id_in, :c_inout); END;",
|
||||
{
|
||||
id_in: { type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: updateFromId },
|
||||
c_inout: { type: oracledb.STRING, dir: oracledb.BIND_INOUT, val: ["something new"], maxArraySize: maxArraySizeVal },
|
||||
output: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT, maxArraySize: maxArraySizeVal }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fun_verifyResult_inout(result.outBinds.c_inout, updateFromId);
|
||||
fun_verifyResult_inout(result.outBinds.output, updateFromId);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
fun_verifyResult_inout(result.outBinds.c_inout, updateFromId);
|
||||
fun_verifyResult_inout(result.outBinds.output, updateFromId);
|
||||
};
|
||||
|
||||
var fun_verifyResult_inout = function(result, updateFromId) {
|
||||
var rowsAffected = tableSize - updateFromId;
|
||||
should.strictEqual(result.length, rowsAffected);
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
fun_verifyEachRow_inout(index, element, updateFromId);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
};
|
||||
|
||||
var fun_verifyEachRow_inout = function(index, element, updateFromId) {
|
||||
if (typeof element === "string") {
|
||||
var expectedTail = index + updateFromId + 1;
|
||||
should.strictEqual(element, "something new " + expectedTail);
|
||||
} else if (typeof element === "number") {
|
||||
should.strictEqual(element, index + 1 + updateFromId);
|
||||
const fun_verifyResult_inout = function(result, updateFromId) {
|
||||
let rowsAffected = tableSize - updateFromId;
|
||||
assert.strictEqual(result.length, rowsAffected);
|
||||
for (let element of result) {
|
||||
const index = result.indexOf(element) + updateFromId + 1;
|
||||
if (typeof element === "string") {
|
||||
assert.strictEqual(element, "something new " + index);
|
||||
} else if (typeof element === "number") {
|
||||
assert.strictEqual(element, index);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var fun_query_out = function(affectFromId, maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
const fun_query_out = async function(affectFromId, maxArraySizeVal, fetchArraySizeVal) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
connection.execute(
|
||||
const result = await connection.execute(
|
||||
"BEGIN :output := nodb_ref_fun_pkg.array_out(:c); END;",
|
||||
{
|
||||
c: { type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: affectFromId },
|
||||
output: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT, maxArraySize: maxArraySizeVal }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.outBinds.output.length, tableSize - affectFromId);
|
||||
fun_verifyResult_out(result.outBinds.output, affectFromId);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
const outVal = result.outBinds.output;
|
||||
assert.strictEqual(outVal.length, tableSize - affectFromId);
|
||||
for (let element of outVal) {
|
||||
const index = outVal.indexOf(element) + affectFromId + 1;
|
||||
assert.strictEqual(element, index);
|
||||
}
|
||||
};
|
||||
|
||||
var fun_verifyResult_out = function(result, affectFromId) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
fun_verifyEachRow_out(index, element, affectFromId);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
};
|
||||
|
||||
var fun_verifyEachRow_out = function(index, element, affectFromId) {
|
||||
should.strictEqual(element, index + 1 + affectFromId);
|
||||
};
|
||||
|
||||
it("150.3.1 Bind OUT with oracledb.fetchArraySize = 1", function(done) {
|
||||
var affectFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.1 Bind OUT with oracledb.fetchArraySize = 1", async function() {
|
||||
let affectFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.2 Bind OUT with oracledb.fetchArraySize = tableSize/20", function(done) {
|
||||
var affectFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.2 Bind OUT with oracledb.fetchArraySize = tableSize/20", async function() {
|
||||
let affectFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.3 Bind OUT with oracledb.fetchArraySize = tableSize/10", function(done) {
|
||||
var affectFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.3 Bind OUT with oracledb.fetchArraySize = tableSize/10", async function() {
|
||||
let affectFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.4 Bind OUT with oracledb.fetchArraySize = tableSize", function(done) {
|
||||
var affectFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.4 Bind OUT with oracledb.fetchArraySize = tableSize", async function() {
|
||||
let affectFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.5 Bind OUT with oracledb.fetchArraySize = (table size - 1)", function(done) {
|
||||
var affectFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.5 Bind OUT with oracledb.fetchArraySize = (table size - 1)", async function() {
|
||||
let affectFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.6 Bind IN OUT with oracledb.fetchArraySize = 1", function(done) {
|
||||
var updateFromId = 20;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.6 Bind IN OUT with oracledb.fetchArraySize = 1", async function() {
|
||||
let updateFromId = 20;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.7 Bind IN OUT with oracledb.fetchArraySize = tableSize/20", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.7 Bind IN OUT with oracledb.fetchArraySize = tableSize/20", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.8 Bind IN OUT with oracledb.fetchArraySize = tableSize/10", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.8 Bind IN OUT with oracledb.fetchArraySize = tableSize/10", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.9 Bind IN OUT with oracledb.fetchArraySize = tableSize", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.9 Bind IN OUT with oracledb.fetchArraySize = tableSize", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("150.3.10 Bind IN OUT with oracledb.fetchArraySize = (table size - 1)", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("150.3.10 Bind IN OUT with oracledb.fetchArraySize = (table size - 1)", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -36,435 +36,358 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("151. fetchArraySize4.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var default_fetcArraySize = oracledb.fetchArraySize;
|
||||
var default_maxRows = oracledb.maxRows;
|
||||
var tableName = "nodb_fetchArraySize_151";
|
||||
var tableSize = 1000;
|
||||
let default_fetcArraySize = oracledb.fetchArraySize;
|
||||
let default_maxRows = oracledb.maxRows;
|
||||
const tableName = "nodb_fetchArraySize_151";
|
||||
let tableSize = 1000;
|
||||
|
||||
let create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content VARCHAR(2000) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
" FOR i IN 1.." + tableSize + " LOOP \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" insert into " + tableName + " values (' || i || ',' || to_char(i) ||') \n" +
|
||||
" '); \n" +
|
||||
" END LOOP; \n" +
|
||||
" commit; \n" +
|
||||
"END; ";
|
||||
const create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content VARCHAR(2000) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
" FOR i IN 1.." + tableSize + " LOOP \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" insert into " + tableName + " values (' || i || ',' || to_char(i) ||') \n" +
|
||||
" '); \n" +
|
||||
" END LOOP; \n" +
|
||||
" commit; \n" +
|
||||
"END; ";
|
||||
|
||||
let drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_fetcArraySize, 100);
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_fetcArraySize, 100);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
||||
describe("151.1 getRows() of resultSet = true", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testGetRow = function(fetchArraySizeVal, numRowsVal, cb) {
|
||||
const testGetRow = async function(fetchArraySizeVal, numRowsVal) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " order by id",
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowCount = 0;
|
||||
fetchRowsFromRS(result.resultSet, numRowsVal, rowCount, cb);
|
||||
}
|
||||
{ resultSet: true }
|
||||
);
|
||||
let rowCount = 0;
|
||||
fetchRowsFromRS(result.resultSet, numRowsVal, rowCount);
|
||||
};
|
||||
|
||||
function fetchRowsFromRS(rs, numRowsVal, rowCount, cb) {
|
||||
rs.getRows(numRowsVal, function(err, rows) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal);
|
||||
if (rows.length > 0) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(rows[i][0], rowCount);
|
||||
should.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
return fetchRowsFromRS(rs, numRowsVal, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
async function fetchRowsFromRS(rs, numRowsVal, rowCount) {
|
||||
let rows = await rs.getRows(numRowsVal);
|
||||
assert(rows.length <= numRowsVal);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
rowCount++;
|
||||
assert.strictEqual(rows[i][0], rowCount);
|
||||
assert.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
});
|
||||
return fetchRowsFromRS(rs, numRowsVal, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
it("151.1.1 numRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var numRowsVal = tableSize + 1;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.1 numRows > table size > oracledb.fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let numRowsVal = tableSize + 1;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.2 numRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 1200;
|
||||
var numRowsVal = tableSize + 10000;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.2 numRows > oracledb.fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 1200;
|
||||
let numRowsVal = tableSize + 10000;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.3 table size > numRows > oracledb.fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 11;
|
||||
var numRowsVal = tableSize - 2;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.3 table size > numRows > oracledb.fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 11;
|
||||
let numRowsVal = tableSize - 2;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var numRowsVal = tableSize - 150;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let numRowsVal = tableSize - 150;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.5 numRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 110;
|
||||
var numRowsVal = tableSize - 110;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.5 numRows = oracledb.fetchArraySize < table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 110;
|
||||
let numRowsVal = tableSize - 110;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.6 numRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var numRowsVal = tableSize;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.6 numRows = oracledb.fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let numRowsVal = tableSize;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.7 numRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 9999;
|
||||
var numRowsVal = tableSize + 9999;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.7 numRows = oracledb.fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 9999;
|
||||
let numRowsVal = tableSize + 9999;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.8 numRows = oracledb.fetchArraySize/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10 + 1;
|
||||
var numRowsVal = tableSize / 10;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.8 numRows = oracledb.fetchArraySize/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10 + 1;
|
||||
let numRowsVal = tableSize / 10;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.9 numRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = 90;
|
||||
var numRowsVal = 900;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.9 numRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = 90;
|
||||
let numRowsVal = 900;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var numRowsVal = tableSize / 10 + 1;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let numRowsVal = tableSize / 10 + 1;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.11 numRows = (table size - 1), fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var numRowsVal = tableSize - 1;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.11 numRows = (table size - 1), fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let numRowsVal = tableSize - 1;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("151.1.12 fetchArraySize = (table size - 1), numRows = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var numRowsVal = tableSize;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("151.1.12 fetchArraySize = (table size - 1), numRows = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let numRowsVal = tableSize;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("151.2 getRow() of resultSet = true", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testGetRows = function(fetchArraySize, cb) {
|
||||
const testGetRows = async function(fetchArraySize) {
|
||||
oracledb.fetchArraySize = fetchArraySize;
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " order by id",
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// should.strictEqual(result.rows.length, default_maxRows);
|
||||
var rowCount = 0;
|
||||
fetchRowFromRS(result.resultSet, rowCount, cb);
|
||||
}
|
||||
{ resultSet: true }
|
||||
);
|
||||
let rowCount = 0;
|
||||
await fetchRowFromRS(result.resultSet, rowCount);
|
||||
};
|
||||
|
||||
function fetchRowFromRS(rs, rowCount, cb) {
|
||||
rs.getRow(function(err, row) {
|
||||
if (row) {
|
||||
rowCount = rowCount + 1;
|
||||
// console.log(rows[i][0]);
|
||||
should.strictEqual(row[0], rowCount);
|
||||
should.strictEqual(row[1], rowCount.toString());
|
||||
return fetchRowFromRS(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
async function fetchRowFromRS(rs, rowCount) {
|
||||
let row = await rs.getRow();
|
||||
if (row) {
|
||||
rowCount++;
|
||||
assert.strictEqual(row[0], rowCount);
|
||||
assert.strictEqual(row[1], rowCount.toString());
|
||||
return await fetchRowFromRS(rs, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
it("151.2.1 oracledb.fetchArraySize = 1", function(done) {
|
||||
testGetRows(1, done);
|
||||
it("151.2.1 oracledb.fetchArraySize = 1", async function() {
|
||||
await testGetRows(1);
|
||||
});
|
||||
|
||||
it("151.2.2 oracledb.fetchArraySize = tableSize/50", function(done) {
|
||||
testGetRows(tableSize / 50, done);
|
||||
it("151.2.2 oracledb.fetchArraySize = tableSize/50", async function() {
|
||||
await testGetRows(tableSize / 50);
|
||||
});
|
||||
|
||||
it("151.2.3 oracledb.fetchArraySize = tableSize/20", function(done) {
|
||||
testGetRows(tableSize / 20, done);
|
||||
it("151.2.3 oracledb.fetchArraySize = tableSize/20", async function() {
|
||||
await testGetRows(tableSize / 20);
|
||||
});
|
||||
|
||||
it("151.2.4 oracledb.fetchArraySize = tableSize/10", function(done) {
|
||||
testGetRows(tableSize / 10, done);
|
||||
it("151.2.4 oracledb.fetchArraySize = tableSize/10", async function() {
|
||||
await testGetRows(tableSize / 10);
|
||||
});
|
||||
|
||||
it("151.2.5 oracledb.fetchArraySize = tableSize/5", function(done) {
|
||||
testGetRows(tableSize / 5, done);
|
||||
it("151.2.5 oracledb.fetchArraySize = tableSize/5", async function() {
|
||||
await testGetRows(tableSize / 5);
|
||||
});
|
||||
|
||||
it("151.2.6 oracledb.fetchArraySize = tableSize", function(done) {
|
||||
testGetRows(tableSize, done);
|
||||
it("151.2.6 oracledb.fetchArraySize = tableSize", async function() {
|
||||
await testGetRows(tableSize);
|
||||
});
|
||||
|
||||
it("151.2.7 oracledb.fetchArraySize = (tableSize - 1)", function(done) {
|
||||
testGetRows(tableSize - 1, done);
|
||||
it("151.2.7 oracledb.fetchArraySize = (tableSize - 1)", async function() {
|
||||
await testGetRows(tableSize - 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("151.3 interleaved calls to getRow() and getRows()", function() {
|
||||
var numRowsVal_1, numRowsVal_2;
|
||||
let numRowsVal_1, numRowsVal_2;
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testRS = function(fetchArraySizeVal, cb) {
|
||||
const testRS = async function(fetchArraySizeVal) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " order by id",
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowCount = 0;
|
||||
fetchRowFromRS(result.resultSet, rowCount, cb);
|
||||
}
|
||||
{ resultSet: true }
|
||||
);
|
||||
let rowCount = 0;
|
||||
await fetchRowFromRS(result.resultSet, rowCount);
|
||||
};
|
||||
|
||||
function fetchRowFromRS(rs, rowCount, cb) {
|
||||
rs.getRow(function(err, row) {
|
||||
if (row) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(row[0], rowCount);
|
||||
should.strictEqual(row[1], rowCount.toString());
|
||||
return fetchRowsFromRS_1(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
async function fetchRowFromRS(rs, rowCount) {
|
||||
let row = await rs.getRow();
|
||||
if (row) {
|
||||
rowCount = rowCount + 1;
|
||||
assert.strictEqual(row[0], rowCount);
|
||||
assert.strictEqual(row[1], rowCount.toString());
|
||||
return await fetchRowsFromRS_1(rs, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
function fetchRowsFromRS_1(rs, rowCount, cb) {
|
||||
rs.getRows(numRowsVal_1, function(err, rows) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal_1);
|
||||
if (rows.length > 0) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(rows[i][0], rowCount);
|
||||
should.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
return fetchRowsFromRS_2(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
async function fetchRowsFromRS_1(rs, rowCount) {
|
||||
let rows = await rs.getRows(numRowsVal_1);
|
||||
assert(rows.length <= numRowsVal_1);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
rowCount++;
|
||||
assert.strictEqual(rows[i][0], rowCount);
|
||||
assert.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
});
|
||||
return await fetchRowsFromRS_2(rs, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
function fetchRowsFromRS_2(rs, rowCount, cb) {
|
||||
rs.getRows(numRowsVal_2, function(err, rows) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal_2);
|
||||
if (rows.length > 0) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(rows[i][0], rowCount);
|
||||
should.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
return fetchRowFromRS(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
async function fetchRowsFromRS_2(rs, rowCount) {
|
||||
let rows = await rs.getRows(numRowsVal_2);
|
||||
assert(rows.length <= numRowsVal_2);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
rowCount++;
|
||||
assert.strictEqual(rows[i][0], rowCount);
|
||||
assert.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
});
|
||||
return await fetchRowFromRS(rs, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
it("151.3.1 oracledb.fetchArraySize = 1", function(done) {
|
||||
var fetchArraySizeVal = 1;
|
||||
it("151.3.1 oracledb.fetchArraySize = 1", async function() {
|
||||
let fetchArraySizeVal = 1;
|
||||
numRowsVal_1 = 2;
|
||||
numRowsVal_2 = 10;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("151.3.2 oracledb.fetchArraySize = tableSize/50", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 50;
|
||||
it("151.3.2 oracledb.fetchArraySize = tableSize/50", async function() {
|
||||
let fetchArraySizeVal = tableSize / 50;
|
||||
numRowsVal_1 = 5;
|
||||
numRowsVal_2 = 88;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("151.3.3 oracledb.fetchArraySize = tableSize/20", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
it("151.3.3 oracledb.fetchArraySize = tableSize/20", async function() {
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
numRowsVal_1 = 50;
|
||||
numRowsVal_2 = 100;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("151.3.4 oracledb.fetchArraySize = tableSize/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
it("151.3.4 oracledb.fetchArraySize = tableSize/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
numRowsVal_1 = 30;
|
||||
numRowsVal_2 = 99;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("151.3.5 oracledb.fetchArraySize = tableSize/5", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 5;
|
||||
it("151.3.5 oracledb.fetchArraySize = tableSize/5", async function() {
|
||||
let fetchArraySizeVal = tableSize / 5;
|
||||
numRowsVal_1 = 5;
|
||||
numRowsVal_2 = 88;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("151.3.6 oracledb.fetchArraySize = tableSize", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
it("151.3.6 oracledb.fetchArraySize = tableSize", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
numRowsVal_1 = 15;
|
||||
numRowsVal_2 = tableSize;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("151.3.6 oracledb.fetchArraySize = (tableSize - 1)", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
it("151.3.6 oracledb.fetchArraySize = (tableSize - 1)", async function() {
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
numRowsVal_1 = tableSize - 1;
|
||||
numRowsVal_2 = tableSize;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -39,16 +39,15 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("152. fetchArraySize5.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var default_maxRows = oracledb.maxRows;
|
||||
var tableName = "nodb_fetchArraySize_152";
|
||||
var tableSize = 1000;
|
||||
let default_maxRows = oracledb.maxRows;
|
||||
const tableName = "nodb_fetchArraySize_152";
|
||||
let tableSize = 1000;
|
||||
|
||||
const create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -76,493 +75,397 @@ describe("152. fetchArraySize5.js", function() {
|
|||
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe("152.1 basic fetch with different maxRows and fetchArraySize", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var basicFetch = function(fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
const basicFetch = async function(fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
connection.execute(
|
||||
const result = await connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id",
|
||||
[],
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
should.strictEqual(result.rows.length, resultLenExpected);
|
||||
verifyResult(result.rows, affectedID, cb);
|
||||
}
|
||||
);
|
||||
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
const rows = result.rows;
|
||||
assert.strictEqual(rows.length, resultLenExpected);
|
||||
for (let element of rows) {
|
||||
const index = rows.indexOf(element) + affectedID + 1;
|
||||
assert.strictEqual(element[1], String(index));
|
||||
assert.strictEqual(element[0], index);
|
||||
}
|
||||
};
|
||||
|
||||
var verifyResult = function(result, affectedID, callback) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
verifyEachRow(index + 1 + affectedID, element);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var verifyEachRow = function(index, element) {
|
||||
should.strictEqual(element[1], String(index));
|
||||
should.strictEqual(element[0], index);
|
||||
};
|
||||
|
||||
it("152.1.1 maxRows > table size > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 50;
|
||||
var maxRowsVal = tableSize + 10000;
|
||||
var affectedID = 20;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.1 maxRows > table size > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 50;
|
||||
let maxRowsVal = tableSize + 10000;
|
||||
let affectedID = 20;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.2 maxRows > fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 1001;
|
||||
var maxRowsVal = tableSize + 10000;
|
||||
var affectedID = 20;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.2 maxRows > fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 1001;
|
||||
let maxRowsVal = tableSize + 10000;
|
||||
let affectedID = 20;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.3 table size > maxRows > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 11;
|
||||
var maxRowsVal = tableSize - 2;
|
||||
var affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.3 table size > maxRows > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 11;
|
||||
let maxRowsVal = tableSize - 2;
|
||||
let affectedID = 0;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.4 table size > fetchArraySize > maxRow", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var maxRowsVal = tableSize - 150;
|
||||
var affectedID = 50;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.4 table size > fetchArraySize > maxRow", async function() {
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let maxRowsVal = tableSize - 150;
|
||||
let affectedID = 50;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.5 maxRows = fetchArraySize < table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 110;
|
||||
var maxRowsVal = tableSize - 110;
|
||||
var affectedID = 20;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.5 maxRows = fetchArraySize < table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 110;
|
||||
let maxRowsVal = tableSize - 110;
|
||||
let affectedID = 20;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.6 maxRows = fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.6 maxRows = fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.7 maxRows = fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 9999;
|
||||
var maxRowsVal = tableSize + 9999;
|
||||
var affectedID = 10;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.7 maxRows = fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 9999;
|
||||
let maxRowsVal = tableSize + 9999;
|
||||
let affectedID = 10;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.8 maxRows = fetchArraySize/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10 + 1;
|
||||
var maxRowsVal = tableSize / 10;
|
||||
var affectedID = 7;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.8 maxRows = fetchArraySize/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10 + 1;
|
||||
let maxRowsVal = tableSize / 10;
|
||||
let affectedID = 7;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.9 maxRows = 10 * fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = 90;
|
||||
var maxRowsVal = 900;
|
||||
var affectedID = 50;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.9 maxRows = 10 * fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = 90;
|
||||
let maxRowsVal = 900;
|
||||
let affectedID = 50;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var maxRowsVal = tableSize / 10 + 1;
|
||||
var affectedID = 50;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let maxRowsVal = tableSize / 10 + 1;
|
||||
let affectedID = 50;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.11 maxRows = 0, fetchArraySize = table size ", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = 0;
|
||||
var affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.11 maxRows = 0, fetchArraySize = table size ", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = 0;
|
||||
let affectedID = 0;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.12 maxRows = (table size - 1), fetchArraySize = table size ", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize - 1;
|
||||
var affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.12 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize - 1;
|
||||
let affectedID = 0;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.1.13 fetchArraySize = (table size - 1), maxRows = table size ", function(done) {
|
||||
var fetchArraySizeVal = 999;
|
||||
var maxRowsVal = 1000;
|
||||
var affectedID = 0;
|
||||
basicFetch(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.1.13 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
|
||||
let fetchArraySizeVal = 999;
|
||||
let maxRowsVal = 1000;
|
||||
let affectedID = 0;
|
||||
await basicFetch(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
describe("152.2 REF CURSORS with different numRows and fetchArraySize", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testRefCursor = function(fetchArraySizeVal, numRowsVal, cb) {
|
||||
var create_ref = "CREATE OR REPLACE PROCEDURE testrefproc (p_out OUT SYS_REFCURSOR) " +
|
||||
"AS " +
|
||||
"BEGIN " +
|
||||
" OPEN p_out FOR " +
|
||||
" SELECT * FROM " + tableName + " order by id;" +
|
||||
"END; ";
|
||||
var drop_ref = "drop procedure testrefproc";
|
||||
var exec_ref = "BEGIN testrefproc(:o); END;";
|
||||
const testRefCursor = async function(fetchArraySizeVal, numRowsVal) {
|
||||
const create_ref = "CREATE OR REPLACE PROCEDURE testrefproc (p_out OUT SYS_REFCURSOR) " +
|
||||
"AS " +
|
||||
"BEGIN " +
|
||||
" OPEN p_out FOR " +
|
||||
" SELECT * FROM " + tableName + " order by id;" +
|
||||
"END; ";
|
||||
const drop_ref = "drop procedure testrefproc";
|
||||
const exec_ref = "BEGIN testrefproc(:o); END;";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
create_ref,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
exec_ref,
|
||||
[
|
||||
{ type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowCount = 0;
|
||||
fetchRowsFromRS(result.outBinds[0], numRowsVal, rowCount, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
drop_ref,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
await connection.execute(create_ref);
|
||||
|
||||
let result = await connection.execute(
|
||||
exec_ref,
|
||||
[
|
||||
{ type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
}
|
||||
], cb);
|
||||
);
|
||||
let rowCount = 0;
|
||||
await fetchRowsFromRS(result.outBinds[0], numRowsVal, rowCount);
|
||||
|
||||
await connection.execute(drop_ref);
|
||||
};
|
||||
|
||||
function fetchRowsFromRS(rs, numRowsVal, rowCount, cb) {
|
||||
rs.getRows(numRowsVal, function(err, rows) {
|
||||
if (rows.length > 0) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal);
|
||||
rowCount = rowCount + 1;
|
||||
// console.log(rows[i][0]);
|
||||
should.strictEqual(rows[i].ID, rowCount);
|
||||
should.strictEqual(rows[i].CONTENT, rowCount.toString());
|
||||
}
|
||||
return fetchRowsFromRS(rs, numRowsVal, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
async function fetchRowsFromRS(rs, numRowsVal, rowCount) {
|
||||
let rows = await rs.getRows(numRowsVal);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
assert(rows.length, numRowsVal);
|
||||
rowCount++;
|
||||
// console.log(rows[i][0]);
|
||||
assert.strictEqual(rows[i].ID, rowCount);
|
||||
assert.strictEqual(rows[i].CONTENT, rowCount.toString());
|
||||
}
|
||||
});
|
||||
return await fetchRowsFromRS(rs, numRowsVal, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
it("152.2.1 numRows > table size > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 50;
|
||||
var numRowsVal = tableSize + 10000;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.1 numRows > table size > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 50;
|
||||
let numRowsVal = tableSize + 10000;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.2 numRows > fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 1200;
|
||||
var numRowsVal = tableSize + 10000;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.2 numRows > fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 1200;
|
||||
let numRowsVal = tableSize + 10000;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.3 table size > numRows > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 21;
|
||||
var numRowsVal = tableSize - 2;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.3 table size > numRows > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 21;
|
||||
let numRowsVal = tableSize - 2;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.4 table size > fetchArraySize > maxRow", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var numRowsVal = tableSize - 150;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.4 table size > fetchArraySize > maxRow", async function() {
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let numRowsVal = tableSize - 150;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.5 numRows = fetchArraySize < table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 110;
|
||||
var numRowsVal = tableSize - 110;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.5 numRows = fetchArraySize < table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 110;
|
||||
let numRowsVal = tableSize - 110;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.6 numRows = fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var numRowsVal = tableSize;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.6 numRows = fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let numRowsVal = tableSize;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.7 numRows = fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 9999;
|
||||
var numRowsVal = tableSize + 9999;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.7 numRows = fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 9999;
|
||||
let numRowsVal = tableSize + 9999;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.8 numRows = fetchArraySize/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10 + 1;
|
||||
var numRowsVal = tableSize / 10;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.8 numRows = fetchArraySize/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10 + 1;
|
||||
let numRowsVal = tableSize / 10;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.9 numRows = 10 * fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = 90;
|
||||
var numRowsVal = 900;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.9 numRows = 10 * fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = 90;
|
||||
let numRowsVal = 900;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var numRowsVal = tableSize / 10 + 1;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let numRowsVal = tableSize / 10 + 1;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.11 numRows = (table size - 1), fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var numRowsVal = tableSize - 1;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.11 numRows = (table size - 1), fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let numRowsVal = tableSize - 1;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("152.2.12 fetchArraySize = (table size - 1), numRows = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var numRowsVal = tableSize;
|
||||
testRefCursor(fetchArraySizeVal, numRowsVal, done);
|
||||
it("152.2.12 fetchArraySize = (table size - 1), numRows = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let numRowsVal = tableSize;
|
||||
await testRefCursor(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
});
|
||||
|
||||
describe("152.3 queryStream() with different maxRows and fetchArraySize", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testQueryStream = function(fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
const testQueryStream = async function(fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
var resultLenExpected = tableSize - affectedID;
|
||||
var querySql = "select * from " + tableName + " where id > " + affectedID + " order by id";
|
||||
var stream = connection.queryStream(querySql, [], {fetchArraySize: fetchArraySizeVal});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.fail(error, null, 'Error event should not be triggered');
|
||||
});
|
||||
|
||||
var counter = 0;
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
counter = counter + 1;
|
||||
verifyResult(data, counter, affectedID);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
should.equal(counter, resultLenExpected);
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
cb();
|
||||
let resultLenExpected = tableSize - affectedID;
|
||||
let querySql = "select * from " + tableName + " where id > " + affectedID + " order by id";
|
||||
let stream = connection.queryStream(querySql, [], {fetchArraySize: fetchArraySizeVal});
|
||||
let counter = 0;
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.on('error', reject);
|
||||
stream.on('data', function(data) {
|
||||
counter++;
|
||||
assert.strictEqual(data[0], counter + affectedID);
|
||||
assert.strictEqual(data[1], String(counter + affectedID));
|
||||
});
|
||||
stream.on('end', function() {
|
||||
assert.strictEqual(counter, resultLenExpected);
|
||||
stream.destroy();
|
||||
});
|
||||
stream.on('close', resolve);
|
||||
});
|
||||
};
|
||||
|
||||
var verifyResult = function(data, counter, affectedID) {
|
||||
should.strictEqual(data[0], counter + affectedID);
|
||||
should.strictEqual(data[1], String(counter + affectedID));
|
||||
};
|
||||
|
||||
it("152.3.1 maxRows > table size > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 50;
|
||||
var maxRowsVal = tableSize + 10000;
|
||||
var affectedID = 20;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.1 maxRows > table size > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 50;
|
||||
let maxRowsVal = tableSize + 10000;
|
||||
let affectedID = 20;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.2 maxRows > fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 1001;
|
||||
var maxRowsVal = tableSize + 10000;
|
||||
var affectedID = 20;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.2 maxRows > fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 1001;
|
||||
let maxRowsVal = tableSize + 10000;
|
||||
let affectedID = 20;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.3 table size > maxRows > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 31;
|
||||
var maxRowsVal = tableSize - 2;
|
||||
var affectedID = 10;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.3 table size > maxRows > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 31;
|
||||
let maxRowsVal = tableSize - 2;
|
||||
let affectedID = 10;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.4 table size > fetchArraySize > maxRow", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var maxRowsVal = tableSize - 150;
|
||||
var affectedID = 50;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.4 table size > fetchArraySize > maxRow", async function() {
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let maxRowsVal = tableSize - 150;
|
||||
let affectedID = 50;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.5 maxRows = fetchArraySize < table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 110;
|
||||
var maxRowsVal = tableSize - 110;
|
||||
var affectedID = 20;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.5 maxRows = fetchArraySize < table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 110;
|
||||
let maxRowsVal = tableSize - 110;
|
||||
let affectedID = 20;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.6 maxRows = fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.6 maxRows = fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.7 maxRows = fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 9999;
|
||||
var maxRowsVal = tableSize + 9999;
|
||||
var affectedID = 10;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.7 maxRows = fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 9999;
|
||||
let maxRowsVal = tableSize + 9999;
|
||||
let affectedID = 10;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.8 maxRows = fetchArraySize/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10 + 1;
|
||||
var maxRowsVal = tableSize / 10;
|
||||
var affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.8 maxRows = fetchArraySize/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10 + 1;
|
||||
let maxRowsVal = tableSize / 10;
|
||||
let affectedID = 0;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.9 maxRows = 10 * fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = 90;
|
||||
var maxRowsVal = 900;
|
||||
var affectedID = 50;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.9 maxRows = 10 * fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = 90;
|
||||
let maxRowsVal = 900;
|
||||
let affectedID = 50;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var maxRowsVal = tableSize / 10 + 1;
|
||||
var affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let maxRowsVal = tableSize / 10 + 1;
|
||||
let affectedID = 0;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.11 maxRows = 0, fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = 0;
|
||||
var affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.11 maxRows = 0, fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = 0;
|
||||
let affectedID = 0;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.12 maxRows = (table size - 1), fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize - 1;
|
||||
var affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.12 maxRows = (table size - 1), fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize - 1;
|
||||
let affectedID = 0;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("152.3.13 fetchArraySize = (table size - 1), maxRows = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("152.3.13 fetchArraySize = (table size - 1), maxRows = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await testQueryStream(fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -36,16 +36,15 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("153. fetchArraySize6.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var default_maxRows = oracledb.maxRows;
|
||||
var tableName = "nodb_fetchArraySize_153";
|
||||
var tableSize = 1000;
|
||||
let default_maxRows = oracledb.maxRows;
|
||||
const tableName = "nodb_fetchArraySize_153";
|
||||
let tableSize = 1000;
|
||||
|
||||
const create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -73,202 +72,119 @@ describe("153. fetchArraySize6.js", function() {
|
|||
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe("153.1 DML binding", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var dmlBinding = function(fetchArraySizeVal, affectedRowId, cb) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"update " + tableName + " set content = :c where id > :num",
|
||||
{
|
||||
num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: "something", dir: oracledb.BIND_IN, type: oracledb.STRING }
|
||||
},
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, tableSize - affectedRowId);
|
||||
callback();
|
||||
});
|
||||
const dmlBinding = async function(fetchArraySizeVal, affectedRowId) {
|
||||
let result = await connection.execute(
|
||||
"update " + tableName + " set content = :c where id > :num",
|
||||
{
|
||||
num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: "something", dir: oracledb.BIND_IN, type: oracledb.STRING }
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id > :num order by id",
|
||||
{ num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER } },
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows.length, tableSize - affectedRowId);
|
||||
verifyResult(result.rows, affectedRowId);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
}
|
||||
], cb);
|
||||
);
|
||||
assert.strictEqual(result.rowsAffected, tableSize - affectedRowId);
|
||||
|
||||
result = await connection.execute(
|
||||
"select * from " + tableName + " where id > :num order by id",
|
||||
{ num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER } },
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
}
|
||||
);
|
||||
const rows = result.rows;
|
||||
assert.strictEqual(rows.length, tableSize - affectedRowId);
|
||||
for (let element of rows) {
|
||||
const index = rows.indexOf(element);
|
||||
assert.strictEqual(element[0], index + affectedRowId + 1);
|
||||
assert.strictEqual(element[1], "something");
|
||||
}
|
||||
};
|
||||
|
||||
var verifyResult = function(result, affectedRowId) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
should.strictEqual(element[0], index + affectedRowId + 1);
|
||||
should.strictEqual(element[1], "something");
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
};
|
||||
|
||||
it("153.1.1 fetchArraySize = 1", function(done) {
|
||||
dmlBinding(1, 50, done);
|
||||
it("153.1.1 fetchArraySize = 1", async function() {
|
||||
await dmlBinding(1, 50);
|
||||
});
|
||||
|
||||
it("153.1.2 fetchArraySize = tableSize/20", function(done) {
|
||||
dmlBinding(tableSize / 20, 0, done);
|
||||
it("153.1.2 fetchArraySize = tableSize/20", async function() {
|
||||
await dmlBinding(tableSize / 20, 0);
|
||||
});
|
||||
|
||||
it("153.1.3 fetchArraySize = tableSize/10", function(done) {
|
||||
dmlBinding(tableSize / 10, 2, done);
|
||||
it("153.1.3 fetchArraySize = tableSize/10", async function() {
|
||||
await dmlBinding(tableSize / 10, 2);
|
||||
});
|
||||
|
||||
it("153.1.4 fetchArraySize = tableSize", function(done) {
|
||||
dmlBinding(tableSize, 0, done);
|
||||
it("153.1.4 fetchArraySize = tableSize", async function() {
|
||||
await dmlBinding(tableSize, 0);
|
||||
});
|
||||
|
||||
it("153.1.5 fetchArraySize = (table size - 1)", function(done) {
|
||||
dmlBinding(tableSize - 1, 0, done);
|
||||
it("153.1.5 fetchArraySize = (table size - 1)", async function() {
|
||||
await dmlBinding(tableSize - 1, 0);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("153.2 procedure binding", function() {
|
||||
|
||||
var proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_pkg IS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE array_out(ids OUT idType);\n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType); \n" +
|
||||
"END;";
|
||||
const proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_pkg IS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE array_out(ids OUT idType);\n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType); \n" +
|
||||
"END;";
|
||||
|
||||
var proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_pkg IS \n" +
|
||||
" PROCEDURE array_out(ids OUT idType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" SELECT id BULK COLLECT INTO ids from " + tableName + " order by 1; \n" +
|
||||
" END; \n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" update " + tableName + " set content = (contents(1)||' '||to_char(id)) where id > id_in; \n" +
|
||||
" SELECT content BULK COLLECT INTO contents FROM " + tableName + " where id > id_in ORDER BY id; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
var proc_drop = "DROP PACKAGE nodb_ref_pkg";
|
||||
const proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_pkg IS \n" +
|
||||
" PROCEDURE array_out(ids OUT idType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" SELECT id BULK COLLECT INTO ids from " + tableName + " order by 1; \n" +
|
||||
" END; \n" +
|
||||
" PROCEDURE array_inout(id_in IN NUMBER, contents IN OUT stringType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" update " + tableName + " set content = (contents(1)||' '||to_char(id)) where id > id_in; \n" +
|
||||
" SELECT content BULK COLLECT INTO contents FROM " + tableName + " where id > id_in ORDER BY id; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
const proc_drop = "DROP PACKAGE nodb_ref_pkg";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package_body,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
await connection.execute(proc_package);
|
||||
await connection.execute(proc_package_body);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_drop,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_drop);
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var proc_query_inout = function(updateFromId, maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
connection.execute(
|
||||
const proc_query_inout = async function(updateFromId, maxArraySizeVal, fetchArraySizeVal) {
|
||||
let result = await connection.execute(
|
||||
"BEGIN nodb_ref_pkg.array_inout(:id_in, :c); END;",
|
||||
{
|
||||
id_in: { type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: updateFromId },
|
||||
|
@ -276,212 +192,146 @@ describe("153. fetchArraySize6.js", function() {
|
|||
},
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowsAffected = tableSize - updateFromId;
|
||||
should.strictEqual(result.outBinds.c.length, rowsAffected);
|
||||
proc_verifyResult_inout(result.outBinds.c, updateFromId, cb);
|
||||
}
|
||||
);
|
||||
const rowsAffected = tableSize - updateFromId;
|
||||
const outVal = result.outBinds.c;
|
||||
assert.strictEqual(outVal.length, rowsAffected);
|
||||
for (let element of outVal) {
|
||||
const index = outVal.indexOf(element) + updateFromId + 1;
|
||||
assert.strictEqual(element, "something new " + index);
|
||||
}
|
||||
};
|
||||
|
||||
var proc_verifyResult_inout = function(result, updateFromId, callback) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
var expectedTail = index + updateFromId + 1;
|
||||
should.strictEqual(element, "something new " + expectedTail);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var proc_query_out = function(maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
connection.execute(
|
||||
let proc_query_out = async function(maxArraySizeVal, fetchArraySizeVal) {
|
||||
let result = await connection.execute(
|
||||
"BEGIN nodb_ref_pkg.array_out(:c); END;",
|
||||
{
|
||||
c: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT, maxArraySize: maxArraySizeVal },
|
||||
},
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.outBinds.c.length, tableSize);
|
||||
proc_verifyResult_out(result.outBinds.c);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
const outVal = result.outBinds.c;
|
||||
assert.strictEqual(outVal.length, tableSize);
|
||||
for (let element of outVal) {
|
||||
const index = outVal.indexOf(element);
|
||||
assert.strictEqual(element, index + 1);
|
||||
}
|
||||
};
|
||||
|
||||
var proc_verifyResult_out = function(result) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
should.strictEqual(element, index + 1);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
};
|
||||
|
||||
it("153.2.1 Bind OUT with fetchArraySize = 1", function(done) {
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.1 Bind OUT with fetchArraySize = 1", async function() {
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.2 Bind OUT with fetchArraySize = tableSize/20", function(done) {
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.2 Bind OUT with fetchArraySize = tableSize/20", async function() {
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.3 Bind OUT with fetchArraySize = tableSize/10", function(done) {
|
||||
var maxArraySizeVal = tableSize * 10;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.3 Bind OUT with fetchArraySize = tableSize/10", async function() {
|
||||
let maxArraySizeVal = tableSize * 10;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.4 Bind OUT with fetchArraySize = tableSize", function(done) {
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.4 Bind OUT with fetchArraySize = tableSize", async function() {
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.5 Bind OUT with fetchArraySize = (table size - 1)", function(done) {
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
proc_query_out(maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.5 Bind OUT with fetchArraySize = (table size - 1)", async function() {
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await proc_query_out(maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.6 Bind IN OUT with fetchArraySize = 1", function(done) {
|
||||
var updateFromId = 20;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.6 Bind IN OUT with fetchArraySize = 1", async function() {
|
||||
let updateFromId = 20;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.7 Bind IN OUT with fetchArraySize = tableSize/20", function(done) {
|
||||
var updateFromId = 20;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.7 Bind IN OUT with fetchArraySize = tableSize/20", async function() {
|
||||
let updateFromId = 20;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.8 Bind IN OUT with fetchArraySize = tableSize/10", function(done) {
|
||||
var updateFromId = 10;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.8 Bind IN OUT with fetchArraySize = tableSize/10", async function() {
|
||||
let updateFromId = 10;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.9 Bind IN OUT with fetchArraySize = tableSize", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.9 Bind IN OUT with fetchArraySize = tableSize", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.2.10 Bind IN OUT with fetchArraySize = (table size - 1)", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.2.10 Bind IN OUT with fetchArraySize = (table size - 1)", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await proc_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("153.3 function binding", function() {
|
||||
|
||||
var proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_fun_pkg AS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" FUNCTION array_out(id_in IN NUMBER) RETURN idType;\n" +
|
||||
" FUNCTION array_inout(id_in IN NUMBER, contents IN OUT stringType) RETURN idType; \n" +
|
||||
"END;";
|
||||
const proc_package = "CREATE OR REPLACE PACKAGE nodb_ref_fun_pkg AS\n" +
|
||||
" TYPE idType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" FUNCTION array_out(id_in IN NUMBER) RETURN idType;\n" +
|
||||
" FUNCTION array_inout(id_in IN NUMBER, contents IN OUT stringType) RETURN idType; \n" +
|
||||
"END;";
|
||||
|
||||
var proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_fun_pkg AS \n" +
|
||||
" FUNCTION array_out(id_in IN NUMBER) RETURN idType AS \n" +
|
||||
" tmp_id1 idType; \n" +
|
||||
" BEGIN \n" +
|
||||
" SELECT id BULK COLLECT INTO tmp_id1 from " + tableName + " where id > id_in ORDER BY 1; \n" +
|
||||
" RETURN tmp_id1; \n" +
|
||||
" END; \n" +
|
||||
" FUNCTION array_inout(id_in IN NUMBER, contents IN OUT stringType) RETURN idType AS \n" +
|
||||
" tmp_id2 idType; \n" +
|
||||
" BEGIN \n" +
|
||||
" update " + tableName + " set content = (contents(1)||' '||to_char(id)) where id > id_in; \n" +
|
||||
" SELECT content BULK COLLECT INTO contents FROM " + tableName + " where id > id_in ORDER BY id; \n" +
|
||||
" SELECT id BULK COLLECT INTO tmp_id2 FROM " + tableName + " where id > id_in ORDER BY 1; \n" +
|
||||
" RETURN tmp_id2; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
var proc_drop = "DROP PACKAGE nodb_ref_fun_pkg";
|
||||
const proc_package_body = "CREATE OR REPLACE PACKAGE BODY nodb_ref_fun_pkg AS \n" +
|
||||
" FUNCTION array_out(id_in IN NUMBER) RETURN idType AS \n" +
|
||||
" tmp_id1 idType; \n" +
|
||||
" BEGIN \n" +
|
||||
" SELECT id BULK COLLECT INTO tmp_id1 from " + tableName + " where id > id_in ORDER BY 1; \n" +
|
||||
" RETURN tmp_id1; \n" +
|
||||
" END; \n" +
|
||||
" FUNCTION array_inout(id_in IN NUMBER, contents IN OUT stringType) RETURN idType AS \n" +
|
||||
" tmp_id2 idType; \n" +
|
||||
" BEGIN \n" +
|
||||
" update " + tableName + " set content = (contents(1)||' '||to_char(id)) where id > id_in; \n" +
|
||||
" SELECT content BULK COLLECT INTO contents FROM " + tableName + " where id > id_in ORDER BY id; \n" +
|
||||
" SELECT id BULK COLLECT INTO tmp_id2 FROM " + tableName + " where id > id_in ORDER BY 1; \n" +
|
||||
" RETURN tmp_id2; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
const proc_drop = "DROP PACKAGE nodb_ref_fun_pkg";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_package_body,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
await connection.execute(proc_package);
|
||||
await connection.execute(proc_package_body);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_drop,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_drop);
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var fun_query_inout = function(updateFromId, maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
connection.execute(
|
||||
const fun_query_inout = async function(updateFromId, maxArraySizeVal, fetchArraySizeVal) {
|
||||
let result = await connection.execute(
|
||||
"BEGIN :output := nodb_ref_fun_pkg.array_inout(:id_in, :c_inout); END;",
|
||||
{
|
||||
id_in: { type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: updateFromId },
|
||||
|
@ -490,36 +340,28 @@ describe("153. fetchArraySize6.js", function() {
|
|||
},
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fun_verifyResult_inout(result.outBinds.c_inout, updateFromId);
|
||||
fun_verifyResult_inout(result.outBinds.output, updateFromId);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
fun_verifyResult_inout(result.outBinds.c_inout, updateFromId);
|
||||
fun_verifyResult_inout(result.outBinds.output, updateFromId);
|
||||
};
|
||||
|
||||
var fun_verifyResult_inout = function(result, updateFromId) {
|
||||
var rowsAffected = tableSize - updateFromId;
|
||||
should.strictEqual(result.length, rowsAffected);
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
const fun_verifyResult_inout = function(result, updateFromId) {
|
||||
let rowsAffected = tableSize - updateFromId;
|
||||
assert.strictEqual(result.length, rowsAffected);
|
||||
for (let element of result) {
|
||||
let index = result.indexOf(element);
|
||||
if (typeof element === "string") {
|
||||
var expectedTail = index + updateFromId + 1;
|
||||
should.strictEqual(element, "something new " + expectedTail);
|
||||
let expectedTail = index + updateFromId + 1;
|
||||
assert.strictEqual(element, "something new " + expectedTail);
|
||||
} else if (typeof element === "number") {
|
||||
should.strictEqual(element, index + 1 + updateFromId);
|
||||
assert.strictEqual(element, index + 1 + updateFromId);
|
||||
}
|
||||
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var fun_query_out = function(affectFromId, maxArraySizeVal, fetchArraySizeVal, cb) {
|
||||
connection.execute(
|
||||
const fun_query_out = async function(affectFromId, maxArraySizeVal, fetchArraySizeVal) {
|
||||
let result = await connection.execute(
|
||||
"BEGIN :output := nodb_ref_fun_pkg.array_out(:c); END;",
|
||||
{
|
||||
c: { type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: affectFromId },
|
||||
|
@ -527,94 +369,84 @@ describe("153. fetchArraySize6.js", function() {
|
|||
},
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.outBinds.output.length, tableSize - affectFromId);
|
||||
fun_verifyResult_out(result.outBinds.output, affectFromId);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
const outVal = result.outBinds.output;
|
||||
assert.strictEqual(outVal.length, tableSize - affectFromId);
|
||||
for (let element of outVal) {
|
||||
const index = outVal.indexOf(element);
|
||||
assert.strictEqual(element, index + 1 + affectFromId);
|
||||
}
|
||||
};
|
||||
|
||||
var fun_verifyResult_out = function(result, affectFromId) {
|
||||
async.forEach(result, function(element, cb) {
|
||||
var index = result.indexOf(element);
|
||||
should.strictEqual(element, index + 1 + affectFromId);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
};
|
||||
|
||||
it("153.3.1 Bind OUT with fetchArraySize = 1", function(done) {
|
||||
var affectFromId = 10;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.1 Bind OUT with fetchArraySize = 1", async function() {
|
||||
let affectFromId = 10;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.2 Bind OUT with fetchArraySize = tableSize/20", function(done) {
|
||||
var affectFromId = 20;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.2 Bind OUT with fetchArraySize = tableSize/20", async function() {
|
||||
let affectFromId = 20;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.3 Bind OUT with fetchArraySize = tableSize/10", function(done) {
|
||||
var affectFromId = 5;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.3 Bind OUT with fetchArraySize = tableSize/10", async function() {
|
||||
let affectFromId = 5;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.4 Bind OUT with fetchArraySize = tableSize", function(done) {
|
||||
var affectFromId = 29;
|
||||
var maxArraySizeVal = tableSize * 10;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.4 Bind OUT with fetchArraySize = tableSize", async function() {
|
||||
let affectFromId = 29;
|
||||
let maxArraySizeVal = tableSize * 10;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.5 Bind OUT with fetchArraySize = (table size - 1)", function(done) {
|
||||
var affectFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 10;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.5 Bind OUT with fetchArraySize = (table size - 1)", async function() {
|
||||
let affectFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 10;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await fun_query_out(affectFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.6 Bind IN OUT with fetchArraySize = 1", function(done) {
|
||||
var updateFromId = 20;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = 1;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.6 Bind IN OUT with fetchArraySize = 1", async function() {
|
||||
let updateFromId = 20;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = 1;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.7 Bind IN OUT with fetchArraySize = tableSize/20", function(done) {
|
||||
var updateFromId = 20;
|
||||
var maxArraySizeVal = tableSize;
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.7 Bind IN OUT with fetchArraySize = tableSize/20", async function() {
|
||||
let updateFromId = 20;
|
||||
let maxArraySizeVal = tableSize;
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.8 Bind IN OUT with fetchArraySize = tableSize/10", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.8 Bind IN OUT with fetchArraySize = tableSize/10", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.9 Bind IN OUT with fetchArraySize = tableSize", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.9 Bind IN OUT with fetchArraySize = tableSize", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("153.3.10 Bind IN OUT with fetchArraySize = (table size - 1)", function(done) {
|
||||
var updateFromId = 0;
|
||||
var maxArraySizeVal = tableSize * 2;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal, done);
|
||||
it("153.3.10 Bind IN OUT with fetchArraySize = (table size - 1)", async function() {
|
||||
let updateFromId = 0;
|
||||
let maxArraySizeVal = tableSize * 2;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
await fun_query_inout(updateFromId, maxArraySizeVal, fetchArraySizeVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -36,15 +36,15 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("154. fetchArraySize7.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var default_maxRows = oracledb.maxRows;
|
||||
var tableName = "nodb_fetchArraySize_154";
|
||||
var tableSize = 1000;
|
||||
let default_maxRows = oracledb.maxRows;
|
||||
const tableName = "nodb_fetchArraySize_154";
|
||||
const tableSize = 1000;
|
||||
|
||||
const create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -72,401 +72,326 @@ describe("154. fetchArraySize7.js", function() {
|
|||
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
||||
describe("154.1 getRows() of resultSet = true", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testGetRow = function(fetchArraySizeVal, numRowsVal, cb) {
|
||||
const testGetRow = async function(fetchArraySizeVal, numRowsVal) {
|
||||
|
||||
connection.execute(
|
||||
const result = await connection.execute(
|
||||
"select * from " + tableName + " order by id",
|
||||
[],
|
||||
{
|
||||
resultSet: true,
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowCount = 0;
|
||||
fetchRowsFromRS(result.resultSet, numRowsVal, rowCount, cb);
|
||||
}
|
||||
);
|
||||
let rowCount = 0;
|
||||
fetchRowsFromRS(result.resultSet, numRowsVal, rowCount);
|
||||
};
|
||||
|
||||
function fetchRowsFromRS(rs, numRowsVal, rowCount, cb) {
|
||||
rs.getRows(numRowsVal, function(err, rows) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal);
|
||||
if (rows.length > 0) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(rows[i][0], rowCount);
|
||||
should.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
return fetchRowsFromRS(rs, numRowsVal, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
async function fetchRowsFromRS(rs, numRowsVal, rowCount) {
|
||||
let rows = await rs.getRows(numRowsVal);
|
||||
assert(rows.length <= numRowsVal);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
assert.strictEqual(rows[i][0], rowCount);
|
||||
assert.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
});
|
||||
return await fetchRowsFromRS(rs, numRowsVal, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
it("154.1.1 numRows > table size > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 50;
|
||||
var numRowsVal = tableSize + 10000;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.1 numRows > table size > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 50;
|
||||
let numRowsVal = tableSize + 10000;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.2 numRows > fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 1200;
|
||||
var numRowsVal = tableSize + 10000;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.2 numRows > fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 1200;
|
||||
let numRowsVal = tableSize + 10000;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.3 table size > numRows > fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 91;
|
||||
var numRowsVal = tableSize - 2;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.3 table size > numRows > fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = tableSize - 91;
|
||||
let numRowsVal = tableSize - 2;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.4 table size > fetchArraySize > maxRow", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var numRowsVal = tableSize - 150;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.4 table size > fetchArraySize > maxRow", async function() {
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let numRowsVal = tableSize - 150;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.5 numRows = fetchArraySize < table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 110;
|
||||
var numRowsVal = tableSize - 110;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.5 numRows = fetchArraySize < table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 110;
|
||||
let numRowsVal = tableSize - 110;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.6 numRows = fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var numRowsVal = tableSize;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.6 numRows = fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let numRowsVal = tableSize;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.7 numRows = fetchArraySize > table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize + 9999;
|
||||
var numRowsVal = tableSize + 9999;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.7 numRows = fetchArraySize > table size", async function() {
|
||||
let fetchArraySizeVal = tableSize + 9999;
|
||||
let numRowsVal = tableSize + 9999;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.8 numRows = fetchArraySize/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10 + 1;
|
||||
var numRowsVal = tableSize / 10;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.8 numRows = fetchArraySize/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10 + 1;
|
||||
let numRowsVal = tableSize / 10;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.9 numRows = 10 * fetchArraySize", function(done) {
|
||||
var fetchArraySizeVal = 90;
|
||||
var numRowsVal = 900;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.9 numRows = 10 * fetchArraySize", async function() {
|
||||
let fetchArraySizeVal = 90;
|
||||
let numRowsVal = 900;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var numRowsVal = tableSize / 10 + 1;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.10 numRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let numRowsVal = tableSize / 10 + 1;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.11 numRows = (table size - 1), fetchArraySize = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var numRowsVal = tableSize - 1;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.11 numRows = (table size - 1), fetchArraySize = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let numRowsVal = tableSize - 1;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
it("154.1.12 fetchArraySize = (table size - 1), numRows = table size", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var numRowsVal = tableSize;
|
||||
testGetRow(fetchArraySizeVal, numRowsVal, done);
|
||||
it("154.1.12 fetchArraySize = (table size - 1), numRows = table size", async function() {
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let numRowsVal = tableSize;
|
||||
await testGetRow(fetchArraySizeVal, numRowsVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("154.2 getRow() of resultSet = true", function() {
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testGetRows = function(fetchArraySizeVal, cb) {
|
||||
connection.execute(
|
||||
const testGetRows = async function(fetchArraySizeVal) {
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " order by id",
|
||||
[],
|
||||
{
|
||||
resultSet: true,
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// should.strictEqual(result.rows.length, default_maxRows);
|
||||
var rowCount = 0;
|
||||
fetchRowFromRS(result.resultSet, rowCount, cb);
|
||||
}
|
||||
);
|
||||
let rowCount = 0;
|
||||
// assert.strictEqual(result.rows.length, default_maxRows);
|
||||
await fetchRowFromRS(result.resultSet, rowCount);
|
||||
};
|
||||
|
||||
function fetchRowFromRS(rs, rowCount, cb) {
|
||||
rs.getRow(function(err, row) {
|
||||
if (row) {
|
||||
rowCount = rowCount + 1;
|
||||
// console.log(rows[i][0]);
|
||||
should.strictEqual(row[0], rowCount);
|
||||
should.strictEqual(row[1], rowCount.toString());
|
||||
return fetchRowFromRS(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
async function fetchRowFromRS(rs, rowCount) {
|
||||
let row = await rs.getRow();
|
||||
if (row) {
|
||||
rowCount = rowCount + 1;
|
||||
// console.log(rows[i][0]);
|
||||
assert.strictEqual(row[0], rowCount);
|
||||
assert.strictEqual(row[1], rowCount.toString());
|
||||
return fetchRowFromRS(rs, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
it("154.2.1 fetchArraySize = 1", function(done) {
|
||||
testGetRows(1, done);
|
||||
it("154.2.1 fetchArraySize = 1", async function() {
|
||||
await testGetRows(1);
|
||||
});
|
||||
|
||||
it("154.2.2 fetchArraySize = tableSize/50", function(done) {
|
||||
testGetRows(tableSize / 50, done);
|
||||
it("154.2.2 fetchArraySize = tableSize/50", async function() {
|
||||
await testGetRows(tableSize / 50);
|
||||
});
|
||||
|
||||
it("154.2.3 fetchArraySize = tableSize/20", function(done) {
|
||||
testGetRows(tableSize / 20, done);
|
||||
it("154.2.3 fetchArraySize = tableSize/20", async function() {
|
||||
await testGetRows(tableSize / 20);
|
||||
});
|
||||
|
||||
it("154.2.4 fetchArraySize = tableSize/10", function(done) {
|
||||
testGetRows(tableSize / 10, done);
|
||||
it("154.2.4 fetchArraySize = tableSize/10", async function() {
|
||||
await testGetRows(tableSize / 10);
|
||||
});
|
||||
|
||||
it("154.2.5 fetchArraySize = tableSize/5", function(done) {
|
||||
testGetRows(tableSize / 5, done);
|
||||
it("154.2.5 fetchArraySize = tableSize/5", async function() {
|
||||
await testGetRows(tableSize / 5);
|
||||
});
|
||||
|
||||
it("154.2.6 fetchArraySize = tableSize", function(done) {
|
||||
testGetRows(tableSize, done);
|
||||
it("154.2.6 fetchArraySize = tableSize", async function() {
|
||||
await testGetRows(tableSize);
|
||||
});
|
||||
|
||||
it("154.2.7 fetchArraySize = (table size - 1)", function(done) {
|
||||
testGetRows(tableSize - 1, done);
|
||||
it("154.2.7 fetchArraySize = (table size - 1)", async function() {
|
||||
await testGetRows(tableSize - 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("154.3 interleaved calls to getRow() and getRows()", function() {
|
||||
var numRowsVal_1, numRowsVal_2;
|
||||
let numRowsVal_1, numRowsVal_2;
|
||||
|
||||
before(function(done) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
await connection.execute(create_table);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var testRS = function(fetchArraySizeVal, cb) {
|
||||
connection.execute(
|
||||
const testRS = async function(fetchArraySizeVal) {
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " order by id",
|
||||
[],
|
||||
{
|
||||
resultSet: true,
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowCount = 0;
|
||||
fetchRowFromRS(result.resultSet, rowCount, cb);
|
||||
}
|
||||
);
|
||||
let rowCount = 0;
|
||||
fetchRowFromRS(result.resultSet, rowCount);
|
||||
};
|
||||
|
||||
function fetchRowFromRS(rs, rowCount, cb) {
|
||||
rs.getRow(function(err, row) {
|
||||
if (row) {
|
||||
async function fetchRowFromRS(rs, rowCount) {
|
||||
let row = await rs.getRow();
|
||||
if (row) {
|
||||
rowCount = rowCount + 1;
|
||||
assert.strictEqual(row[0], rowCount);
|
||||
assert.strictEqual(row[1], rowCount.toString());
|
||||
return await fetchRowsFromRS_1(rs, rowCount);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchRowsFromRS_1(rs, rowCount, cb) {
|
||||
let rows = await rs.getRows(numRowsVal_1);
|
||||
assert(rows.length <= numRowsVal_1);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(row[0], rowCount);
|
||||
should.strictEqual(row[1], rowCount.toString());
|
||||
return fetchRowsFromRS_1(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
assert.strictEqual(rows[i][0], rowCount);
|
||||
assert.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
});
|
||||
return await fetchRowsFromRS_2(rs, rowCount, cb);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
function fetchRowsFromRS_1(rs, rowCount, cb) {
|
||||
rs.getRows(numRowsVal_1, function(err, rows) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal_1);
|
||||
if (rows.length > 0) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(rows[i][0], rowCount);
|
||||
should.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
return fetchRowsFromRS_2(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
async function fetchRowsFromRS_2(rs, rowCount, cb) {
|
||||
let rows = await rs.getRows(numRowsVal_2);
|
||||
assert(rows.length <= numRowsVal_2);
|
||||
if (rows.length > 0) {
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
assert.strictEqual(rows[i][0], rowCount);
|
||||
assert.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
});
|
||||
return await fetchRowFromRS(rs, rowCount, cb);
|
||||
} else {
|
||||
assert.strictEqual(rowCount, tableSize);
|
||||
await rs.close();
|
||||
}
|
||||
}
|
||||
|
||||
function fetchRowsFromRS_2(rs, rowCount, cb) {
|
||||
rs.getRows(numRowsVal_2, function(err, rows) {
|
||||
(rows.length).should.be.belowOrEqual(numRowsVal_2);
|
||||
if (rows.length > 0) {
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
rowCount = rowCount + 1;
|
||||
should.strictEqual(rows[i][0], rowCount);
|
||||
should.strictEqual(rows[i][1], rowCount.toString());
|
||||
}
|
||||
return fetchRowFromRS(rs, rowCount, cb);
|
||||
} else {
|
||||
should.strictEqual(rowCount, tableSize);
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
it("154.3.1 fetchArraySize = 1", function(done) {
|
||||
var fetchArraySizeVal = 1;
|
||||
it("154.3.1 fetchArraySize = 1", async function() {
|
||||
let fetchArraySizeVal = 1;
|
||||
numRowsVal_1 = 2;
|
||||
numRowsVal_2 = 10;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("154.3.2 fetchArraySize = tableSize/50", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 50;
|
||||
it("154.3.2 fetchArraySize = tableSize/50", async function() {
|
||||
let fetchArraySizeVal = tableSize / 50;
|
||||
numRowsVal_1 = 5;
|
||||
numRowsVal_2 = 88;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("154.3.3 fetchArraySize = tableSize/20", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 20;
|
||||
it("154.3.3 fetchArraySize = tableSize/20", async function() {
|
||||
let fetchArraySizeVal = tableSize / 20;
|
||||
numRowsVal_1 = 50;
|
||||
numRowsVal_2 = 100;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("154.3.4 fetchArraySize = tableSize/10", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
it("154.3.4 fetchArraySize = tableSize/10", async function() {
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
numRowsVal_1 = 30;
|
||||
numRowsVal_2 = 99;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("154.3.5 fetchArraySize = tableSize/5", function(done) {
|
||||
var fetchArraySizeVal = tableSize / 5;
|
||||
it("154.3.5 fetchArraySize = tableSize/5", async function() {
|
||||
let fetchArraySizeVal = tableSize / 5;
|
||||
numRowsVal_1 = 5;
|
||||
numRowsVal_2 = 88;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("154.3.6 fetchArraySize = tableSize", function(done) {
|
||||
var fetchArraySizeVal = tableSize;
|
||||
it("154.3.6 fetchArraySize = tableSize", async function() {
|
||||
let fetchArraySizeVal = tableSize;
|
||||
numRowsVal_1 = 15;
|
||||
numRowsVal_2 = tableSize;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
it("154.3.7 fetchArraySize = (tableSize - 1)", function(done) {
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
it("154.3.7 fetchArraySize = (tableSize - 1)", async function() {
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
numRowsVal_1 = tableSize - 1;
|
||||
numRowsVal_2 = tableSize;
|
||||
testRS(fetchArraySizeVal, done);
|
||||
await testRS(fetchArraySizeVal);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -33,16 +33,15 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require ('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe("155. fetchArraySize8.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var default_fetcArraySize = oracledb.fetchArraySize;
|
||||
var default_maxRows = oracledb.maxRows;
|
||||
var tableName = "nodb_fetchArraySize_155";
|
||||
let default_fetcArraySize = oracledb.fetchArraySize;
|
||||
let default_maxRows = oracledb.maxRows;
|
||||
const tableName = "nodb_fetchArraySize_155";
|
||||
|
||||
const create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -64,333 +63,275 @@ describe("155. fetchArraySize8.js", function() {
|
|||
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_fetcArraySize, 100);
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_fetcArraySize, 100);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe("155.1 Streaming clobs with different oracledb.fetchArraySize", function() {
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var basicFetchWithGlobalOption = function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback() ;
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
insertData(tableSize, callback);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
should.strictEqual(result.rows.length, resultLenExpected);
|
||||
verifyResult(result.rows, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], cb);
|
||||
const basicFetchWithGlobalOption = async function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
await connection.execute(create_table);
|
||||
await insertData(tableSize);
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id"
|
||||
);
|
||||
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
assert.strictEqual(result.rows.length, resultLenExpected);
|
||||
await verifyResult(result.rows);
|
||||
|
||||
await connection.execute(drop_table);
|
||||
};
|
||||
|
||||
it("155.1.1 maxRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize / 2;
|
||||
var maxRowsVal = tableSize * 2;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.1 maxRows > table size > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize / 2;
|
||||
let maxRowsVal = tableSize * 2;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.2 maxRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize + 10;
|
||||
var maxRowsVal = tableSize * 3;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.2 maxRows > oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize + 10;
|
||||
let maxRowsVal = tableSize * 3;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.3 table size > maxRows > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 199;
|
||||
var fetchArraySizeVal = tableSize - 80;
|
||||
var maxRowsVal = tableSize - 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.3 table size > maxRows > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 199;
|
||||
let fetchArraySizeVal = tableSize - 80;
|
||||
let maxRowsVal = tableSize - 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
var tableSize = 290;
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var maxRowsVal = tableSize - 150;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
let tableSize = 290;
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let maxRowsVal = tableSize - 150;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.5 maxRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize - 3;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.5 maxRows = oracledb.fetchArraySize < table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize - 3;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.6 maxRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.6 maxRows = oracledb.fetchArraySize = table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.7 maxRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 10;
|
||||
var fetchArraySizeVal = tableSize + 30;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.7 maxRows = oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 10;
|
||||
let fetchArraySizeVal = tableSize + 30;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.8 maxRows = oracledb.fetchArraySize/10", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal / 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.8 maxRows = oracledb.fetchArraySize/10", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal / 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.9 maxRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 2;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal * 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 2;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal * 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var tableSize = 200;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var maxRowsVal = fetchArraySizeVal + 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let tableSize = 200;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let maxRowsVal = fetchArraySizeVal + 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.11 maxRows = 0, fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = 0;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.11 maxRows = 0, fetchArraySize = table size ", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = 0;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.12 maxRows = (table size - 1), fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize - 1;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.12 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize - 1;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.1.13 fetchArraySize = (table size - 1), maxRows = table size ", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.1.13 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
describe("155.2 Streaming clobs with different execute() option fetchArraySize", function() {
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var basicFetchWithExecOption = function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback() ;
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
insertData(tableSize, callback);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id",
|
||||
[],
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
should.strictEqual(result.rows.length, resultLenExpected);
|
||||
verifyResult(result.rows, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
const basicFetchWithExecOption = async function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
await connection.execute(create_table);
|
||||
await insertData(tableSize);
|
||||
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id",
|
||||
[],
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
}
|
||||
], cb);
|
||||
);
|
||||
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
assert.strictEqual(result.rows.length, resultLenExpected);
|
||||
await verifyResult(result.rows);
|
||||
};
|
||||
|
||||
it("155.2.1 maxRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize - 50;
|
||||
var maxRowsVal = tableSize + 200;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.1 maxRows > table size > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize - 50;
|
||||
let maxRowsVal = tableSize + 200;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.2 maxRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize + 30;
|
||||
var maxRowsVal = tableSize + 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.2 maxRows > oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize + 30;
|
||||
let maxRowsVal = tableSize + 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.3 table size > maxRows > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 199;
|
||||
var fetchArraySizeVal = tableSize - 130;
|
||||
var maxRowsVal = tableSize - 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.3 table size > maxRows > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 199;
|
||||
let fetchArraySizeVal = tableSize - 130;
|
||||
let maxRowsVal = tableSize - 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
var tableSize = 290;
|
||||
var fetchArraySizeVal = tableSize - 10;
|
||||
var maxRowsVal = tableSize - 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
let tableSize = 290;
|
||||
let fetchArraySizeVal = tableSize - 10;
|
||||
let maxRowsVal = tableSize - 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.5 maxRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize - 3;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.5 maxRows = oracledb.fetchArraySize < table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize - 3;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.6 maxRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.6 maxRows = oracledb.fetchArraySize = table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.7 maxRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 10;
|
||||
var fetchArraySizeVal = tableSize + 30;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.7 maxRows = oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 10;
|
||||
let fetchArraySizeVal = tableSize + 30;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.8 maxRows = oracledb.fetchArraySize/10", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal / 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.8 maxRows = oracledb.fetchArraySize/10", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal / 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.9 maxRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 2;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal * 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 2;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal * 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var tableSize = 200;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var maxRowsVal = fetchArraySizeVal + 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let tableSize = 200;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let maxRowsVal = fetchArraySizeVal + 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.11 maxRows = 0, fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = 0;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.11 maxRows = 0, fetchArraySize = table size ", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = 0;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.12 maxRows = (table size - 1), fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize - 1;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.12 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize - 1;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("155.2.13 fetchArraySize = (table size - 1), maxRows = table size ", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("155.2.13 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
var insertData = function(tableSize, cb) {
|
||||
var insert_data = "BEGIN \n" +
|
||||
let insertData = async function(tableSize) {
|
||||
const insert_data = "BEGIN \n" +
|
||||
" FOR i IN 1.." + tableSize + " LOOP \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" insert into " + tableName + " values (' || i || ',''CLOB' || to_char(i) || ''') \n" +
|
||||
|
@ -399,65 +340,25 @@ describe("155. fetchArraySize8.js", function() {
|
|||
" commit; \n" +
|
||||
"END; ";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
insert_data,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"select id from " + tableName,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows.length, tableSize);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], cb);
|
||||
};
|
||||
|
||||
var verifyResult = function(rows, cb) {
|
||||
async.eachSeries(
|
||||
rows,
|
||||
verifyEachRow,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
}
|
||||
await connection.execute(insert_data);
|
||||
let result = await connection.execute(
|
||||
"select id from " + tableName
|
||||
);
|
||||
assert.strictEqual(result.rows.length, tableSize);
|
||||
};
|
||||
|
||||
var verifyEachRow = function(row, cb) {
|
||||
var id = row[0];
|
||||
should.strictEqual(row[0], id);
|
||||
var lob = row[1];
|
||||
should.exist(lob);
|
||||
lob.setEncoding('utf8');
|
||||
var clobData = '';
|
||||
const verifyResult = async function(rows) {
|
||||
for (let row of rows) {
|
||||
await verifyEachRow(row);
|
||||
}
|
||||
};
|
||||
|
||||
lob.on('data', function(chunk) {
|
||||
clobData += chunk;
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
lob.on('end', function(err) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(clobData, "CLOB" + String(id));
|
||||
});
|
||||
|
||||
lob.on('close', function(err) {
|
||||
should.not.exist(err);
|
||||
cb(err);
|
||||
});
|
||||
const verifyEachRow = async function(row) {
|
||||
const id = row[0];
|
||||
assert.strictEqual(row[0], id);
|
||||
const lob = row[1];
|
||||
const clobData = await lob.getData();
|
||||
assert.strictEqual(clobData, "CLOB" + String(id));
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -33,17 +33,15 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe("156. fetchArraySize9.js", function() {
|
||||
|
||||
let connection = null;
|
||||
var default_fetcArraySize = oracledb.fetchArraySize;
|
||||
var default_maxRows = oracledb.maxRows;
|
||||
var tableName = "nodb_fetchArraySize_156";
|
||||
let default_fetcArraySize = oracledb.fetchArraySize;
|
||||
let default_maxRows = oracledb.maxRows;
|
||||
const tableName = "nodb_fetchArraySize_156";
|
||||
|
||||
const create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -65,400 +63,306 @@ describe("156. fetchArraySize9.js", function() {
|
|||
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.strictEqual(default_fetcArraySize, 100);
|
||||
should.strictEqual(default_maxRows, 0);
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert.strictEqual(default_fetcArraySize, 100);
|
||||
assert.strictEqual(default_maxRows, 0);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe("156.1 Streaming blobs with different oracledb.fetchArraySize", function() {
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.fetchArraySize = default_fetcArraySize;
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var basicFetchWithGlobalOption = function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback() ;
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
insertData(tableSize, callback);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
should.strictEqual(result.rows.length, resultLenExpected);
|
||||
verifyResult(result.rows, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], cb);
|
||||
const basicFetchWithGlobalOption = async function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
await connection.execute(create_table);
|
||||
await insertData(tableSize);
|
||||
oracledb.fetchArraySize = fetchArraySizeVal;
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id"
|
||||
);
|
||||
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
assert.strictEqual(result.rows.length, resultLenExpected);
|
||||
await verifyResult(result.rows);
|
||||
|
||||
await connection.execute(drop_table);
|
||||
};
|
||||
|
||||
it("156.1.1 maxRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize - 50;
|
||||
var maxRowsVal = tableSize + 200;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.1 maxRows > table size > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize - 50;
|
||||
let maxRowsVal = tableSize + 200;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.2 maxRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize + 30;
|
||||
var maxRowsVal = tableSize + 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.2 maxRows > oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize + 30;
|
||||
let maxRowsVal = tableSize + 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.3 table size > maxRows > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 199;
|
||||
var fetchArraySizeVal = tableSize - 130;
|
||||
var maxRowsVal = tableSize - 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.3 table size > maxRows > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 199;
|
||||
let fetchArraySizeVal = tableSize - 130;
|
||||
let maxRowsVal = tableSize - 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
var tableSize = 290;
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var maxRowsVal = tableSize - 150;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
let tableSize = 290;
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let maxRowsVal = tableSize - 150;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.5 maxRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize - 3;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.5 maxRows = oracledb.fetchArraySize < table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize - 3;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.6 maxRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.6 maxRows = oracledb.fetchArraySize = table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.7 maxRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 10;
|
||||
var fetchArraySizeVal = tableSize + 30;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.7 maxRows = oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 10;
|
||||
let fetchArraySizeVal = tableSize + 30;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.8 maxRows = oracledb.fetchArraySize/10", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal / 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.8 maxRows = oracledb.fetchArraySize/10", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal / 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.9 maxRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 2;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal * 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 2;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal * 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var tableSize = 200;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var maxRowsVal = fetchArraySizeVal + 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let tableSize = 200;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let maxRowsVal = fetchArraySizeVal + 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.11 maxRows = 0, fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = 0;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.11 maxRows = 0, fetchArraySize = table size ", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = 0;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.12 maxRows = (table size - 1), fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize - 1;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.12 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize - 1;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.1.13 fetchArraySize = (table size - 1), maxRows = table size ", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.1.13 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithGlobalOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
describe("156.2 Streaming blobs with different execute() option fetchArraySize", function() {
|
||||
|
||||
afterEach(function(done) {
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = default_maxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
var basicFetchWithExecOption = function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, cb) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback() ;
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
insertData(tableSize, callback);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id",
|
||||
[],
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
should.strictEqual(result.rows.length, resultLenExpected);
|
||||
verifyResult(result.rows, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
let basicFetchWithExecOption = async function(tableSize, fetchArraySizeVal, maxRowsVal, affectedID) {
|
||||
await connection.execute(create_table);
|
||||
await insertData(tableSize);
|
||||
|
||||
oracledb.maxRows = maxRowsVal;
|
||||
let result = await connection.execute(
|
||||
"select * from " + tableName + " where id > " + affectedID + " order by id",
|
||||
[],
|
||||
{
|
||||
fetchArraySize: fetchArraySizeVal
|
||||
}
|
||||
], cb);
|
||||
);
|
||||
let resultLenExpected = maxRowsVal > (tableSize - affectedID) ? (tableSize - affectedID) : maxRowsVal;
|
||||
if (maxRowsVal === 0) resultLenExpected = tableSize - affectedID;
|
||||
assert.strictEqual(result.rows.length, resultLenExpected);
|
||||
await verifyResult(result.rows);
|
||||
|
||||
await connection.execute(drop_table);
|
||||
};
|
||||
|
||||
it("156.2.1 maxRows > table size > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize - 50;
|
||||
var maxRowsVal = tableSize + 200;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.1 maxRows > table size > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize - 50;
|
||||
let maxRowsVal = tableSize + 200;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.2 maxRows > oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize + 30;
|
||||
var maxRowsVal = tableSize + 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.2 maxRows > oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize + 30;
|
||||
let maxRowsVal = tableSize + 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.3 table size > maxRows > oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 199;
|
||||
var fetchArraySizeVal = tableSize - 30;
|
||||
var maxRowsVal = tableSize - 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.3 table size > maxRows > oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 199;
|
||||
let fetchArraySizeVal = tableSize - 30;
|
||||
let maxRowsVal = tableSize - 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.4 table size > oracledb.fetchArraySize > maxRow", function(done) {
|
||||
var tableSize = 290;
|
||||
var fetchArraySizeVal = tableSize - 90;
|
||||
var maxRowsVal = tableSize - 150;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.4 table size > oracledb.fetchArraySize > maxRow", async function() {
|
||||
let tableSize = 290;
|
||||
let fetchArraySizeVal = tableSize - 90;
|
||||
let maxRowsVal = tableSize - 150;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.5 maxRows = oracledb.fetchArraySize < table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize - 3;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.5 maxRows = oracledb.fetchArraySize < table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize - 3;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.6 maxRows = oracledb.fetchArraySize = table size", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.6 maxRows = oracledb.fetchArraySize = table size", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.7 maxRows = oracledb.fetchArraySize > table size", function(done) {
|
||||
var tableSize = 10;
|
||||
var fetchArraySizeVal = tableSize + 30;
|
||||
var maxRowsVal = fetchArraySizeVal;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.7 maxRows = oracledb.fetchArraySize > table size", async function() {
|
||||
let tableSize = 10;
|
||||
let fetchArraySizeVal = tableSize + 30;
|
||||
let maxRowsVal = fetchArraySizeVal;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.8 maxRows = oracledb.fetchArraySize/10", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal / 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.8 maxRows = oracledb.fetchArraySize/10", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal / 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.9 maxRows = 10 * oracledb.fetchArraySize", function(done) {
|
||||
var tableSize = 2;
|
||||
var fetchArraySizeVal = 30;
|
||||
var maxRowsVal = fetchArraySizeVal * 10;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.9 maxRows = 10 * oracledb.fetchArraySize", async function() {
|
||||
let tableSize = 2;
|
||||
let fetchArraySizeVal = 30;
|
||||
let maxRowsVal = fetchArraySizeVal * 10;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", function(done) {
|
||||
var tableSize = 200;
|
||||
var fetchArraySizeVal = tableSize / 10;
|
||||
var maxRowsVal = tableSize / 10 + 50;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.10 maxRows > fetchArraySize, fetchArraySize = (table size)/10", async function() {
|
||||
let tableSize = 200;
|
||||
let fetchArraySizeVal = tableSize / 10;
|
||||
let maxRowsVal = tableSize / 10 + 50;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.11 maxRows = 0, fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 20;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = 0;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.11 maxRows = 0, fetchArraySize = table size ", async function() {
|
||||
let tableSize = 20;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = 0;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.12 maxRows = (table size - 1), fetchArraySize = table size ", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize;
|
||||
var maxRowsVal = tableSize - 1;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.12 maxRows = (table size - 1), fetchArraySize = table size ", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize;
|
||||
let maxRowsVal = tableSize - 1;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
|
||||
it("156.2.13 fetchArraySize = (table size - 1), maxRows = table size ", function(done) {
|
||||
var tableSize = 100;
|
||||
var fetchArraySizeVal = tableSize - 1;
|
||||
var maxRowsVal = tableSize;
|
||||
var affectedID = 0;
|
||||
basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID, done);
|
||||
it("156.2.13 fetchArraySize = (table size - 1), maxRows = table size ", async function() {
|
||||
let tableSize = 100;
|
||||
let fetchArraySizeVal = tableSize - 1;
|
||||
let maxRowsVal = tableSize;
|
||||
let affectedID = 0;
|
||||
await basicFetchWithExecOption(tableSize, fetchArraySizeVal, maxRowsVal, affectedID);
|
||||
});
|
||||
});
|
||||
|
||||
var insertData = function(tableSize, cb) {
|
||||
var insert_data = "DECLARE \n" +
|
||||
" tmpchar VARCHAR2(2000); \n" +
|
||||
" tmplob BLOB; \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1.." + tableSize + " LOOP \n" +
|
||||
" select to_char(i) into tmpchar from dual; \n" +
|
||||
" select utl_raw.cast_to_raw(tmpchar) into tmplob from dual; \n" +
|
||||
" insert into " + tableName + " values (i, tmplob); \n" +
|
||||
" END LOOP; \n" +
|
||||
" commit; \n" +
|
||||
"END; ";
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
insert_data,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"select id from " + tableName,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows.length, tableSize);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], cb);
|
||||
};
|
||||
|
||||
var verifyResult = function(rows, cb) {
|
||||
async.eachSeries(
|
||||
rows,
|
||||
verifyEachRow,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
}
|
||||
const insertData = async function(tableSize) {
|
||||
const insert_data = "DECLARE \n" +
|
||||
" tmpchar VARCHAR2(2000); \n" +
|
||||
" tmplob BLOB; \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1.." + tableSize + " LOOP \n" +
|
||||
" select to_char(i) into tmpchar from dual; \n" +
|
||||
" select utl_raw.cast_to_raw(tmpchar) into tmplob from dual; \n" +
|
||||
" insert into " + tableName + " values (i, tmplob); \n" +
|
||||
" END LOOP; \n" +
|
||||
" commit; \n" +
|
||||
"END; ";
|
||||
await connection.execute(insert_data);
|
||||
const result = await connection.execute(
|
||||
"select id from " + tableName
|
||||
);
|
||||
assert.strictEqual(result.rows.length, tableSize);
|
||||
};
|
||||
|
||||
var verifyEachRow = function(row, cb) {
|
||||
var id = row[0];
|
||||
var lob = row[1];
|
||||
should.exist(lob);
|
||||
var blobData = 0;
|
||||
var totalLength = 0;
|
||||
blobData = Buffer.alloc(0);
|
||||
const verifyResult = async function(rows) {
|
||||
for (let row of rows) {
|
||||
await verifyEachRow(row);
|
||||
}
|
||||
};
|
||||
|
||||
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(err) {
|
||||
should.not.exist(err);
|
||||
var expected = Buffer.from((String(id)), "utf-8");
|
||||
should.strictEqual(assist.compare2Buffers(blobData, expected), true);
|
||||
cb(err);
|
||||
});
|
||||
const verifyEachRow = async function(row) {
|
||||
const id = row[0];
|
||||
const lob = row[1];
|
||||
const blobData = await lob.getData();
|
||||
const expected = Buffer.from((String(id)), "utf-8");
|
||||
assert.deepStrictEqual(blobData, expected);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
272
test/fetchAs.js
272
test/fetchAs.js
|
@ -32,8 +32,7 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require ('oracledb');
|
||||
const should = require ('should');
|
||||
const async = require ('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require ('./dbconfig.js');
|
||||
const assist = require ('./dataTypeAssist.js');
|
||||
|
||||
|
@ -41,61 +40,49 @@ const assist = require ('./dataTypeAssist.js');
|
|||
describe('56. fetchAs.js', function() {
|
||||
|
||||
let connection = null;
|
||||
beforeEach('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
beforeEach('get one connection', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
});
|
||||
|
||||
afterEach('release connection, reset fetchAsString property', function(done) {
|
||||
afterEach('release connection, reset fetchAsString property', async function() {
|
||||
oracledb.fetchAsString = [];
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
it('56.1 property value check', function() {
|
||||
|
||||
(oracledb.fetchAsString).should.eql([]);
|
||||
assert.deepStrictEqual(oracledb.fetchAsString, []);
|
||||
|
||||
oracledb.fetchAsString = [oracledb.DATE];
|
||||
should.deepEqual(oracledb.fetchAsString, [ oracledb.DATE ]);
|
||||
assert.deepStrictEqual(oracledb.fetchAsString, [ oracledb.DATE ]);
|
||||
|
||||
oracledb.fetchAsString = [ oracledb.NUMBER ];
|
||||
should.deepEqual(oracledb.fetchAsString, [ oracledb.NUMBER ]);
|
||||
assert.deepStrictEqual(oracledb.fetchAsString, [ oracledb.NUMBER ]);
|
||||
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
should.deepEqual(oracledb.fetchAsString, [ oracledb.DATE, oracledb.NUMBER ]);
|
||||
assert.deepStrictEqual(oracledb.fetchAsString, [ oracledb.DATE, oracledb.NUMBER ]);
|
||||
|
||||
oracledb.fetchAsString = [ oracledb.DB_TYPE_JSON ];
|
||||
should.deepEqual(oracledb.fetchAsString, [ oracledb.DB_TYPE_JSON ]);
|
||||
assert.deepStrictEqual(oracledb.fetchAsString, [ oracledb.DB_TYPE_JSON ]);
|
||||
|
||||
oracledb.fetchAsString = [ oracledb.DB_TYPE_JSON, oracledb.DATE, oracledb.NUMBER ];
|
||||
should.deepEqual(oracledb.fetchAsString, [ oracledb.DB_TYPE_JSON, oracledb.DATE, oracledb.NUMBER ]);
|
||||
assert.deepStrictEqual(oracledb.fetchAsString, [ oracledb.DB_TYPE_JSON, oracledb.DATE, oracledb.NUMBER ]);
|
||||
});
|
||||
|
||||
it('56.2 Fetch DATE column values as STRING - by-Column name', function(done) {
|
||||
connection.execute(
|
||||
it('56.2 Fetch DATE column values as STRING - by-Column name', async function() {
|
||||
let result = await connection.execute(
|
||||
"SELECT TO_DATE('2005-01-06', 'YYYY-DD-MM') AS TS_DATE FROM DUAL",
|
||||
[],
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
fetchInfo : { "TS_DATE": { type : oracledb.STRING } }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.rows[0]);
|
||||
result.rows[0].TS_DATE.should.be.a.String();
|
||||
done();
|
||||
}
|
||||
);
|
||||
assert.strictEqual(typeof result.rows[0].TS_DATE, "string");
|
||||
});
|
||||
|
||||
it('56.3 Fetch DATE, NUMBER column values STRING - by Column-name', function(done) {
|
||||
connection.execute(
|
||||
it('56.3 Fetch DATE, NUMBER column values STRING - by Column-name', async function() {
|
||||
let result = await connection.execute(
|
||||
"SELECT 1234567 AS TS_NUM, TO_TIMESTAMP('1999-12-01 11:10:01.00123', 'YYYY-MM-DD HH:MI:SS.FF') AS TS_DATE FROM DUAL",
|
||||
[],
|
||||
{
|
||||
|
@ -105,22 +92,17 @@ describe('56. fetchAs.js', function() {
|
|||
"TS_DATE" : { type : oracledb.STRING },
|
||||
"TS_NUM" : { type : oracledb.STRING }
|
||||
}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.rows[0]);
|
||||
result.rows[0].TS_DATE.should.be.a.String();
|
||||
result.rows[0].TS_NUM.should.be.a.String();
|
||||
Number(result.rows[0].TS_NUM).should.equal(1234567);
|
||||
done();
|
||||
}
|
||||
);
|
||||
assert.strictEqual(typeof result.rows[0].TS_DATE, "string");
|
||||
assert.strictEqual(typeof result.rows[0].TS_NUM, "string");
|
||||
assert.strictEqual(Number(result.rows[0].TS_NUM), 1234567);
|
||||
});
|
||||
|
||||
it('56.4 Fetch DATE, NUMBER as STRING by-time configuration and by-name', function(done) {
|
||||
it('56.4 Fetch DATE, NUMBER as STRING by-time configuration and by-name', async function() {
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"SELECT 1234567 AS TS_NUM, TO_TIMESTAMP('1999-12-01 11:10:01.00123', 'YYYY-MM-DD HH:MI:SS.FF') AS TS_DATE FROM DUAL",
|
||||
[],
|
||||
{
|
||||
|
@ -130,22 +112,17 @@ describe('56. fetchAs.js', function() {
|
|||
"TS_DATE" : { type : oracledb.STRING },
|
||||
"TS_NUM" : { type : oracledb.STRING }
|
||||
}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.rows[0]);
|
||||
result.rows[0].TS_DATE.should.be.a.String();
|
||||
result.rows[0].TS_NUM.should.be.a.String();
|
||||
Number(result.rows[0].TS_NUM).should.equal(1234567);
|
||||
done();
|
||||
}
|
||||
);
|
||||
assert.strictEqual(typeof result.rows[0].TS_DATE, "string");
|
||||
assert.strictEqual(typeof result.rows[0].TS_NUM, "string");
|
||||
assert.strictEqual(Number(result.rows[0].TS_NUM), 1234567);
|
||||
});
|
||||
|
||||
it('56.5 Fetch DATE, NUMBER column as STRING by-type and override at execute time', function(done) {
|
||||
it('56.5 Fetch DATE, NUMBER column as STRING by-type and override at execute time', async function() {
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"SELECT 1234567 AS TS_NUM, TO_TIMESTAMP('1999-12-01 11:10:01.00123', 'YYYY-MM-DD HH:MI:SS.FF') AS TS_DATE FROM DUAL",
|
||||
[],
|
||||
{
|
||||
|
@ -155,20 +132,15 @@ describe('56. fetchAs.js', function() {
|
|||
"TS_DATE" : { type : oracledb.DEFAULT },
|
||||
"TS_NUM" : { type : oracledb.STRING }
|
||||
}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.rows[0]);
|
||||
result.rows[0].TS_DATE.should.be.an.Object;
|
||||
result.rows[0].TS_NUM.should.be.a.String();
|
||||
Number(result.rows[0].TS_NUM).should.equal(1234567);
|
||||
done();
|
||||
}
|
||||
);
|
||||
assert.strictEqual(typeof result.rows[0].TS_DATE, "object");
|
||||
assert.strictEqual(typeof result.rows[0].TS_NUM, "string");
|
||||
assert.strictEqual(Number(result.rows[0].TS_NUM), 1234567);
|
||||
});
|
||||
|
||||
it('56.6 Fetch ROWID column values STRING - non-ResultSet', function(done) {
|
||||
connection.execute(
|
||||
it('56.6 Fetch ROWID column values STRING - non-ResultSet', async function() {
|
||||
let result = await connection.execute(
|
||||
"SELECT ROWID from DUAL",
|
||||
[],
|
||||
{
|
||||
|
@ -177,18 +149,13 @@ describe('56. fetchAs.js', function() {
|
|||
{
|
||||
"ROWID" : { type : oracledb.STRING }
|
||||
}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.rows[0].TS_DATA);
|
||||
result.rows[0].ROWID.should.be.a.String();
|
||||
done();
|
||||
}
|
||||
);
|
||||
assert.strictEqual(typeof result.rows[0].ROWID, "string");
|
||||
});
|
||||
|
||||
it('56.7 Fetch ROWID column values STRING - ResultSet', function(done) {
|
||||
connection.execute(
|
||||
it('56.7 Fetch ROWID column values STRING - ResultSet', async function() {
|
||||
let result = await connection.execute(
|
||||
"SELECT ROWID from DUAL",
|
||||
[],
|
||||
{
|
||||
|
@ -198,21 +165,11 @@ describe('56. fetchAs.js', function() {
|
|||
{
|
||||
"ROWID" : { type : oracledb.STRING }
|
||||
}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
result.resultSet.getRow(function(err, row) {
|
||||
should.not.exist(err);
|
||||
// console.log(row);
|
||||
row.ROWID.should.be.a.String();
|
||||
result.resultSet.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
let row = await result.resultSet.getRow();
|
||||
assert.strictEqual(typeof row.ROWID, "string");
|
||||
await result.resultSet.close();
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -221,7 +178,7 @@ describe('56. fetchAs.js', function() {
|
|||
* Numbers out of above range will be rounded.
|
||||
* The last element is out of Oracle database standard Number range. It will be rounded by database.
|
||||
*/
|
||||
var numStrs =
|
||||
let numStrs =
|
||||
[
|
||||
'17249138680355831',
|
||||
'-17249138680355831',
|
||||
|
@ -230,7 +187,7 @@ describe('56. fetchAs.js', function() {
|
|||
'0.1724913868035583123456789123456789123456'
|
||||
];
|
||||
|
||||
var numResults =
|
||||
let numResults =
|
||||
[
|
||||
'17249138680355831',
|
||||
'-17249138680355831',
|
||||
|
@ -239,9 +196,9 @@ describe('56. fetchAs.js', function() {
|
|||
'.172491386803558312345678912345678912346'
|
||||
];
|
||||
|
||||
it('56.8 large numbers with fetchInfo', function(done) {
|
||||
async.eachSeries(numStrs, function(element, callback) {
|
||||
connection.execute(
|
||||
it('56.8 large numbers with fetchInfo', async function() {
|
||||
for (let element of numStrs) {
|
||||
let result = await connection.execute(
|
||||
"SELECT TO_NUMBER( " + element + " ) AS TS_NUM FROM DUAL",
|
||||
[],
|
||||
{
|
||||
|
@ -250,62 +207,49 @@ describe('56. fetchAs.js', function() {
|
|||
{
|
||||
"TS_NUM" : { type : oracledb.STRING }
|
||||
}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0].TS_NUM.should.be.a.String();
|
||||
(result.rows[0].TS_NUM).should.eql(numResults[numStrs.indexOf(element)]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual(typeof result.rows[0].TS_NUM, "string");
|
||||
assert.strictEqual(result.rows[0].TS_NUM, numResults[numStrs.indexOf(element)]);
|
||||
}
|
||||
});
|
||||
|
||||
it('56.9 large numbers with setting fetchAsString property', function(done) {
|
||||
it('56.9 large numbers with setting fetchAsString property', async function() {
|
||||
oracledb.fetchAsString = [ oracledb.NUMBER ];
|
||||
|
||||
async.eachSeries(numStrs, function(element, callback) {
|
||||
connection.execute(
|
||||
for (let element of numStrs) {
|
||||
let result = await connection.execute(
|
||||
"SELECT TO_NUMBER( " + element + " ) AS TS_NUM FROM DUAL",
|
||||
[],
|
||||
{ outFormat : oracledb.OUT_FORMAT_OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.rows[0].TS_NUM);
|
||||
result.rows[0].TS_NUM.should.be.a.String();
|
||||
(result.rows[0].TS_NUM).should.eql(numResults[numStrs.indexOf(element)]);
|
||||
callback();
|
||||
}
|
||||
{ outFormat : oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
assert.strictEqual(typeof result.rows[0].TS_NUM, "string");
|
||||
assert.strictEqual(result.rows[0].TS_NUM, numResults[numStrs.indexOf(element)]);
|
||||
}
|
||||
});
|
||||
|
||||
// FetchInfo format should <columName> : {type : oracledb.<type> }
|
||||
it('56.10 invalid syntax for type should result in error', function(done) {
|
||||
connection.execute (
|
||||
"SELECT SYSDATE AS THE_DATE FROM DUAL",
|
||||
{ },
|
||||
{ fetchInfo : { "THE_DATE" : oracledb.STRING }},
|
||||
function(err) {
|
||||
should.exist (err) ;
|
||||
should.strictEqual(err.message, 'NJS-015: type was not specified for conversion');
|
||||
done ();
|
||||
});
|
||||
it('56.10 invalid syntax for type should result in error', async function() {
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await connection.execute(
|
||||
"SELECT SYSDATE AS THE_DATE FROM DUAL",
|
||||
{ },
|
||||
{ fetchInfo : { "THE_DATE" : oracledb.STRING }}
|
||||
);
|
||||
},
|
||||
// NJS-015: type was not specified for conversion
|
||||
/ NJS-015:/
|
||||
);
|
||||
});
|
||||
|
||||
it('56.11 assigns an empty array to fetchAsString', function() {
|
||||
oracledb.fetchAsString = [];
|
||||
(oracledb.fetchAsString).should.eql([]);
|
||||
assert.deepStrictEqual(oracledb.fetchAsString, []);
|
||||
});
|
||||
|
||||
it('56.12 Negative - empty string', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = '';
|
||||
},
|
||||
|
@ -314,7 +258,7 @@ describe('56. fetchAs.js', function() {
|
|||
});
|
||||
|
||||
it('56.13 Negative - null', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = null;
|
||||
},
|
||||
|
@ -323,7 +267,7 @@ describe('56. fetchAs.js', function() {
|
|||
});
|
||||
|
||||
it('56.14 Negative - undefined', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = undefined;
|
||||
},
|
||||
|
@ -332,7 +276,7 @@ describe('56. fetchAs.js', function() {
|
|||
});
|
||||
|
||||
it('56.15 Negative - NaN', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = NaN;
|
||||
},
|
||||
|
@ -341,7 +285,7 @@ describe('56. fetchAs.js', function() {
|
|||
});
|
||||
|
||||
it('56.16 Negative - invalid type of value, number', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = 10;
|
||||
},
|
||||
|
@ -350,7 +294,7 @@ describe('56. fetchAs.js', function() {
|
|||
});
|
||||
|
||||
it('56.17 Negative - invalid type of value, string', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = 'abc';
|
||||
},
|
||||
|
@ -358,64 +302,54 @@ describe('56. fetchAs.js', function() {
|
|||
);
|
||||
});
|
||||
|
||||
it('56.18 Negative - passing oracledb.DATE type to fetchInfo', function(done) {
|
||||
connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: { ts_date: { type: oracledb.DATE } }
|
||||
},
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-021: invalid type for conversion specified'
|
||||
it('56.18 Negative - passing oracledb.DATE type to fetchInfo', async function() {
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: { ts_date: { type: oracledb.DATE } }
|
||||
}
|
||||
);
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
},
|
||||
// NJS-021: invalid type for conversion specified
|
||||
/NJS-021:/
|
||||
);
|
||||
});
|
||||
|
||||
it('56.19 Negative - passing empty JSON to fetchInfo', function(done) {
|
||||
connection.execute(
|
||||
it('56.19 Negative - passing empty JSON to fetchInfo', async function() {
|
||||
let result = await connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: {}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
(result.rows[0][0]).should.be.a.Date();
|
||||
done();
|
||||
}
|
||||
);
|
||||
assert(result);
|
||||
assert.strictEqual(result.rows[0][0] instanceof Date, true);
|
||||
});
|
||||
|
||||
it('56.20 Negative - passing oracledb.NUMBER type to fetchInfo', function(done) {
|
||||
connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: { ts_date: { type: oracledb.NUMBER } }
|
||||
},
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-021: invalid type for conversion specified'
|
||||
it('56.20 Negative - passing oracledb.NUMBER type to fetchInfo', async function() {
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: { ts_date: { type: oracledb.NUMBER } }
|
||||
}
|
||||
);
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
},
|
||||
// NJS-021: invalid type for conversion specified
|
||||
/NJS-021:/
|
||||
);
|
||||
});
|
||||
|
||||
it('56.21 Negative - invalid type of value, Date', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
var dt = new Date ();
|
||||
let dt = new Date ();
|
||||
oracledb.fetchAsString = dt;
|
||||
},
|
||||
/NJS-004:/
|
||||
|
@ -423,9 +357,9 @@ describe('56. fetchAs.js', function() {
|
|||
});
|
||||
|
||||
it('56.22 Negative - invalid type of value, Buffer', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
var buf = assist.createBuffer (10) ; // arbitary sized buffer
|
||||
let buf = assist.createBuffer (10) ; // arbitary sized buffer
|
||||
oracledb.fetchAsString = buf;
|
||||
},
|
||||
/NJS-004:/
|
||||
|
|
|
@ -34,126 +34,72 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const async = require('async');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('139. fetchAsStringWithRefCursor.js', function() {
|
||||
let connection = null;
|
||||
var tableName = "nodb_tab_fetchAsRefCursor";
|
||||
const tableName = "nodb_tab_fetchAsRefCursor";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function createTable(cb) {
|
||||
let sql = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE' ); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE ( ' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" id NUMBER(10), \n" +
|
||||
" content VARCHAR2(20), \n" +
|
||||
" hiredate DATE \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
// PL/SQL procedure to create the table
|
||||
let sql = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE' ); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE ( ' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" id NUMBER(10), \n" +
|
||||
" content VARCHAR2(20), \n" +
|
||||
" hiredate DATE \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
await connection.execute(sql);
|
||||
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function insertData(cb) {
|
||||
let sql = "DECLARE \n" +
|
||||
" x NUMBER := 0; \n" +
|
||||
" n VARCHAR2(20); \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1..300 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO " + tableName + " VALUES(x, n, TO_DATE('2012-02-18', 'YYYY-MM-DD')); \n" +
|
||||
" END LOOP; \n" +
|
||||
"END; ";
|
||||
// PL/SQL procedure to insert data into the table
|
||||
sql = "DECLARE \n" +
|
||||
" x NUMBER := 0; \n" +
|
||||
" n VARCHAR2(20); \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1..300 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO " + tableName + " VALUES(x, n, TO_DATE('2012-02-18', 'YYYY-MM-DD')); \n" +
|
||||
" END LOOP; \n" +
|
||||
"END; ";
|
||||
await connection.execute(sql);
|
||||
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createProc(cb) {
|
||||
let proc = "CREATE OR REPLACE PROCEDURE nodb_proc_fetchcursor (p_in IN NUMBER, p_out OUT SYS_REFCURSOR) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" OPEN p_out FOR \n" +
|
||||
" SELECT * FROM " + tableName + " WHERE id > p_in; \n" +
|
||||
"END; ";
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
// PL/SQL procedure for the ref cursor
|
||||
let proc = "CREATE OR REPLACE PROCEDURE nodb_proc_fetchcursor (p_in IN NUMBER, p_out OUT SYS_REFCURSOR) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" OPEN p_out FOR \n" +
|
||||
" SELECT * FROM " + tableName + " WHERE id > p_in; \n" +
|
||||
"END; ";
|
||||
await connection.execute(proc);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
let sql = "DROP PROCEDURE nodb_proc_fetchcursor";
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
let sql = "DROP TABLE " + tableName + " PURGE";
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function restoreSettings(cb) {
|
||||
oracledb.fetchAsString = [];
|
||||
cb();
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
let sql = "DROP PROCEDURE nodb_proc_fetchcursor";
|
||||
await connection.execute(sql);
|
||||
|
||||
sql = "DROP TABLE " + tableName + " PURGE";
|
||||
await connection.execute(sql);
|
||||
|
||||
await connection.close();
|
||||
oracledb.fetchAsString = [];
|
||||
});
|
||||
|
||||
it('139.1 columns fetched from REF CURSORS can be mapped by fetchInfo settings', function(done) {
|
||||
connection.execute(
|
||||
it('139.1 columns fetched from REF CURSORS can be mapped by fetchInfo settings', async function() {
|
||||
let result = await connection.execute(
|
||||
"begin nodb_proc_fetchcursor(:in, :out); end;",
|
||||
{
|
||||
in: 290,
|
||||
|
@ -166,63 +112,48 @@ describe('139. fetchAsStringWithRefCursor.js', function() {
|
|||
"ID": { type: oracledb.STRING },
|
||||
"HIREDATE": { type: oracledb.STRING }
|
||||
}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fetchRowFromRC(result.outBinds.out, done);
|
||||
}
|
||||
);
|
||||
|
||||
var fetchRowFromRC = function(rc, callback) {
|
||||
rc.getRow(function(err, row) {
|
||||
should.not.exist(err);
|
||||
if (row) {
|
||||
(row.ID).should.be.a.String();
|
||||
(row.HIREDATE).should.be.a.String();
|
||||
return fetchRowFromRC(rc, callback);
|
||||
} else {
|
||||
rc.close(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
});
|
||||
const fetchRowFromRC = async function(rc) {
|
||||
const row = await rc.getRow();
|
||||
if (row) {
|
||||
assert.strictEqual(typeof row.ID, "string");
|
||||
assert.strictEqual(typeof row.HIREDATE, "string");
|
||||
return await fetchRowFromRC(rc);
|
||||
} else {
|
||||
await rc.close();
|
||||
}
|
||||
}; // fetchRowFromRC()
|
||||
|
||||
await fetchRowFromRC(result.outBinds.out);
|
||||
|
||||
}); // 139.1
|
||||
|
||||
it('139.2 fetchAsString takes effect as well', function(done) {
|
||||
it('139.2 fetchAsString takes effect as well', async function() {
|
||||
|
||||
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||
connection.execute(
|
||||
let result = await connection.execute(
|
||||
"begin nodb_proc_fetchcursor(:in, :out); end;",
|
||||
{
|
||||
in: 295,
|
||||
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fetchRowFromRC(result.outBinds.out, done);
|
||||
}
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
var fetchRowFromRC = function(rc, callback) {
|
||||
rc.getRow(function(err, row) {
|
||||
should.not.exist(err);
|
||||
if (row) {
|
||||
(row.ID).should.not.be.a.String();
|
||||
(row.HIREDATE).should.be.a.String();
|
||||
return fetchRowFromRC(rc, callback);
|
||||
} else {
|
||||
rc.close(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
});
|
||||
const fetchRowFromRC = async function(rc) {
|
||||
const row = await rc.getRow();
|
||||
if (row) {
|
||||
assert.notStrictEqual(typeof row.ID, "string");
|
||||
assert.strictEqual(typeof row.HIREDATE, "string");
|
||||
return await fetchRowFromRC(rc);
|
||||
} else {
|
||||
await rc.close();
|
||||
}
|
||||
}; // fetchRowFromRC()
|
||||
|
||||
await fetchRowFromRC(result.outBinds.out);
|
||||
}); // 139.2
|
||||
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,6 @@ const oracledb = require('oracledb');
|
|||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('88. fetchBlobAsBuffer2.js', function() {
|
||||
|
||||
|
@ -104,8 +103,7 @@ describe('88. fetchBlobAsBuffer2.js', function() {
|
|||
// compare fetch result
|
||||
const compareClientFetchResult = function(resultVal, specialStr, content, contentLength) {
|
||||
assert.strictEqual(resultVal.length, contentLength);
|
||||
const compareBuffer = assist.compare2Buffers(resultVal, content);
|
||||
assert.strictEqual(compareBuffer, true);
|
||||
assert.deepStrictEqual(resultVal, content);
|
||||
};
|
||||
|
||||
describe('88.1 fetch BLOB columns by setting fetchInfo option', function() {
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const async = require('async');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
@ -42,9 +41,9 @@ const assist = require('./dataTypeAssist.js');
|
|||
describe('89. fetchBlobAsBuffer3.js', function() {
|
||||
|
||||
let connection = null;
|
||||
var insertID = 1; // assume id for insert into db starts from 1
|
||||
let insertID = 1; // assume id for insert into db starts from 1
|
||||
|
||||
var proc_create_table2 = "BEGIN \n" +
|
||||
const proc_create_table2 = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
|
@ -62,181 +61,96 @@ describe('89. fetchBlobAsBuffer3.js', function() {
|
|||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var drop_table2 = "DROP TABLE nodb_blob2 PURGE";
|
||||
var defaultStmtCache = oracledb.stmtCacheSize;
|
||||
const drop_table2 = "DROP TABLE nodb_blob2 PURGE";
|
||||
const defaultStmtCache = oracledb.stmtCacheSize;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
before('get one connection', async function() {
|
||||
oracledb.stmtCacheSize = 0;
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
}); // before
|
||||
|
||||
after('release connection', function(done) {
|
||||
after('release connection', async function() {
|
||||
oracledb.stmtCacheSize = defaultStmtCache;
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
var insertIntoBlobTable2 = function(id, content1, content2, callback) {
|
||||
connection.execute(
|
||||
const insertIntoBlobTable2 = async function(id, content1, content2) {
|
||||
let result = await connection.execute(
|
||||
"INSERT INTO nodb_blob2 VALUES (:ID, :B1, :B2)",
|
||||
[ id, content1, content2 ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
[ id, content1, content2 ]
|
||||
);
|
||||
};
|
||||
|
||||
// compare fetch result
|
||||
var compareClientFetchResult = function(err, resultVal, specialStr, content, contentLength) {
|
||||
should.not.exist(err);
|
||||
compareBuffers(resultVal, specialStr, content, contentLength);
|
||||
};
|
||||
|
||||
// compare two buffers
|
||||
var compareBuffers = function(resultVal, specialStr, content, contentLength) {
|
||||
should.equal(resultVal.length, contentLength);
|
||||
var compareBuffer = assist.compare2Buffers(resultVal, content);
|
||||
should.strictEqual(compareBuffer, true);
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
};
|
||||
|
||||
describe('89.1 fetch multiple BLOBs', function() {
|
||||
|
||||
before('create Table and populate', function(done) {
|
||||
connection.execute(
|
||||
proc_create_table2,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before('create Table and populate', async function() {
|
||||
await connection.execute(proc_create_table2);
|
||||
}); // before
|
||||
|
||||
after('drop table', function(done) {
|
||||
connection.execute(
|
||||
drop_table2,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after('drop table', async function() {
|
||||
await connection.execute(drop_table2);
|
||||
}); // after
|
||||
|
||||
beforeEach('set oracledb.fetchAsBuffer', function(done) {
|
||||
beforeEach('set oracledb.fetchAsBuffer', function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
|
||||
done();
|
||||
}); // beforeEach
|
||||
|
||||
afterEach('clear the By type specification', function(done) {
|
||||
afterEach('clear the By type specification', function() {
|
||||
oracledb.fetchAsBuffer = [];
|
||||
done();
|
||||
}); // afterEach
|
||||
|
||||
it('89.1.1 fetch multiple BLOB columns as Buffer', function(done) {
|
||||
var id = insertID++;
|
||||
var specialStr_1 = '89.1.1_1';
|
||||
var contentLength_1 = 26;
|
||||
var strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
var specialStr_2 = '89.1.1_2';
|
||||
var contentLength_2 = 100;
|
||||
var strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable2(id, content_1, content_2, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"SELECT ID, B1, B2 from nodb_blob2",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1);
|
||||
resultVal = result.rows[0][2];
|
||||
compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
it('89.1.1 fetch multiple BLOB columns as Buffer', async function() {
|
||||
const id = insertID++;
|
||||
const specialStr_1 = '89.1.1_1';
|
||||
const contentLength_1 = 26;
|
||||
const strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
const content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
const specialStr_2 = '89.1.1_2';
|
||||
const contentLength_2 = 100;
|
||||
const strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
const content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
|
||||
await insertIntoBlobTable2(id, content_1, content_2);
|
||||
const result = await connection.execute(
|
||||
"SELECT ID, B1, B2 from nodb_blob2"
|
||||
);
|
||||
assert.deepStrictEqual(result.rows[0][1], content_1);
|
||||
assert.deepStrictEqual(result.rows[0][2], content_2);
|
||||
}); // 89.1.1
|
||||
|
||||
it('89.1.2 fetch two BLOB columns, one as string, another streamed', function(done) {
|
||||
var id = insertID++;
|
||||
var specialStr_1 = '89.1.2_1';
|
||||
var contentLength_1 = 30;
|
||||
var strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
var specialStr_2 = '89.1.2_2';
|
||||
var contentLength_2 = 50;
|
||||
var strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
var content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
it('89.1.2 fetch two BLOB columns, one as string, another streamed', async function() {
|
||||
const id = insertID++;
|
||||
const specialStr_1 = '89.1.2_1';
|
||||
const contentLength_1 = 30;
|
||||
const strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
const content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
const specialStr_2 = '89.1.2_2';
|
||||
const contentLength_2 = 50;
|
||||
const strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
const content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoBlobTable2(id, content_1, content_2, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"SELECT ID, B1 from nodb_blob2 where ID = :id",
|
||||
{ id : id },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
oracledb.fetchAsBuffer = [];
|
||||
await insertIntoBlobTable2(id, content_1, content_2);
|
||||
|
||||
connection.execute(
|
||||
"SELECT B2 from nodb_blob2 where ID = :id",
|
||||
{ id : id },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rows.length).should.not.eql(0);
|
||||
var lob = result.rows[0][0];
|
||||
should.exist(lob);
|
||||
let result = await connection.execute(
|
||||
"SELECT ID, B1 from nodb_blob2 where ID = :id",
|
||||
{ id : id }
|
||||
);
|
||||
assert.deepStrictEqual(result.rows[0][1], content_1);
|
||||
|
||||
// set the encoding so we get a 'string' not a 'buffer'
|
||||
lob.setEncoding('utf8');
|
||||
var clobData = '';
|
||||
oracledb.fetchAsBuffer = [];
|
||||
|
||||
lob.on('data', function(chunk) {
|
||||
clobData += chunk;
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.not.exist(err, "lob.on 'error' event.");
|
||||
});
|
||||
|
||||
lob.on('end', function() {
|
||||
should.not.exist(err);
|
||||
var specialStrLen_2 = specialStr_2.length;
|
||||
var resultLen_2 = clobData.length;
|
||||
should.equal(clobData.length, contentLength_2);
|
||||
should.strictEqual(clobData.substring(0, specialStrLen_2), specialStr_2);
|
||||
should.strictEqual(clobData.substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
|
||||
|
||||
cb();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
result = await connection.execute(
|
||||
"SELECT B2 from nodb_blob2 where ID = :id",
|
||||
{ id : id }
|
||||
);
|
||||
assert.notStrictEqual(result.rows.length, 0);
|
||||
const clobData = (await result.rows[0][0].getData()).toString();
|
||||
const specialStrLen_2 = specialStr_2.length;
|
||||
const resultLen_2 = clobData.length;
|
||||
assert.strictEqual(clobData.length, contentLength_2);
|
||||
assert.strictEqual(clobData.substring(0, specialStrLen_2), specialStr_2);
|
||||
assert.strictEqual(clobData.substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
|
||||
|
||||
}); // 89.1.2
|
||||
|
||||
|
@ -244,165 +158,150 @@ describe('89. fetchBlobAsBuffer3.js', function() {
|
|||
|
||||
describe('89.2 types support for fetchAsBuffer property', function() {
|
||||
|
||||
afterEach ('clear the by-type specification', function(done) {
|
||||
afterEach('clear the by-type specification', function() {
|
||||
oracledb.fetchAsBuffer = [];
|
||||
done ();
|
||||
});
|
||||
|
||||
it('89.2.1 String not supported in fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.1 String not supported in fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.STRING ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.1
|
||||
|
||||
|
||||
it('89.2.2 CLOB not supported in fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.2 CLOB not supported in fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.CLOB ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.2
|
||||
|
||||
|
||||
it('89.2.3 Number not supported in fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.3 Number not supported in fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.NUMBER ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.3
|
||||
|
||||
|
||||
it('89.2.4 Date not supported in fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.4 Date not supported in fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.DATE ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.4
|
||||
|
||||
|
||||
it('89.2.5 Cursor not supported in fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.5 Cursor not supported in fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.CURSOR ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.5
|
||||
|
||||
|
||||
it('89.2.6 Buffer not supported in fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.6 Buffer not supported in fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.BUFFER ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.6
|
||||
|
||||
|
||||
it('89.2.7 BLOB supported in fetchAsBuffer', function(done) {
|
||||
should.doesNotThrow(
|
||||
it('89.2.7 BLOB supported in fetchAsBuffer', function() {
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
|
||||
}
|
||||
);
|
||||
should.strictEqual(oracledb.fetchAsBuffer.length, 1);
|
||||
should.strictEqual(oracledb.fetchAsBuffer[0], oracledb.BLOB);
|
||||
done();
|
||||
assert.strictEqual(oracledb.fetchAsBuffer.length, 1);
|
||||
assert.strictEqual(oracledb.fetchAsBuffer[0], oracledb.BLOB);
|
||||
}); // 89.2.7
|
||||
|
||||
|
||||
it('89.2.8 negative null value for fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.8 negative null value for fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = null;
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.8
|
||||
|
||||
|
||||
it('89.2.9 negative undefined value for fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.9 negative undefined value for fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = undefined;
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.9
|
||||
|
||||
|
||||
it('89.2.10 negative numeric value for fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.10 negative numeric value for fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = 89210;
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.10
|
||||
|
||||
|
||||
it('89.2.11 negative emtpy string value for fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.11 negative emtpy string value for fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = ' ';
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.11
|
||||
|
||||
|
||||
it('89.2.12 negative arbitary string value for fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.12 negative arbitary string value for fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsBuffer = "89.2.12";
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.12
|
||||
|
||||
|
||||
it('89.2.13 negative date value for fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.13 negative date value for fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
var dt = new Date ();
|
||||
let dt = new Date ();
|
||||
oracledb.fetchAsBuffer = dt;
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.13
|
||||
|
||||
|
||||
it('89.2.14 negative arbitary buffer value for fetchAsBuffer', function(done) {
|
||||
should.throws(
|
||||
it('89.2.14 negative arbitary buffer value for fetchAsBuffer', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
var buf = assist.createBuffer (10) ;
|
||||
let buf = assist.createBuffer(10) ;
|
||||
oracledb.fetchAsBuffer = buf;
|
||||
},
|
||||
/NJS-004:/
|
||||
);
|
||||
done();
|
||||
}); // 89.2.14
|
||||
|
||||
}); // 89.2
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -109,7 +109,7 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
const compareStrings = function(resultVal, specialStr, content, contentLength) {
|
||||
let specialStrLen = specialStr.length;
|
||||
let resultLen = resultVal.length;
|
||||
assert.equal(resultLen, contentLength);
|
||||
assert.strictEqual(resultLen, contentLength);
|
||||
assert.strictEqual(resultVal.substring(0, specialStrLen), specialStr);
|
||||
assert.strictEqual(resultVal.substring(resultLen - specialStrLen, resultLen), specialStr);
|
||||
};
|
||||
|
@ -137,7 +137,7 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
);
|
||||
let resultVal = result.rows[0][1];
|
||||
if (specialStr === null) {
|
||||
assert.equal(resultVal, null);
|
||||
assert.strictEqual(resultVal, null);
|
||||
} else {
|
||||
compareStrings(resultVal, specialStr, insertContent, insertContentLength);
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
);
|
||||
let resultVal = result.rows[0].C;
|
||||
if (specialStr === null) {
|
||||
assert.equal(resultVal, null);
|
||||
assert.strictEqual(resultVal, null);
|
||||
} else {
|
||||
compareStrings(resultVal, specialStr, insertContent, insertContentLength);
|
||||
}
|
||||
|
@ -824,7 +824,7 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
let resultVal = row.C;
|
||||
|
||||
if (specialStr === null) {
|
||||
assert.equal(resultVal, null);
|
||||
assert.strictEqual(resultVal, null);
|
||||
} else {
|
||||
compareStrings(resultVal, specialStr, insertContent, insertContentLength);
|
||||
}
|
||||
|
@ -1092,7 +1092,7 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
);
|
||||
let resultVal = result.rows[0][1];
|
||||
if (specialStr === null) {
|
||||
assert.equal(resultVal, null);
|
||||
assert.strictEqual(resultVal, null);
|
||||
} else {
|
||||
compareStrings(resultVal, specialStr, insertContent, insertContentLength);
|
||||
}
|
||||
|
@ -1370,7 +1370,7 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
|
||||
let resultVal = row[1];
|
||||
if (specialStr === null) {
|
||||
assert.equal(resultVal, null);
|
||||
assert.strictEqual(resultVal, null);
|
||||
} else {
|
||||
compareStrings(resultVal, specialStr, insertContent, insertContentLength);
|
||||
}
|
||||
|
|
|
@ -34,357 +34,260 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const async = require('async');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
|
||||
describe('86. fetchClobAsString3.js', function() {
|
||||
|
||||
let connection = null;
|
||||
var insertID = 1; // assume id for insert into db starts from 1
|
||||
var proc_create_table2 = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_clob2 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_clob2 ( \n" +
|
||||
" ID NUMBER, \n" +
|
||||
" C1 CLOB, \n" +
|
||||
" C2 CLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var drop_table2 = "DROP TABLE nodb_clob2 PURGE";
|
||||
var defaultStmtCache = oracledb.stmtCacheSize;
|
||||
let insertID = 1; // assume id for insert into db starts from 1
|
||||
const proc_create_table2 = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_clob2 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_clob2 ( \n" +
|
||||
" ID NUMBER, \n" +
|
||||
" C1 CLOB, \n" +
|
||||
" C2 CLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
const drop_table2 = "DROP TABLE nodb_clob2 PURGE";
|
||||
let defaultStmtCache = oracledb.stmtCacheSize;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
before('get one connection', async function() {
|
||||
oracledb.stmtCacheSize = 0;
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
}); // before
|
||||
|
||||
after('release connection', function(done) {
|
||||
after('release connection', async function() {
|
||||
oracledb.stmtCacheSize = defaultStmtCache;
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
var insertIntoClobTable2 = function(id, content1, content2, callback) {
|
||||
connection.execute(
|
||||
const insertIntoClobTable2 = async function(id, content1, content2) {
|
||||
let result = await connection.execute(
|
||||
"INSERT INTO nodb_clob2 VALUES (:ID, :C1, :C2)",
|
||||
[ id, content1, content2 ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
[ id, content1, content2 ]
|
||||
);
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
};
|
||||
|
||||
describe('86.1 fetch multiple CLOBs and result set', function() {
|
||||
before('create Table and populate', function(done) {
|
||||
connection.execute(
|
||||
proc_create_table2,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done() ;
|
||||
}
|
||||
);
|
||||
before('create Table and populate', async function() {
|
||||
await connection.execute(proc_create_table2);
|
||||
}); // before
|
||||
|
||||
after('drop table', function(done) {
|
||||
after('drop table', async function() {
|
||||
oracledb.fetchAsString = [];
|
||||
connection.execute(
|
||||
drop_table2,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
await connection.execute(drop_table2);
|
||||
}); // after
|
||||
|
||||
beforeEach('set oracledb.fetchAsString', function(done) {
|
||||
beforeEach('set oracledb.fetchAsString', function() {
|
||||
oracledb.fetchAsString = [ oracledb.CLOB ];
|
||||
done();
|
||||
}); // beforeEach
|
||||
|
||||
afterEach('clear the By type specification', function(done) {
|
||||
afterEach('clear the By type specification', function() {
|
||||
oracledb.fetchAsString = [];
|
||||
done();
|
||||
}); // afterEach
|
||||
|
||||
it('86.1.1 fetch multiple CLOB columns as String', function(done) {
|
||||
var id = insertID++;
|
||||
var specialStr_1 = '86.1.1_1';
|
||||
var contentLength_1 = 26;
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var specialStr_2 = '86.1.1_2';
|
||||
var contentLength_2 = 100;
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
it('86.1.1 fetch multiple CLOB columns as String', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr_1 = '86.1.1_1';
|
||||
const contentLength_1 = 26;
|
||||
let content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
let specialStr_2 = '86.1.1_2';
|
||||
const contentLength_2 = 100;
|
||||
let content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable2(id, content_1, content_2, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"SELECT ID, C1, C2 from nodb_clob2",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var specialStrLen_1 = specialStr_1.length;
|
||||
var resultLen_1 = result.rows[0][1].length;
|
||||
should.equal(result.rows[0][1].length, contentLength_1);
|
||||
should.strictEqual(result.rows[0][1].substring(0, specialStrLen_1), specialStr_1);
|
||||
should.strictEqual(result.rows[0][1].substring(resultLen_1 - specialStrLen_1, resultLen_1), specialStr_1);
|
||||
await insertIntoClobTable2(id, content_1, content_2);
|
||||
|
||||
var specialStrLen_2 = specialStr_2.length;
|
||||
var resultLen_2 = result.rows[0][2].length;
|
||||
should.equal(result.rows[0][2].length, contentLength_2);
|
||||
should.strictEqual(result.rows[0][2].substring(0, specialStrLen_2), specialStr_2);
|
||||
should.strictEqual(result.rows[0][2].substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let result = await connection.execute("SELECT ID, C1, C2 from nodb_clob2");
|
||||
let specialStrLen_1 = specialStr_1.length;
|
||||
let resultLen_1 = result.rows[0][1].length;
|
||||
assert.strictEqual(result.rows[0][1].length, contentLength_1);
|
||||
assert.strictEqual(result.rows[0][1].substring(0, specialStrLen_1), specialStr_1);
|
||||
assert.strictEqual(result.rows[0][1].substring(resultLen_1 - specialStrLen_1, resultLen_1), specialStr_1);
|
||||
|
||||
let specialStrLen_2 = specialStr_2.length;
|
||||
let resultLen_2 = result.rows[0][2].length;
|
||||
assert.strictEqual(result.rows[0][2].length, contentLength_2);
|
||||
assert.strictEqual(result.rows[0][2].substring(0, specialStrLen_2), specialStr_2);
|
||||
assert.strictEqual(result.rows[0][2].substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
|
||||
}); // 86.1.1
|
||||
|
||||
it('86.1.2 fetch two CLOB columns, one as string, another streamed', function(done) {
|
||||
var id = insertID++;
|
||||
var specialStr_1 = '86.1.2_1';
|
||||
var contentLength_1 = 30;
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
var specialStr_2 = '86.1.2_2';
|
||||
var contentLength_2 = 50;
|
||||
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
it('86.1.2 fetch two CLOB columns, one as string, another streamed', async function() {
|
||||
let id = insertID++;
|
||||
const specialStr_1 = '86.1.2_1';
|
||||
const contentLength_1 = 30;
|
||||
let content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
const specialStr_2 = '86.1.2_2';
|
||||
const contentLength_2 = 50;
|
||||
let content_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
insertIntoClobTable2(id, content_1, content_2, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"SELECT ID, C1 from nodb_clob2 where ID = :id",
|
||||
{ id: id },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var specialStrLen_1 = specialStr_1.length;
|
||||
var resultLen_1 = result.rows[0][1].length;
|
||||
should.equal(result.rows[0][1].length, contentLength_1);
|
||||
should.strictEqual(result.rows[0][1].substring(0, specialStrLen_1), specialStr_1);
|
||||
should.strictEqual(result.rows[0][1].substring(resultLen_1 - specialStrLen_1, resultLen_1), specialStr_1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
oracledb.fetchAsString = [];
|
||||
await insertIntoClobTable2(id, content_1, content_2);
|
||||
|
||||
connection.execute(
|
||||
"SELECT C2 from nodb_clob2 where ID = :id",
|
||||
{ id: id },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rows.length).should.not.eql(0);
|
||||
var lob = result.rows[0][0];
|
||||
should.exist(lob);
|
||||
let result = await connection.execute(
|
||||
"SELECT ID, C1 from nodb_clob2 where ID = :id",
|
||||
{ id: id }
|
||||
);
|
||||
let specialStrLen_1 = specialStr_1.length;
|
||||
let resultLen_1 = result.rows[0][1].length;
|
||||
assert.strictEqual(result.rows[0][1].length, contentLength_1);
|
||||
assert.strictEqual(result.rows[0][1].substring(0, specialStrLen_1), specialStr_1);
|
||||
assert.strictEqual(result.rows[0][1].substring(resultLen_1 - specialStrLen_1, resultLen_1), specialStr_1);
|
||||
|
||||
// set the encoding so we get a 'string' not a 'String'
|
||||
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() {
|
||||
should.not.exist(err);
|
||||
var specialStrLen_2 = specialStr_2.length;
|
||||
var resultLen_2 = clobData.length;
|
||||
should.equal(clobData.length, contentLength_2);
|
||||
should.strictEqual(clobData.substring(0, specialStrLen_2), specialStr_2);
|
||||
should.strictEqual(clobData.substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
|
||||
|
||||
cb();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
oracledb.fetchAsString = [];
|
||||
result = await connection.execute(
|
||||
"SELECT C2 from nodb_clob2 where ID = :id",
|
||||
{ id: id }
|
||||
);
|
||||
assert.notStrictEqual(result.rows.length, 0);
|
||||
|
||||
let lob = result.rows[0][0];
|
||||
assert(lob);
|
||||
// set the encoding so we get a 'string' not a 'String'
|
||||
lob.setEncoding('utf8');
|
||||
let clobData = await lob.getData();
|
||||
let specialStrLen_2 = specialStr_2.length;
|
||||
let resultLen_2 = clobData.length;
|
||||
assert.strictEqual(clobData.length, contentLength_2);
|
||||
assert.strictEqual(clobData.substring(0, specialStrLen_2), specialStr_2);
|
||||
assert.strictEqual(clobData.substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
|
||||
}); // 86.1.2
|
||||
|
||||
it('86.1.3 works with Restult Set', function(done) {
|
||||
var id = insertID++;
|
||||
var specialStr_1 = '86.1.3';
|
||||
var contentLength_1 = 387;
|
||||
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
it('86.1.3 works with Restult Set', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr_1 = '86.1.3';
|
||||
let contentLength_1 = 387;
|
||||
let content_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "insert into nodb_clob2(id, c1) values (:i, :c)";
|
||||
connection.execute(
|
||||
sql,
|
||||
{
|
||||
i: id,
|
||||
c: content_1
|
||||
},
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
let doClose = async function(rs) {
|
||||
await rs.close();
|
||||
};
|
||||
|
||||
let fetchOneRowFromRS = async function(rs) {
|
||||
let row = await rs.getRow();
|
||||
if (!row) {
|
||||
await doClose(rs);
|
||||
} else {
|
||||
let specialStrLen_1 = specialStr_1.length;
|
||||
let resultLen_1 = row[0].length;
|
||||
assert.strictEqual(row[0].length, contentLength_1);
|
||||
assert.strictEqual(
|
||||
row[0].substring(0, specialStrLen_1),
|
||||
specialStr_1
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select c1 from nodb_clob2 where id = :1",
|
||||
[id],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fetchOneRowFromRS(result.resultSet, cb);
|
||||
}
|
||||
assert.strictEqual(
|
||||
row[0].substring(resultLen_1 - specialStrLen_1, resultLen_1),
|
||||
specialStr_1
|
||||
);
|
||||
await fetchOneRowFromRS(rs);
|
||||
}
|
||||
], done);
|
||||
|
||||
var fetchOneRowFromRS = function(rs, callback) {
|
||||
rs.getRow(
|
||||
function(err, row) {
|
||||
if (err) {
|
||||
should.not.exist(err);
|
||||
doClose(rs, callback);
|
||||
} else if (!row) {
|
||||
doClose(rs, callback);
|
||||
} else {
|
||||
var specialStrLen_1 = specialStr_1.length;
|
||||
var resultLen_1 = row[0].length;
|
||||
should.equal(row[0].length, contentLength_1);
|
||||
should.strictEqual(
|
||||
row[0].substring(0, specialStrLen_1),
|
||||
specialStr_1
|
||||
);
|
||||
should.strictEqual(
|
||||
row[0].substring(resultLen_1 - specialStrLen_1, resultLen_1),
|
||||
specialStr_1
|
||||
);
|
||||
fetchOneRowFromRS(rs, callback);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var doClose = function(rs, callback) {
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
let sql = "insert into nodb_clob2(id, c1) values (:i, :c)";
|
||||
await connection.execute(
|
||||
sql,
|
||||
{
|
||||
i: id,
|
||||
c: content_1
|
||||
}
|
||||
);
|
||||
|
||||
let result = await connection.execute(
|
||||
"select c1 from nodb_clob2 where id = :1",
|
||||
[id],
|
||||
{ resultSet: true }
|
||||
);
|
||||
await fetchOneRowFromRS(result.resultSet);
|
||||
}); // 86.1.3
|
||||
|
||||
}); // 86.1
|
||||
|
||||
describe('86.2 types support for fetchAsString property', function() {
|
||||
|
||||
afterEach ('clear the by-type specification', function(done) {
|
||||
afterEach ('clear the by-type specification', function() {
|
||||
oracledb.fetchAsString = [];
|
||||
done ();
|
||||
});
|
||||
|
||||
it('86.2.1 String not supported in fetchAsString', function(done) {
|
||||
should.throws(
|
||||
it('86.2.1 String not supported in fetchAsString', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ oracledb.STRING ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 86.2.1
|
||||
|
||||
it('86.2.2 BLOB not supported in fetchAsString', function(done) {
|
||||
should.throws(
|
||||
it('86.2.2 BLOB not supported in fetchAsString', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ oracledb.BLOB ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 86.2.2
|
||||
|
||||
it('86.2.3 Cursor not supported in fetchAsString', function(done) {
|
||||
should.throws(
|
||||
it('86.2.3 Cursor not supported in fetchAsString', function() {
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ oracledb.CURSOR ];
|
||||
},
|
||||
/NJS-021: invalid type for conversion specified/
|
||||
);
|
||||
done();
|
||||
}); // 86.2.3
|
||||
|
||||
it('86.2.4 Buffer supported in fetchAsString', function(done) {
|
||||
should.doesNotThrow(
|
||||
it('86.2.4 Buffer supported in fetchAsString', function() {
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ oracledb.BUFFER ];
|
||||
}
|
||||
);
|
||||
should.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
should.strictEqual(oracledb.fetchAsString[0], oracledb.BUFFER);
|
||||
done();
|
||||
assert.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
assert.strictEqual(oracledb.fetchAsString[0], oracledb.BUFFER);
|
||||
}); // 86.2.4
|
||||
|
||||
it('86.2.5 Number supported in fetchAsString', function(done) {
|
||||
should.doesNotThrow(
|
||||
it('86.2.5 Number supported in fetchAsString', function() {
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ oracledb.NUMBER ];
|
||||
}
|
||||
);
|
||||
should.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
should.strictEqual(oracledb.fetchAsString[0], oracledb.NUMBER);
|
||||
done();
|
||||
assert.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
assert.strictEqual(oracledb.fetchAsString[0], oracledb.NUMBER);
|
||||
}); // 86.2.5
|
||||
|
||||
it('86.2.6 Date supported in fetchAsString', function(done) {
|
||||
should.doesNotThrow(
|
||||
it('86.2.6 Date supported in fetchAsString', function() {
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||
}
|
||||
);
|
||||
should.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
should.strictEqual(oracledb.fetchAsString[0], oracledb.DATE);
|
||||
done();
|
||||
assert.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
assert.strictEqual(oracledb.fetchAsString[0], oracledb.DATE);
|
||||
}); // 86.2.6
|
||||
|
||||
it('86.2.7 CLOB supported in fetchAsString', function(done) {
|
||||
should.doesNotThrow(
|
||||
it('86.2.7 CLOB supported in fetchAsString', function() {
|
||||
assert.doesNotThrow(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ oracledb.CLOB ];
|
||||
}
|
||||
);
|
||||
should.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
should.strictEqual(oracledb.fetchAsString[0], oracledb.CLOB);
|
||||
done();
|
||||
assert.strictEqual(oracledb.fetchAsString.length, 1);
|
||||
assert.strictEqual(oracledb.fetchAsString[0], oracledb.CLOB);
|
||||
}); // 86.2.7
|
||||
|
||||
it('86.2.8 undefined in fetchAsString will throw NJS-021', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ undefined ];
|
||||
},
|
||||
|
@ -393,7 +296,7 @@ describe('86. fetchClobAsString3.js', function() {
|
|||
}); // 86.2.8
|
||||
|
||||
it('86.2.9 Random string in fetchAsString will throw NJS-021', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ "foobar" ];
|
||||
},
|
||||
|
@ -402,7 +305,7 @@ describe('86. fetchClobAsString3.js', function() {
|
|||
}); // 86.2.9
|
||||
|
||||
it('86.2.10 Random integer in fetchAsString will throw NJS-021', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ 31415 ];
|
||||
},
|
||||
|
@ -411,7 +314,7 @@ describe('86. fetchClobAsString3.js', function() {
|
|||
}); // 86.2.10
|
||||
|
||||
it('86.2.11 Negative integer in fetchAsString will throw NJS-021', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ -1 ];
|
||||
},
|
||||
|
@ -420,7 +323,7 @@ describe('86. fetchClobAsString3.js', function() {
|
|||
}); // 86.2.11
|
||||
|
||||
it('86.2.12 Random float in fetchAsString will throw NJS-021', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ 3.1415 ];
|
||||
},
|
||||
|
@ -429,7 +332,7 @@ describe('86. fetchClobAsString3.js', function() {
|
|||
}); // 86.2.12
|
||||
|
||||
it('86.2.13 Array in fetchAsString will throw NJS-021', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ [3] ];
|
||||
},
|
||||
|
@ -438,7 +341,7 @@ describe('86. fetchClobAsString3.js', function() {
|
|||
}); // 86.2.13
|
||||
|
||||
it('86.2.14 Object in fetchAsString will throw NJS-021', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = [ {1:1} ];
|
||||
},
|
||||
|
@ -447,7 +350,7 @@ describe('86. fetchClobAsString3.js', function() {
|
|||
}); // 86.2.14
|
||||
|
||||
it('86.2.15 Non-Array as fetchAsString will throw NJS-004', function() {
|
||||
should.throws(
|
||||
assert.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = 1;
|
||||
},
|
||||
|
|
|
@ -32,16 +32,15 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
|
||||
describe('90. fetchClobAsString4.js', function() {
|
||||
|
||||
let connection = null;
|
||||
var insertID = 1; // assume id for insert into db starts from 1
|
||||
var proc_clob_in_tab = "BEGIN \n" +
|
||||
let insertID = 1; // assume id for insert into db starts from 1
|
||||
const proc_clob_in_tab = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
|
@ -61,579 +60,416 @@ describe('90. fetchClobAsString4.js', function() {
|
|||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_clob_in_tab,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await connection.execute(proc_clob_in_tab);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.fetchAsString = [];
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_clob_1 PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
|
||||
after(async function() {
|
||||
oracledb.fetchAsString = [];
|
||||
await connection.execute("DROP TABLE nodb_clob_1 PURGE");
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
var executeSQL = function(sql, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return callback();
|
||||
}
|
||||
);
|
||||
const insertTable = async function(insertSql, bindVar) {
|
||||
let result = await connection.execute(insertSql, bindVar);
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
};
|
||||
|
||||
var insertTable = function(insertSql, bindVar, callback) {
|
||||
connection.execute(
|
||||
insertSql,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var verifyResult = function(resultVal, specialStr, originalStr) {
|
||||
var resultLength = resultVal.length;
|
||||
var specStrLength = specialStr.length;
|
||||
should.strictEqual(resultLength, originalStr.length);
|
||||
should.strictEqual(resultVal.substring(0, specStrLength), specialStr);
|
||||
should.strictEqual(resultVal.substring(resultLength - specStrLength, resultLength), specialStr);
|
||||
let verifyResult = function(resultVal, specialStr, originalStr) {
|
||||
let resultLength = resultVal.length;
|
||||
let specStrLength = specialStr.length;
|
||||
assert.strictEqual(resultLength, originalStr.length);
|
||||
assert.strictEqual(resultVal.substring(0, specStrLength), specialStr);
|
||||
assert.strictEqual(resultVal.substring(resultLength - specStrLength, resultLength), specialStr);
|
||||
};
|
||||
|
||||
describe('90.1 PLSQL FUNCTION RETURN CLOB to STRING', function() {
|
||||
var proc = "CREATE OR REPLACE FUNCTION nodb_clobs_out_94 (ID_1 IN NUMBER, ID_2 IN NUMBER, C IN VARCHAR2) RETURN CLOB \n" +
|
||||
const proc = "CREATE OR REPLACE FUNCTION nodb_clobs_out_94 (ID_1 IN NUMBER, ID_2 IN NUMBER, C IN VARCHAR2) RETURN CLOB \n" +
|
||||
"IS \n" +
|
||||
" tmpLOB4 CLOB; \n" +
|
||||
"BEGIN \n" +
|
||||
" select clob into tmpLOB4 from nodb_clob_1 where num_1 = ID_1;\n" +
|
||||
" RETURN tmpLOB4; \n" +
|
||||
"END;";
|
||||
var sqlRun = "begin :output := nodb_clobs_out_94 (:i1, :i2, :c); end;";
|
||||
var proc_drop = "DROP FUNCTION nodb_clobs_out_94";
|
||||
const sqlRun = "begin :output := nodb_clobs_out_94 (:i1, :i2, :c); end;";
|
||||
const proc_drop = "DROP FUNCTION nodb_clobs_out_94";
|
||||
|
||||
before(function(done) {
|
||||
executeSQL(proc, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
executeSQL(proc_drop, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
beforeEach('set oracledb.fetchAsString', function(done) {
|
||||
beforeEach('set oracledb.fetchAsString', function() {
|
||||
oracledb.fetchAsString = [ oracledb.CLOB ];
|
||||
done();
|
||||
}); // beforeEach
|
||||
|
||||
afterEach('clear the By type specification', function(done) {
|
||||
afterEach('clear the By type specification', function() {
|
||||
oracledb.fetchAsString = [];
|
||||
done();
|
||||
}); // afterEach
|
||||
|
||||
it('90.1.1 bind by position - 1', function(done) {
|
||||
var len = 400;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.1.1";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.1.1 bind by position - 1', async function() {
|
||||
const len = 400;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.1.1";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, null, clobStr],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, null, clobStr]
|
||||
);
|
||||
let resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.1.1
|
||||
|
||||
it('90.1.2 bind by name - 1', function(done) {
|
||||
var len = 400;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.1.2";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.1.2 bind by name - 1', async function() {
|
||||
const len = 400;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.1.2";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: null, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: null, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
}
|
||||
], done);
|
||||
);
|
||||
let resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.1.2
|
||||
|
||||
it('90.1.3 bind by position - 2', function(done) {
|
||||
var len = 400;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.1.2";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.1.3 bind by position - 2', async function() {
|
||||
const len = 400;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.1.2";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, sequence, null ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, sequence, null ]
|
||||
);
|
||||
let resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.1.3
|
||||
|
||||
it('90.1.4 bind by name - 2', function(done) {
|
||||
var len = 400;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.1.4";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.1.4 bind by name - 2', async function() {
|
||||
const len = 400;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.1.4";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
}
|
||||
], done);
|
||||
);
|
||||
let resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.1.4
|
||||
|
||||
}); // 90.1
|
||||
|
||||
describe('90.2 PLSQL PROCEDURE BIND OUT CLOB to STRING', function() {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_92 (ID_1 IN NUMBER, ID_2 IN NUMBER, C1 IN VARCHAR2, C2 OUT CLOB) \n" +
|
||||
const proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_92 (ID_1 IN NUMBER, ID_2 IN NUMBER, C1 IN VARCHAR2, C2 OUT CLOB) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" select clob into C2 from nodb_clob_1 where num_1 = ID_1;\n" +
|
||||
"END;";
|
||||
var sqlRun = "begin nodb_clobs_out_92 (:i1, :i2, :c1, :c2); end;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_clobs_out_92";
|
||||
const sqlRun = "begin nodb_clobs_out_92 (:i1, :i2, :c1, :c2); end;";
|
||||
const proc_drop = "DROP PROCEDURE nodb_clobs_out_92";
|
||||
|
||||
before(function(done) {
|
||||
executeSQL(proc, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
executeSQL(proc_drop, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
beforeEach('set oracledb.fetchAsString', function(done) {
|
||||
beforeEach('set oracledb.fetchAsString', function() {
|
||||
oracledb.fetchAsString = [ oracledb.CLOB ];
|
||||
done();
|
||||
}); // beforeEach
|
||||
|
||||
afterEach('clear the By type specification', function(done) {
|
||||
afterEach('clear the By type specification', function() {
|
||||
oracledb.fetchAsString = [];
|
||||
done();
|
||||
}); // afterEach
|
||||
|
||||
it('90.2.1 bind by position - 1', function(done) {
|
||||
var len = 500;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.2.1";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.2.1 bind by position - 1', async function() {
|
||||
const len = 500;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.2.1";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
[ sequence, null, { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len } ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
[ sequence, null, { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len } ]
|
||||
);
|
||||
let resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.2.1
|
||||
|
||||
it('90.2.2 bind by name - 1', function(done) {
|
||||
var len = 400;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.2.2";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.2.2 bind by name - 1', async function() {
|
||||
const len = 400;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.2.2";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: null, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
c2: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.c2;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: null, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
c2: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
}
|
||||
], done);
|
||||
);
|
||||
let resultVal = result.outBinds.c2;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.2.2
|
||||
|
||||
it('90.2.3 bind by position - 2', function(done) {
|
||||
var len = 500;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.2.3";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.2.3 bind by position - 2', async function() {
|
||||
const len = 500;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.2.3";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
[ sequence, sequence, null, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len } ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
[ sequence, sequence, null, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len } ]
|
||||
);
|
||||
let resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.2.3
|
||||
|
||||
it('90.2.4 bind by name - 2', function(done) {
|
||||
var len = 400;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.2.4";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.2.4 bind by name - 2', async function() {
|
||||
const len = 400;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.2.4";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
c2: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.c2;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
c2: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
}
|
||||
], done);
|
||||
);
|
||||
let resultVal = result.outBinds.c2;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.2.4
|
||||
|
||||
}); // 90.2
|
||||
|
||||
describe('90.3 PLSQL FUNCTION RETURN CLOB to VARCHAR2', function() {
|
||||
var proc = "CREATE OR REPLACE FUNCTION nodb_clobs_out_92 (ID_1 IN NUMBER, ID_2 IN NUMBER, C IN VARCHAR2) RETURN VARCHAR2 \n" +
|
||||
const proc = "CREATE OR REPLACE FUNCTION nodb_clobs_out_92 (ID_1 IN NUMBER, ID_2 IN NUMBER, C IN VARCHAR2) RETURN VARCHAR2 \n" +
|
||||
"IS \n" +
|
||||
" tmpLOB2 CLOB; \n" +
|
||||
"BEGIN \n" +
|
||||
" select clob into tmpLOB2 from nodb_clob_1 where num_1 = ID_1;\n" +
|
||||
" RETURN tmpLOB2; \n" +
|
||||
"END;";
|
||||
var sqlRun = "begin :output := nodb_clobs_out_92 (:i1, :i2, :c); end;";
|
||||
var proc_drop = "DROP FUNCTION nodb_clobs_out_92";
|
||||
const sqlRun = "begin :output := nodb_clobs_out_92 (:i1, :i2, :c); end;";
|
||||
const proc_drop = "DROP FUNCTION nodb_clobs_out_92";
|
||||
|
||||
before(function(done) {
|
||||
executeSQL(proc, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
executeSQL(proc_drop, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_drop);
|
||||
}); // after
|
||||
|
||||
beforeEach('set oracledb.fetchAsString', function(done) {
|
||||
beforeEach('set oracledb.fetchAsString', function() {
|
||||
oracledb.fetchAsString = [ oracledb.CLOB ];
|
||||
done();
|
||||
}); // beforeEach
|
||||
|
||||
afterEach('clear the By type specification', function(done) {
|
||||
afterEach('clear the By type specification', function() {
|
||||
oracledb.fetchAsString = [];
|
||||
done();
|
||||
}); // afterEach
|
||||
|
||||
it('90.3.1 bind by name - 1', function(done) {
|
||||
var len = 1000;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.3.1";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.3.1 bind by name - 1', async function() {
|
||||
const len = 1000;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.3.1";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: null, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: null, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
}
|
||||
], done);
|
||||
);
|
||||
let resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.3.1
|
||||
|
||||
it('90.3.2 bind by position - 1', function(done) {
|
||||
var len = 1000;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.3.1";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.3.2 bind by position - 1', async function() {
|
||||
const len = 1000;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.3.1";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, null, clobStr ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, null, clobStr ]
|
||||
);
|
||||
let resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.3.2
|
||||
|
||||
it('90.3.3 bind by name - 2', function(done) {
|
||||
var len = 1000;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.3.3";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.3.3 bind by name - 2', async function() {
|
||||
const len = 1000;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.3.3";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
{
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
|
||||
}
|
||||
], done);
|
||||
);
|
||||
let resultVal = result.outBinds.output;
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.3.3
|
||||
|
||||
it('90.3.4 bind by position - 2', function(done) {
|
||||
var len = 1000;
|
||||
var sequence = insertID++;
|
||||
var specialStr = "90.3.4";
|
||||
var clobStr = random.getRandomString(len, specialStr);
|
||||
it('90.3.4 bind by position - 2', async function() {
|
||||
const len = 1000;
|
||||
let sequence = insertID++;
|
||||
const specialStr = "90.3.4";
|
||||
let clobStr = random.getRandomString(len, specialStr);
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
var bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
insertTable(sql, bindVar, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, sequence, null ],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let sql = "INSERT INTO nodb_clob_1 (num_1, num_2, content, clob) VALUES (:i1, :i2, :c1, :c2)";
|
||||
let bindVar = {
|
||||
i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
i2: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len },
|
||||
c2: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
|
||||
};
|
||||
await insertTable(sql, bindVar);
|
||||
|
||||
let result = await connection.execute(
|
||||
sqlRun,
|
||||
[ { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }, sequence, sequence, null ]
|
||||
);
|
||||
let resultVal = result.outBinds[0];
|
||||
verifyResult(resultVal, specialStr, clobStr);
|
||||
}); // 90.3.4
|
||||
|
||||
}); // 90.3
|
||||
|
|
|
@ -35,7 +35,6 @@ const oracledb = require('oracledb');
|
|||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('245. fetchLobAsStrBuf.js', function() {
|
||||
let connection = null;
|
||||
|
@ -163,13 +162,13 @@ describe('245. fetchLobAsStrBuf.js', function() {
|
|||
lob.on('end', function() {
|
||||
if (originalBuffer == "EMPTY_BLOB") {
|
||||
let nullBuffer = Buffer.from('', "utf-8");
|
||||
assert.strictEqual(assist.compare2Buffers(blobData, nullBuffer), true);
|
||||
assert.deepStrictEqual(blobData, nullBuffer);
|
||||
} else {
|
||||
assert.strictEqual(totalLength, originalBuffer.length);
|
||||
let specStrLength = specialStr.length;
|
||||
assert.strictEqual(blobData.toString('utf8', 0, specStrLength), specialStr);
|
||||
assert.strictEqual(blobData.toString('utf8', (totalLength - specStrLength), totalLength), specialStr);
|
||||
assert.strictEqual(assist.compare2Buffers(blobData, originalBuffer), true);
|
||||
assert.deepStrictEqual(blobData, originalBuffer);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
|
|
|
@ -34,650 +34,472 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const async = require('async');
|
||||
const should = require('should');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
|
||||
describe('116. fetchUrowidAsString.js', function() {
|
||||
|
||||
let connection = null;
|
||||
var tableName = "nodb_rowid";
|
||||
var dataArray = random.getRandomNumArray(30);
|
||||
var numRows = dataArray.length; // number of rows to return from each call to getRows()
|
||||
const tableName = "nodb_rowid";
|
||||
let dataArray = random.getRandomNumArray(30);
|
||||
let numRows = dataArray.length; // number of rows to return from each call to getRows()
|
||||
|
||||
var proc_create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE' ); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE ( ' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" num NUMBER, \n" +
|
||||
" content UROWID \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
const proc_create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE' ); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE ( ' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" num NUMBER, \n" +
|
||||
" content UROWID \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before('get one connection', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after('release connection', async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
var insertData = function(connection, tableName, callback) {
|
||||
async.eachSeries(dataArray, function(element, cb) {
|
||||
var sql = "INSERT INTO " + tableName + "(num) VALUES(" + element + ")";
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
const insertData = async function(connection, tableName) {
|
||||
for (let element in dataArray) {
|
||||
const sql = "INSERT INTO " + tableName + "(num) VALUES(" + element + ")";
|
||||
await connection.execute(sql);
|
||||
}
|
||||
};
|
||||
|
||||
var updateDate = function(connection, tableName, callback) {
|
||||
async.eachSeries(dataArray, function(element, cb) {
|
||||
var sql = "UPDATE " + tableName + " T SET content = T.ROWID where num = " + element;
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
const updateData = async function(connection, tableName) {
|
||||
for (let element in dataArray) {
|
||||
const sql = "UPDATE " + tableName + " T SET content = T.ROWID where num = " + element;
|
||||
await connection.execute(sql);
|
||||
}
|
||||
};
|
||||
|
||||
describe('116.1 works with fetchInfo option', function() {
|
||||
var maxRowBak = oracledb.maxRows;
|
||||
var option = { fetchInfo: { "CONTENT": { type: oracledb.STRING } } };
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function makeTable(callback) {
|
||||
connection.execute(
|
||||
proc_create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function insertRow(callback) {
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
let maxRowBak = oracledb.maxRows;
|
||||
let option = { fetchInfo: { "CONTENT": { type: oracledb.STRING } } };
|
||||
before(async function() {
|
||||
await connection.execute(proc_create_table);
|
||||
await insertData(connection, tableName);
|
||||
await updateData(connection, tableName);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
after(async function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
it('116.1.1 fetchInfo', function(done) {
|
||||
test1(option, false, false, done);
|
||||
it('116.1.1 fetchInfo', async function() {
|
||||
await test1(option, false);
|
||||
});
|
||||
|
||||
it('116.1.2 fetchInfo, and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.1.2 fetchInfo, and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.1.3 fetchInfo, and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.1.3 fetchInfo, and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.1.4 fetchInfo, and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.1.4 fetchInfo, and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.1.5 fetchInfo, queryStream() and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.1.5 fetchInfo, queryStream() and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.1.6 fetchInfo, queryStream() and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.1.6 fetchInfo, queryStream() and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.1.7 fetchInfo, queryStream() and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.1.7 fetchInfo, queryStream() and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.1.8 fetchInfo, resultSet = true', function(done) {
|
||||
var option_rs = {
|
||||
it('116.1.8 fetchInfo, resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
resultSet: true,
|
||||
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||
};
|
||||
test2(option_rs, false, false, done);
|
||||
await test2(option_rs, false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('116.2 works with fetchInfo and outFormat = OBJECT', function() {
|
||||
var maxRowBak = oracledb.maxRows;
|
||||
var option = {
|
||||
let maxRowBak = oracledb.maxRows;
|
||||
let option = {
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||
};
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function makeTable(callback) {
|
||||
connection.execute(
|
||||
proc_create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function insertRow(callback) {
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_create_table);
|
||||
await insertData(connection, tableName);
|
||||
await updateData(connection, tableName);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
after(async function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
it('116.2.1 fetchInfo with outFormat = OBJECT', function(done) {
|
||||
test1(option, true, false, done);
|
||||
it('116.2.1 fetchInfo with outFormat = OBJECT', async function() {
|
||||
await test1(option, true);
|
||||
});
|
||||
|
||||
it('116.2.2 fetchInfo, outFormat = OBJECT, and resultSet = true', function(done) {
|
||||
var option_rs = {
|
||||
it('116.2.2 fetchInfo, outFormat = OBJECT, and resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
resultSet: true,
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||
};
|
||||
test2(option_rs, true, false, done);
|
||||
await test2(option_rs, true);
|
||||
});
|
||||
|
||||
it('116.2.3 fetchInfo, outFormat = OBJECT, and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.2.3 fetchInfo, outFormat = OBJECT, and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.2.4 fetchInfo, outFormat = OBJECT, and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.2.4 fetchInfo, outFormat = OBJECT, and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.2.5 fetchInfo, outFormat = OBJECT, and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.2.5 fetchInfo, outFormat = OBJECT, and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.2.6 fetchInfo, outFormat = OBJECT, queryStream() and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.2.6 fetchInfo, outFormat = OBJECT, queryStream() and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.2.7 fetchInfo, outFormat = OBJECT, queryStream() and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.2.7 fetchInfo, outFormat = OBJECT, queryStream() and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.2.8 fetchInfo, outFormat = OBJECT, queryStream() and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.2.8 fetchInfo, outFormat = OBJECT, queryStream() and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
});
|
||||
|
||||
describe('116.3 works with fetchInfo and outFormat = ARRAY', function() {
|
||||
var maxRowBak = oracledb.maxRows;
|
||||
var option = {
|
||||
let maxRowBak = oracledb.maxRows;
|
||||
let option = {
|
||||
outFormat: oracledb.OUT_FORMAT_ARRAY,
|
||||
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||
};
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function makeTable(callback) {
|
||||
connection.execute(
|
||||
proc_create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function insertRow(callback) {
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_create_table);
|
||||
await insertData(connection, tableName);
|
||||
await updateData(connection, tableName);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
after(async function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
it('116.3.1 fetchInfo', function(done) {
|
||||
test1(option, false, true, done);
|
||||
it('116.3.1 fetchInfo', async function() {
|
||||
await test1(option, false);
|
||||
});
|
||||
|
||||
it('116.3.2 fetchInfo, and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.3.2 fetchInfo, and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.3.3 fetchInfo, and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.3.3 fetchInfo, and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.3.4 fetchInfo, and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.3.4 fetchInfo, and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.3.5 fetchInfo, queryStream() and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.3.5 fetchInfo, queryStream() and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.3.6 fetchInfo, queryStream() and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.3.6 fetchInfo, queryStream() and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.3.7 fetchInfo, queryStream() and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.3.7 fetchInfo, queryStream() and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.3.8 fetchInfo, resultSet = true', function(done) {
|
||||
var option_rs = {
|
||||
it('116.3.8 fetchInfo, resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
resultSet: true,
|
||||
outFormat: oracledb.OUT_FORMAT_ARRAY,
|
||||
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||
};
|
||||
test2(option_rs, false, true, done);
|
||||
await test2(option_rs, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('116.4 fetch as string by default', function() {
|
||||
var maxRowBak = oracledb.maxRows;
|
||||
var option = {};
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function makeTable(callback) {
|
||||
connection.execute(
|
||||
proc_create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function insertRow(callback) {
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
let maxRowBak = oracledb.maxRows;
|
||||
let option = {};
|
||||
before(async function() {
|
||||
await connection.execute(proc_create_table);
|
||||
await insertData(connection, tableName);
|
||||
await updateData(connection, tableName);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
after(async function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
await connection.execute(drop_table);
|
||||
|
||||
});
|
||||
|
||||
it('116.4.1 fetch by default', function(done) {
|
||||
test1(option, false, false, done);
|
||||
it('116.4.1 fetch by default', async function() {
|
||||
await test1(option, false);
|
||||
});
|
||||
|
||||
it('116.4.2 oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.4.2 oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.4.3 oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.4.3 oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.4.4 oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.4.4 oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.4.5 queryStream() and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.4.5 queryStream() and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.4.6 queryStream() and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.4.6 queryStream() and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.4.7 queryStream() and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.4.7 queryStream() and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.4.8 resultSet = true', function(done) {
|
||||
var option_rs = {
|
||||
it('116.4.8 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
resultSet: true,
|
||||
};
|
||||
test2(option_rs, false, false, done);
|
||||
await test2(option_rs, false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('116.5 fetch as string by default with outFormat = OBJECT', function() {
|
||||
var maxRowBak = oracledb.maxRows;
|
||||
var option = { outFormat: oracledb.OUT_FORMAT_OBJECT };
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function makeTable(callback) {
|
||||
connection.execute(
|
||||
proc_create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function insertRow(callback) {
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
let maxRowBak = oracledb.maxRows;
|
||||
let option = { outFormat: oracledb.OUT_FORMAT_OBJECT };
|
||||
before(async function() {
|
||||
await connection.execute(proc_create_table);
|
||||
await insertData(connection, tableName);
|
||||
await updateData(connection, tableName);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
after(async function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
await connection.execute(drop_table);
|
||||
|
||||
});
|
||||
|
||||
it('116.5.1 fetch by default', function(done) {
|
||||
test1(option, true, false, done);
|
||||
it('116.5.1 fetch by default', async function() {
|
||||
await test1(option, true);
|
||||
});
|
||||
|
||||
it('116.5.2 oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.5.2 oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.5.3 oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.5.3 oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.5.4 oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.5.4 oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.5.5 queryStream() and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.5.5 queryStream() and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.5.6 queryStream() and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.5.6 queryStream() and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.5.7 queryStream() and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.5.7 queryStream() and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.5.8 resultSet = true', function(done) {
|
||||
var option_rs = {
|
||||
it('116.5.8 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
resultSet: true,
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT
|
||||
};
|
||||
test2(option_rs, true, false, done);
|
||||
await test2(option_rs, true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('116.6 fetch as string by default with outFormat = ARRAY', function() {
|
||||
var maxRowBak = oracledb.maxRows;
|
||||
var option = { outFormat: oracledb.OUT_FORMAT_ARRAY };
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function makeTable(callback) {
|
||||
connection.execute(
|
||||
proc_create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function insertRow(callback) {
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
let maxRowBak = oracledb.maxRows;
|
||||
let option = { outFormat: oracledb.OUT_FORMAT_ARRAY };
|
||||
before(async function() {
|
||||
await connection.execute(proc_create_table);
|
||||
await insertData(connection, tableName);
|
||||
await updateData(connection, tableName);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
after(async function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
await connection.execute(drop_table);
|
||||
});
|
||||
|
||||
it('116.6.1 fetch by default', function(done) {
|
||||
test1(option, false, true, done);
|
||||
it('116.6.1 fetch by default', async function() {
|
||||
await test1(option, false);
|
||||
});
|
||||
|
||||
it('116.6.2 oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.6.2 oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.6.3 oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.6.3 oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.6.4 oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.6.4 oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testMaxRow(option, done);
|
||||
await testMaxRow(option);
|
||||
});
|
||||
|
||||
it('116.6.5 queryStream() and oracledb.maxRows < actual number of rows', function(done) {
|
||||
it('116.6.5 queryStream() and oracledb.maxRows < actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows - 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.6.6 queryStream() and oracledb.maxRows = actual number of rows', function(done) {
|
||||
it('116.6.6 queryStream() and oracledb.maxRows = actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.6.7 queryStream() and oracledb.maxRows > actual number of rows', function(done) {
|
||||
it('116.6.7 queryStream() and oracledb.maxRows > actual number of rows', async function() {
|
||||
oracledb.maxRows = numRows + 1;
|
||||
testQueryStream(option, done);
|
||||
await testQueryStream(option);
|
||||
});
|
||||
|
||||
it('116.6.8 resultSet = true', function(done) {
|
||||
var option_rs = {
|
||||
it('116.6.8 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
resultSet: true,
|
||||
outFormat: oracledb.OUT_FORMAT_ARRAY,
|
||||
};
|
||||
test2(option_rs, false, false, done);
|
||||
await test2(option_rs, false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function test1(option, object, array, callback) {
|
||||
async.eachSeries(dataArray, function(element, cb) {
|
||||
var sql = "select content,rowid from " + tableName + " where num = " + element;
|
||||
connection.execute(
|
||||
sql,
|
||||
[],
|
||||
option,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal_1 = result.rows[0][0];
|
||||
var resultVal_2 = result.rows[0][1];
|
||||
if (object === true) {
|
||||
resultVal_1 = result.rows[0].CONTENT;
|
||||
resultVal_2 = result.rows[0].ROWID;
|
||||
}
|
||||
should.strictEqual(typeof resultVal_1, "string");
|
||||
should.strictEqual(resultVal_1, resultVal_2);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function test2(option, object, array, callback) {
|
||||
async.eachSeries(dataArray, function(element, cb) {
|
||||
var sql = "select content,rowid from " + tableName + " where num = " + element;
|
||||
connection.execute(
|
||||
sql,
|
||||
[],
|
||||
option,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.resultSet.getRow(
|
||||
function(err, row) {
|
||||
var resultVal_1 = row[0];
|
||||
var resultVal_2 = row[1];
|
||||
if (object === true) {
|
||||
resultVal_1 = row.CONTENT;
|
||||
resultVal_2 = row.ROWID;
|
||||
}
|
||||
should.strictEqual(typeof resultVal_1, "string");
|
||||
should.strictEqual(resultVal_1, resultVal_2);
|
||||
result.resultSet.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function testMaxRow(option, callback) {
|
||||
var sql = "select CONTENT from " + tableName;
|
||||
connection.execute(
|
||||
sql,
|
||||
[],
|
||||
option,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var rowExpected = (oracledb.maxRows >= numRows) ? numRows : oracledb.maxRows;
|
||||
should.strictEqual(result.rows.length, rowExpected);
|
||||
callback();
|
||||
async function test1(option, object) {
|
||||
for (let element in dataArray) {
|
||||
const sql = "select content,rowid from " + tableName + " where num = " + element;
|
||||
let result = await connection.execute(sql, [], option);
|
||||
let resultVal_1 = result.rows[0][0];
|
||||
let resultVal_2 = result.rows[0][1];
|
||||
if (object === true) {
|
||||
resultVal_1 = result.rows[0].CONTENT;
|
||||
resultVal_2 = result.rows[0].ROWID;
|
||||
}
|
||||
);
|
||||
assert.strictEqual(typeof resultVal_1, "string");
|
||||
assert.strictEqual(resultVal_1, resultVal_2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function testQueryStream(option, callback) {
|
||||
var sql = "select CONTENT from " + tableName;
|
||||
var stream = connection.queryStream(
|
||||
sql,
|
||||
[],
|
||||
option
|
||||
);
|
||||
async function test2(option, object) {
|
||||
for (let element in dataArray) {
|
||||
const sql = "select content,rowid from " + tableName + " where num = " + element;
|
||||
let result = await connection.execute(sql, [], option);
|
||||
let row = await result.resultSet.getRow();
|
||||
let resultVal_1 = row[0];
|
||||
let resultVal_2 = row[1];
|
||||
|
||||
var result = [];
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
result.push(data);
|
||||
if (object === true) {
|
||||
resultVal_1 = row.CONTENT;
|
||||
resultVal_2 = row.ROWID;
|
||||
}
|
||||
assert.strictEqual(typeof resultVal_1, "string");
|
||||
assert.strictEqual(resultVal_1, resultVal_2);
|
||||
|
||||
await result.resultSet.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function testMaxRow(option) {
|
||||
let sql = "select CONTENT from " + tableName;
|
||||
let result = await connection.execute(sql, [], option);
|
||||
let rowExpected = (oracledb.maxRows >= numRows) ? numRows : oracledb.maxRows;
|
||||
assert.strictEqual(result.rows.length, rowExpected);
|
||||
}
|
||||
|
||||
async function testQueryStream(option) {
|
||||
const sql = "select CONTENT from " + tableName;
|
||||
const stream = await connection.queryStream(sql, [], option);
|
||||
|
||||
let result = [];
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.on('error', reject);
|
||||
stream.on('end', function() {
|
||||
assert.strictEqual(result.length, numRows);
|
||||
stream.destroy();
|
||||
});
|
||||
stream.on('close', resolve);
|
||||
stream.on('data', function(data) {
|
||||
assert(data);
|
||||
result.push(data);
|
||||
});
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
should.strictEqual(result.length, numRows);
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2019, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2019, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -63,7 +63,6 @@ describe('192. implicitResults.js', function() {
|
|||
|
||||
if (!isRunnable) {
|
||||
this.skip();
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
const conn = await oracledb.getConnection(dbConfig);
|
||||
|
|
|
@ -33,37 +33,26 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('158. insertAll.js', function() {
|
||||
|
||||
let conn;
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
conn = connection;
|
||||
done();
|
||||
}
|
||||
);
|
||||
before(async function() {
|
||||
conn = await oracledb.getConnection(dbConfig);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
conn.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await conn.close();
|
||||
});
|
||||
|
||||
it('158.1 original case from the issue', function(done) {
|
||||
it('158.1 original case from the issue', async function() {
|
||||
|
||||
var dataLength = 35000;
|
||||
var doCreate = function(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
let dataLength = 35000;
|
||||
//Create the table
|
||||
const proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
|
@ -80,228 +69,132 @@ describe('158. insertAll.js', function() {
|
|||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
conn.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
};
|
||||
await conn.execute(proc);
|
||||
|
||||
var doDrop = function(cb) {
|
||||
var sql = "DROP TABLE nodb_tab_insertall PURGE";
|
||||
conn.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
};
|
||||
// insert data (including LOB) into the table
|
||||
const myval = 'a'.repeat(dataLength);
|
||||
let sql = "INSERT ALL INTO nodb_tab_insertall \n" +
|
||||
" WITH nt AS (SELECT 1, :C FROM DUAL) \n" +
|
||||
" SELECT * FROM nt";
|
||||
let result = await conn.execute(
|
||||
sql,
|
||||
{ c: { val: myval, type: oracledb.CLOB } }
|
||||
);
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
|
||||
var doInsert = function(cb) {
|
||||
var myval = 'a'.repeat(dataLength);
|
||||
var sql = "INSERT ALL INTO nodb_tab_insertall \n" +
|
||||
" WITH nt AS (SELECT 1, :C FROM DUAL) \n" +
|
||||
" SELECT * FROM nt";
|
||||
conn.execute(
|
||||
sql,
|
||||
{ c: { val: myval, type: oracledb.CLOB } },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
};
|
||||
// Run a select query to get the inserted LOB's length
|
||||
sql = "select dbms_lob.getlength(val) from nodb_tab_insertall";
|
||||
result = await conn.execute(sql);
|
||||
let buf = result.rows[0][0];
|
||||
assert.strictEqual(buf, dataLength);
|
||||
|
||||
var doQuery = function(cb) {
|
||||
var sql = "select dbms_lob.getlength(val) from nodb_tab_insertall";
|
||||
conn.execute(
|
||||
sql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var buf = result.rows[0][0];
|
||||
should.strictEqual(buf, dataLength);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
async.series([
|
||||
doCreate,
|
||||
doInsert,
|
||||
doQuery,
|
||||
doDrop
|
||||
], done);
|
||||
// Drop the table
|
||||
sql = "DROP TABLE nodb_tab_insertall PURGE";
|
||||
await conn.execute(sql);
|
||||
|
||||
}); // 158.1
|
||||
|
||||
it('158.2 inserts into one table', function(done) {
|
||||
async.series([
|
||||
makeTab1,
|
||||
function dotest(cb) {
|
||||
var sql = "INSERT ALL \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (100, :a) \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (200, :b) \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (300, :c) \n" +
|
||||
"SELECT * FROM DUAL";
|
||||
conn.execute(
|
||||
sql,
|
||||
['Changjie', 'Shelly', 'Chris'],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 3);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function doverify(cb) {
|
||||
var sql = "select content from nodb_tab_ia1 order by id";
|
||||
conn.execute(
|
||||
sql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.deepEqual(
|
||||
result.rows,
|
||||
[ [ 'Changjie' ], [ 'Shelly' ], [ 'Chris' ] ]
|
||||
);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
dropTab1
|
||||
], done);
|
||||
it('158.2 inserts into one table', async function() {
|
||||
await makeTab1();
|
||||
let sql = "INSERT ALL \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (100, :a) \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (200, :b) \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (300, :c) \n" +
|
||||
"SELECT * FROM DUAL";
|
||||
let result = await conn.execute(
|
||||
sql,
|
||||
['Changjie', 'Shelly', 'Chris']
|
||||
);
|
||||
assert.strictEqual(result.rowsAffected, 3);
|
||||
|
||||
sql = "select content from nodb_tab_ia1 order by id";
|
||||
result = await conn.execute(sql);
|
||||
assert.deepStrictEqual(
|
||||
result.rows,
|
||||
[ [ 'Changjie' ], [ 'Shelly' ], [ 'Chris' ] ]
|
||||
);
|
||||
|
||||
//Drop the table
|
||||
sql = "DROP TABLE nodb_tab_ia1 PURGE";
|
||||
await conn.execute(sql);
|
||||
}); // 158.2
|
||||
|
||||
it('158.3 inserts into multiple tables', function(done) {
|
||||
async.series([
|
||||
makeTab1,
|
||||
makeTab2,
|
||||
function dotest(cb) {
|
||||
var sql = "INSERT ALL \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (100, :a) \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (200, :b) \n" +
|
||||
" INTO nodb_tab_ia2 (id, content) VALUES (300, :c) \n" +
|
||||
"SELECT * FROM DUAL";
|
||||
conn.execute(
|
||||
sql,
|
||||
['Redwood city', 'Sydney', 'Shenzhen'],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 3);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function doverify1(cb) {
|
||||
var sql = "select content from nodb_tab_ia1 order by id";
|
||||
conn.execute(
|
||||
sql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.deepEqual(
|
||||
result.rows,
|
||||
[ [ 'Redwood city' ], [ 'Sydney' ]]
|
||||
);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function doverify2(cb) {
|
||||
var sql = "select content from nodb_tab_ia2 order by id";
|
||||
conn.execute(
|
||||
sql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.deepEqual(
|
||||
result.rows,
|
||||
[ [ 'Shenzhen' ]]
|
||||
);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
dropTab1,
|
||||
dropTab2
|
||||
], done);
|
||||
it('158.3 inserts into multiple tables', async function() {
|
||||
await makeTab1();
|
||||
await makeTab2();
|
||||
|
||||
let sql = "INSERT ALL \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (100, :a) \n" +
|
||||
" INTO nodb_tab_ia1 (id, content) VALUES (200, :b) \n" +
|
||||
" INTO nodb_tab_ia2 (id, content) VALUES (300, :c) \n" +
|
||||
"SELECT * FROM DUAL";
|
||||
let result = await conn.execute(
|
||||
sql,
|
||||
['Redwood city', 'Sydney', 'Shenzhen']
|
||||
);
|
||||
assert.strictEqual(result.rowsAffected, 3);
|
||||
|
||||
sql = "select content from nodb_tab_ia1 order by id";
|
||||
result = await conn.execute(sql);
|
||||
assert.deepStrictEqual(
|
||||
result.rows,
|
||||
[ [ 'Redwood city' ], [ 'Sydney' ]]
|
||||
);
|
||||
|
||||
sql = "select content from nodb_tab_ia2 order by id";
|
||||
result = await conn.execute(sql);
|
||||
assert.deepStrictEqual(
|
||||
result.rows,
|
||||
[ [ 'Shenzhen' ]]
|
||||
);
|
||||
|
||||
//Drop the tables
|
||||
sql = "DROP TABLE nodb_tab_ia1 PURGE";
|
||||
await conn.execute(sql);
|
||||
sql = "DROP TABLE nodb_tab_ia2 PURGE";
|
||||
await conn.execute(sql);
|
||||
}); // 158.3
|
||||
|
||||
var makeTab1 = function(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_tab_ia1 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_tab_ia1 ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content VARCHAR2(100) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
conn.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
const makeTab1 = async function() {
|
||||
const proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_tab_ia1 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_tab_ia1 ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content VARCHAR2(100) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
await conn.execute(proc);
|
||||
}; // makeTab1
|
||||
|
||||
var dropTab1 = function(cb) {
|
||||
var sql = "DROP TABLE nodb_tab_ia1 PURGE";
|
||||
conn.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var makeTab2 = function(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_tab_ia2 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_tab_ia2 ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content VARCHAR2(50) " +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
conn.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var dropTab2 = function(cb) {
|
||||
var sql = "DROP TABLE nodb_tab_ia2 PURGE";
|
||||
conn.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
const makeTab2 = async function() {
|
||||
const proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_tab_ia2 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_tab_ia2 ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content VARCHAR2(50) " +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
await conn.execute(proc);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -105,4 +105,35 @@ describe('54. lobClose.js', function() {
|
|||
);
|
||||
}); // 54.4
|
||||
|
||||
it('54.5 temp LOBs should be freed in next rpc', async function() {
|
||||
const conn2 = await oracledb.getConnection(dbConfig);
|
||||
let tempLOBArray = [];
|
||||
const numLOBs = 20;
|
||||
const query = "select cache_lobs+nocache_lobs from v$temporary_lobs where sid = sys_context('USERENV','SID')";
|
||||
|
||||
// Create multiple temp LOB's
|
||||
for (let i = 0; i < numLOBs; i++) {
|
||||
tempLOBArray[i] = await conn2.createLob(oracledb.CLOB);
|
||||
}
|
||||
|
||||
// Check number of opened temp LOB's
|
||||
let result = await conn2.execute(query);
|
||||
let numTempLOBs = result.rows[0][0];
|
||||
assert.strictEqual(numTempLOBs, numLOBs);
|
||||
|
||||
// Destroy multiple temp LOB's
|
||||
for (let i = 0; i < numLOBs; i++) {
|
||||
await new Promise((resolve) => {
|
||||
tempLOBArray[i].once('close', resolve);
|
||||
tempLOBArray[i].destroy();
|
||||
});
|
||||
}
|
||||
|
||||
// temp LOB's should be freed on roundtrip (like execute) as piggybacks are sent for closing temp LOB's
|
||||
result = await conn2.execute(query);
|
||||
numTempLOBs = result.rows[0][0];
|
||||
assert.strictEqual(numTempLOBs, 0);
|
||||
await conn2.close();
|
||||
}); // 54.5
|
||||
|
||||
});
|
||||
|
|
|
@ -38,7 +38,6 @@ const assert = require('assert');
|
|||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('132. longrawProcedureBind_in.js', function() {
|
||||
|
||||
|
@ -228,7 +227,7 @@ describe('132. longrawProcedureBind_in.js', function() {
|
|||
if (expected == null) {
|
||||
assert.strictEqual(result.rows[0][1], expected);
|
||||
} else {
|
||||
assist.compare2Buffers(result.rows[0][1], expected);
|
||||
assert.deepStrictEqual(result.rows[0][1], expected);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ const assert = require('assert');
|
|||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('133. longrawProcedureBind_inout.js', function() {
|
||||
|
||||
|
@ -182,7 +181,7 @@ describe('133. longrawProcedureBind_inout.js', function() {
|
|||
if (expectedBuf == null) {
|
||||
assert.strictEqual(result.outBinds.c, expectedBuf);
|
||||
} else {
|
||||
assist.compare2Buffers(result.outBinds.c, expectedBuf);
|
||||
assert.deepStrictEqual(result.outBinds.c, expectedBuf);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -204,7 +203,7 @@ describe('133. longrawProcedureBind_inout.js', function() {
|
|||
if (expectedBuf == null) {
|
||||
assert.strictEqual(result.outBinds.c, expectedBuf);
|
||||
} else {
|
||||
assist.compare2Buffers(result.outBinds.c, expectedBuf);
|
||||
assert.deepStrictEqual(result.outBinds.c, expectedBuf);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -37,7 +37,6 @@ const assert = require('assert');
|
|||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('134. longrawProcedureBind_out.js', function() {
|
||||
|
||||
|
@ -214,7 +213,7 @@ describe('134. longrawProcedureBind_out.js', function() {
|
|||
if (expectedBuf == null) {
|
||||
assert.strictEqual(result.outBinds.c, expectedBuf);
|
||||
} else {
|
||||
assist.compare2Buffers(result.outBinds.c, expectedBuf);
|
||||
assert.deepStrictEqual(result.outBinds.c, expectedBuf);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
273
test/maxRows.js
273
test/maxRows.js
|
@ -32,192 +32,121 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('157. maxRows.js', function() {
|
||||
|
||||
let connection = null;
|
||||
var totalAmount = 107;
|
||||
let totalAmount = 107;
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function createTab(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_tab_conn_emp2 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_tab_conn_emp2 ( \n" +
|
||||
" id NUMBER NOT NULL, \n" +
|
||||
" name VARCHAR2(20) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
let proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_tab_conn_emp2 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_tab_conn_emp2 ( \n" +
|
||||
" id NUMBER NOT NULL, \n" +
|
||||
" name VARCHAR2(20) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
await connection.execute(proc);
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function insertData(cb) {
|
||||
var proc = "DECLARE \n" +
|
||||
" x NUMBER := 0; \n" +
|
||||
" n VARCHAR2(20); \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1..107 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO nodb_tab_conn_emp2 VALUES (x, n); \n" +
|
||||
" END LOOP; \n" +
|
||||
"END; ";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
proc = "DECLARE \n" +
|
||||
" x NUMBER := 0; \n" +
|
||||
" n VARCHAR2(20); \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1..107 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO nodb_tab_conn_emp2 VALUES (x, n); \n" +
|
||||
" END LOOP; \n" +
|
||||
"END; ";
|
||||
await connection.execute(proc);
|
||||
}); // before()
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_tab_conn_emp2 PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
await connection.execute("DROP TABLE nodb_tab_conn_emp2 PURGE");
|
||||
await connection.close();
|
||||
}); // after()
|
||||
|
||||
// restore oracledb.maxRows to its default value
|
||||
afterEach(function(done) {
|
||||
var defaultValue = 0;
|
||||
afterEach(function() {
|
||||
let defaultValue = 0;
|
||||
oracledb.maxRows = defaultValue;
|
||||
done();
|
||||
});
|
||||
|
||||
var verifyRows = function(rows, amount) {
|
||||
for (var i = 0; i < amount; i++) {
|
||||
should.strictEqual(rows[i][0], (i + 1));
|
||||
should.strictEqual(rows[i][1], ("staff " + String(i + 1)));
|
||||
let verifyRows = function(rows, amount) {
|
||||
for (let i = 0; i < amount; i++) {
|
||||
assert.strictEqual(rows[i][0], (i + 1));
|
||||
assert.strictEqual(rows[i][1], ("staff " + String(i + 1)));
|
||||
}
|
||||
};
|
||||
|
||||
var sqlQuery = "SELECT * FROM nodb_tab_conn_emp2 ORDER BY id";
|
||||
let sqlQuery = "SELECT * FROM nodb_tab_conn_emp2 ORDER BY id";
|
||||
|
||||
it('157.1 Default maxRows == 0, which means unlimited', function(done) {
|
||||
should.strictEqual(oracledb.maxRows, 0);
|
||||
it('157.1 Default maxRows == 0, which means unlimited', async function() {
|
||||
assert.strictEqual(oracledb.maxRows, 0);
|
||||
|
||||
connection.execute(
|
||||
sqlQuery,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
should.strictEqual(result.rows.length, totalAmount);
|
||||
verifyRows(result.rows, totalAmount);
|
||||
done();
|
||||
}
|
||||
);
|
||||
const result = await connection.execute(sqlQuery);
|
||||
assert(result);
|
||||
assert.strictEqual(result.rows.length, totalAmount);
|
||||
verifyRows(result.rows, totalAmount);
|
||||
});
|
||||
|
||||
it("157.2 specify the value at execution", function(done) {
|
||||
var fetchAmount = 25;
|
||||
connection.execute(
|
||||
it("157.2 specify the value at execution", async function() {
|
||||
let fetchAmount = 25;
|
||||
const result = await connection.execute(
|
||||
sqlQuery,
|
||||
{},
|
||||
{ maxRows: fetchAmount },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
should.strictEqual(result.rows.length, fetchAmount);
|
||||
verifyRows(result.rows, fetchAmount);
|
||||
done();
|
||||
}
|
||||
{ maxRows: fetchAmount }
|
||||
);
|
||||
assert(result);
|
||||
assert.strictEqual(result.rows.length, fetchAmount);
|
||||
verifyRows(result.rows, fetchAmount);
|
||||
});
|
||||
|
||||
it('157.3 equals to the total amount of rows', function(done) {
|
||||
connection.execute(
|
||||
it('157.3 equals to the total amount of rows', async function() {
|
||||
const result = await connection.execute(
|
||||
sqlQuery,
|
||||
{},
|
||||
{ maxRows: totalAmount },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
should.strictEqual(result.rows.length, totalAmount);
|
||||
verifyRows(result.rows, totalAmount);
|
||||
done();
|
||||
}
|
||||
{ maxRows: totalAmount }
|
||||
);
|
||||
assert(result);
|
||||
assert.strictEqual(result.rows.length, totalAmount);
|
||||
verifyRows(result.rows, totalAmount);
|
||||
});
|
||||
|
||||
it('157.4 cannot set it to be a negative number', async function() {
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await connection.execute(sqlQuery, {}, { maxRows: -5 });
|
||||
},
|
||||
// NJS-007: invalid value for "maxRows" in parameter 3
|
||||
/NJS-007:/
|
||||
);
|
||||
});
|
||||
|
||||
it('157.4 cannot set it to be a negative number', function(done) {
|
||||
connection.execute(
|
||||
sqlQuery,
|
||||
{},
|
||||
{ maxRows: -5 },
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.not.exist(result);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-007: invalid value for "maxRows" in parameter 3'
|
||||
);
|
||||
done();
|
||||
}
|
||||
);
|
||||
it('157.5 sets it to be large value', async function() {
|
||||
const result = await connection.execute(sqlQuery, {}, { maxRows: 500000 });
|
||||
assert(result);
|
||||
verifyRows(result.rows, totalAmount);
|
||||
});
|
||||
|
||||
it('157.5 sets it to be large value', function(done) {
|
||||
connection.execute(
|
||||
sqlQuery,
|
||||
{},
|
||||
{ maxRows: 500000 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
verifyRows(result.rows, totalAmount);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
it('157.6 shows 12c new way to limit the number of records fetched by queries', async function() {
|
||||
|
||||
it('157.6 shows 12c new way to limit the number of records fetched by queries', function(done) {
|
||||
|
||||
var myoffset = 2; // number of rows to skip
|
||||
var mymaxnumrows = 6; // number of rows to fetch
|
||||
var sql = "SELECT * FROM nodb_tab_conn_emp2 ORDER BY id";
|
||||
let myoffset = 2; // number of rows to skip
|
||||
let mymaxnumrows = 6; // number of rows to fetch
|
||||
let sql = "SELECT * FROM nodb_tab_conn_emp2 ORDER BY id";
|
||||
|
||||
if (connection.oracleServerVersion >= 1201000000) {
|
||||
// 12c row-limiting syntax
|
||||
|
@ -229,47 +158,29 @@ describe('157. maxRows.js', function() {
|
|||
+ "WHERE ROWNUM <= :maxnumrows + :offset) WHERE MY_RNUM > :offset";
|
||||
}
|
||||
|
||||
connection.execute(
|
||||
const result = await connection.execute(
|
||||
sql,
|
||||
{ offset: myoffset, maxnumrows: mymaxnumrows },
|
||||
{ maxRows: 150 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rows.length).should.eql(mymaxnumrows);
|
||||
done();
|
||||
}
|
||||
{ maxRows: 150 }
|
||||
);
|
||||
assert.strictEqual(result.rows.length, mymaxnumrows);
|
||||
}); // 157.6
|
||||
|
||||
it('157.7 oracledb.maxRows > 0 && oracledb.maxRows < totalAmount', function(done) {
|
||||
it('157.7 oracledb.maxRows > 0 && oracledb.maxRows < totalAmount', async function() {
|
||||
|
||||
var testValue = 100;
|
||||
let testValue = 100;
|
||||
oracledb.maxRows = testValue;
|
||||
connection.execute(
|
||||
sqlQuery,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var expectedAmount = testValue;
|
||||
verifyRows(result.rows, expectedAmount);
|
||||
done();
|
||||
}
|
||||
);
|
||||
let result = await connection.execute(sqlQuery);
|
||||
let expectedAmount = testValue;
|
||||
verifyRows(result.rows, expectedAmount);
|
||||
}); // 157.7
|
||||
|
||||
it('157.8 oracledb.maxRows > 0, execute() with maxRows=0', function(done) {
|
||||
it('157.8 oracledb.maxRows > 0, execute() with maxRows=0', async function() {
|
||||
|
||||
oracledb.maxRows = 100;
|
||||
connection.execute(
|
||||
sqlQuery,
|
||||
{},
|
||||
{ maxRows: 0 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var expectedAmount = totalAmount;
|
||||
verifyRows(result.rows, expectedAmount);
|
||||
done();
|
||||
}
|
||||
);
|
||||
let result = await connection.execute(sqlQuery, {}, { maxRows: 0 });
|
||||
let expectedAmount = totalAmount;
|
||||
verifyRows(result.rows, expectedAmount);
|
||||
}); // 157.8
|
||||
|
||||
});
|
||||
|
|
|
@ -26,191 +26,99 @@
|
|||
* 68. multipleLobInsertion.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing external authentication functionality.
|
||||
*
|
||||
* Note that enabling the externalAuth feature requires configuration on the
|
||||
* database besides setting "externalAuth" attribute to be true. Please refer
|
||||
* to API documentation about configuration.
|
||||
* https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#extauth
|
||||
* Testing multiple insertions of Large Objects including BLOB and CLOB
|
||||
*
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const fs = require('fs');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('68. multipleLobInsertion.js', function() {
|
||||
|
||||
let connection = null;
|
||||
before(function(done) {
|
||||
before(async function() {
|
||||
|
||||
async.series([
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createTabBLOB(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_multi_blob PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_multi_blob ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" b1 BLOB, \n" +
|
||||
" b2 BLOB, \n" +
|
||||
" b3 BLOB, \n" +
|
||||
" b4 BLOB, \n" +
|
||||
" b5 BLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createTabCLOB(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_multi_clob PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_multi_clob ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" c1 CLOB, \n" +
|
||||
" c2 CLOB, \n" +
|
||||
" c3 CLOB, \n" +
|
||||
" c4 CLOB, \n" +
|
||||
" c5 CLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
// create the BLOB table
|
||||
let proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_multi_blob PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_multi_blob ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" b1 BLOB, \n" +
|
||||
" b2 BLOB, \n" +
|
||||
" b3 BLOB, \n" +
|
||||
" b4 BLOB, \n" +
|
||||
" b5 BLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
await connection.execute(proc);
|
||||
|
||||
// create the CLOB table
|
||||
proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_multi_clob PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_multi_clob ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" c1 CLOB, \n" +
|
||||
" c2 CLOB, \n" +
|
||||
" c3 CLOB, \n" +
|
||||
" c4 CLOB, \n" +
|
||||
" c5 CLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
await connection.execute(proc);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_multi_clob PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_multi_blob PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
await connection.execute("DROP TABLE nodb_multi_clob PURGE");
|
||||
await connection.execute("DROP TABLE nodb_multi_blob PURGE");
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
var lobInsert = function(sql, bindv, inFileName, cb) {
|
||||
|
||||
connection.execute(
|
||||
sql,
|
||||
bindv,
|
||||
{ autoCommit: false },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var lobArr = new Array();
|
||||
|
||||
// put lobbv1..5 to lobArr
|
||||
for (var item in result.outBinds) {
|
||||
lobArr.push(result.outBinds[item][0]);
|
||||
}
|
||||
|
||||
async.eachSeries(
|
||||
lobArr,
|
||||
function(lob, callback) {
|
||||
var inStream = fs.createReadStream(inFileName);
|
||||
|
||||
inStream.pipe(lob);
|
||||
|
||||
// one task completes
|
||||
lob.on('finish', function() {
|
||||
return callback();
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
return callback(err);
|
||||
});
|
||||
|
||||
inStream.on('error', function(err) {
|
||||
return callback(err);
|
||||
});
|
||||
},
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
connection.commit(function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
});
|
||||
}
|
||||
); // async.eachSeries
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
const lobInsert = async function(sql, bindv, inFileName) {
|
||||
const result = await connection.execute(sql, bindv, { autoCommit: false });
|
||||
for (let item in result.outBinds) {
|
||||
const lob = result.outBinds[item][0];
|
||||
const inStream = fs.createReadStream(inFileName);
|
||||
await new Promise((resolve, reject) => {
|
||||
inStream.on('error', reject);
|
||||
lob.on('error', reject);
|
||||
lob.on('finish', resolve);
|
||||
inStream.pipe(lob);
|
||||
});
|
||||
}
|
||||
await connection.commit();
|
||||
};
|
||||
|
||||
it('68.1 inserts multiple BLOBs', function(done) {
|
||||
it('68.1 inserts multiple BLOBs', async function() {
|
||||
|
||||
var sql = "insert into nodb_multi_blob values(1, " +
|
||||
const sql = "insert into nodb_multi_blob values(1, " +
|
||||
" EMPTY_BLOB(), EMPTY_BLOB(), EMPTY_BLOB(), EMPTY_BLOB(), EMPTY_BLOB() ) " +
|
||||
" returning b1, b2, b3, b4, b5 into :lobbv1, :lobbv2, :lobbv3, :lobbv4, :lobbv5";
|
||||
|
||||
var bindvars = {
|
||||
const bindvars = {
|
||||
lobbv1: { type: oracledb.BLOB, dir: oracledb.BIND_OUT },
|
||||
lobbv2: { type: oracledb.BLOB, dir: oracledb.BIND_OUT },
|
||||
lobbv3: { type: oracledb.BLOB, dir: oracledb.BIND_OUT },
|
||||
|
@ -218,19 +126,19 @@ describe('68. multipleLobInsertion.js', function() {
|
|||
lobbv5: { type: oracledb.BLOB, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
|
||||
var inFileName = './test/fuzzydinosaur.jpg';
|
||||
const inFileName = './test/fuzzydinosaur.jpg';
|
||||
|
||||
lobInsert(sql, bindvars, inFileName, done);
|
||||
await lobInsert(sql, bindvars, inFileName);
|
||||
|
||||
}); // 68.1
|
||||
|
||||
it('68.2 inserts multiple CLOBs', function(done) {
|
||||
it('68.2 inserts multiple CLOBs', async function() {
|
||||
|
||||
var sql = "insert into nodb_multi_clob values(1, " +
|
||||
const sql = "insert into nodb_multi_clob values(1, " +
|
||||
" EMPTY_CLOB(), EMPTY_CLOB(), EMPTY_CLOB(), EMPTY_CLOB(), EMPTY_CLOB() ) " +
|
||||
" returning c1, c2, c3, c4, c5 into :lobbv1, :lobbv2, :lobbv3, :lobbv4, :lobbv5";
|
||||
|
||||
var bindvars = {
|
||||
const bindvars = {
|
||||
lobbv1: { type: oracledb.CLOB, dir: oracledb.BIND_OUT },
|
||||
lobbv2: { type: oracledb.CLOB, dir: oracledb.BIND_OUT },
|
||||
lobbv3: { type: oracledb.CLOB, dir: oracledb.BIND_OUT },
|
||||
|
@ -238,10 +146,10 @@ describe('68. multipleLobInsertion.js', function() {
|
|||
lobbv5: { type: oracledb.CLOB, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
|
||||
var inFileName = './test/clobexample.txt';
|
||||
const inFileName = './test/clobexample.txt';
|
||||
|
||||
lobInsert(sql, bindvars, inFileName, done);
|
||||
await lobInsert(sql, bindvars, inFileName);
|
||||
|
||||
});
|
||||
}); // 68.2
|
||||
|
||||
});
|
||||
|
|
|
@ -252,3 +252,4 @@ spec:
|
|||
- test/aq4.js
|
||||
- test/procAndFuncs.js
|
||||
- test/poolTimeout.js
|
||||
- test/binding_buffer_string.js
|
||||
|
|
|
@ -32,138 +32,86 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('15. resultsetToStream.js', function() {
|
||||
|
||||
let connection = null;
|
||||
var rowsAmount = 217;
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createTab(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_rs2stream PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_rs2stream ( \n" +
|
||||
" employees_id NUMBER, \n" +
|
||||
" employees_name VARCHAR2(20), \n" +
|
||||
" employees_history CLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
const rowsAmount = 217;
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function insertRows(cb) {
|
||||
var proc = "DECLARE \n" +
|
||||
" x NUMBER := 0; \n" +
|
||||
" n VARCHAR2(20); \n" +
|
||||
" clobData CLOB; \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1..217 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO nodb_rs2stream VALUES (x, n, EMPTY_CLOB()) RETURNING employees_history INTO clobData; \n" +
|
||||
" DBMS_LOB.WRITE(clobData, 20, 1, '12345678901234567890'); \n" +
|
||||
" END LOOP; \n" +
|
||||
"end; ";
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
let proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_rs2stream PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_rs2stream ( \n" +
|
||||
" employees_id NUMBER, \n" +
|
||||
" employees_name VARCHAR2(20), \n" +
|
||||
" employees_history CLOB \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
await connection.execute(proc);
|
||||
|
||||
proc = "DECLARE \n" +
|
||||
" x NUMBER := 0; \n" +
|
||||
" n VARCHAR2(20); \n" +
|
||||
" clobData CLOB; \n" +
|
||||
"BEGIN \n" +
|
||||
" FOR i IN 1..217 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO nodb_rs2stream VALUES (x, n, EMPTY_CLOB()) RETURNING employees_history INTO clobData; \n" +
|
||||
" DBMS_LOB.WRITE(clobData, 20, 1, '12345678901234567890'); \n" +
|
||||
" END LOOP; \n" +
|
||||
"end; ";
|
||||
await connection.execute(proc);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_rs2stream PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
after(async function() {
|
||||
await connection.execute("DROP TABLE nodb_rs2stream PURGE");
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
describe('15.1 Testing ResultSet.toQueryStream', function() {
|
||||
it('15.1.1 should allow resultsets to be converted to streams', function(done) {
|
||||
connection.execute(
|
||||
|
||||
it('15.1.1 should allow resultsets to be converted to streams', async function() {
|
||||
const result = await connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var stream = result.outBinds.cursor.toQueryStream();
|
||||
|
||||
stream.on('error', function(error) {
|
||||
console.log(error);
|
||||
should.fail(error, null, 'Error event should not be triggered');
|
||||
});
|
||||
|
||||
var counter = 0;
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
counter++;
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
should.equal(counter, rowsAmount);
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
const stream = result.outBinds.cursor.toQueryStream();
|
||||
let counter = 0;
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.on('error', reject);
|
||||
stream.on('end', stream.destroy);
|
||||
stream.on('close', resolve);
|
||||
stream.on('data', function(data) {
|
||||
assert(data);
|
||||
counter++;
|
||||
});
|
||||
});
|
||||
assert.strictEqual(counter, rowsAmount);
|
||||
}); // 15.1.1
|
||||
|
||||
}); // 15.1
|
||||
|
||||
describe('15.2 Testing ResultSet/QueryStream conversion errors', function() {
|
||||
|
||||
it('15.2.1 should prevent conversion to stream after getRow is invoked', async function() {
|
||||
const sql = `
|
||||
begin
|
||||
|
@ -175,15 +123,13 @@ describe('15. resultsetToStream.js', function() {
|
|||
const result = await connection.execute(sql, binds);
|
||||
const cursor = result.outBinds.cursor;
|
||||
await cursor.getRow();
|
||||
try {
|
||||
const stream = cursor.toQueryStream();
|
||||
should.not.exist(stream);
|
||||
} catch (err) {
|
||||
(err.message).should.startWith('NJS-041:');
|
||||
await assert.throws(
|
||||
() => cursor.toQueryStream(),
|
||||
// NJS-041: cannot convert to stream after invoking methods
|
||||
}
|
||||
/NJS-041:/
|
||||
);
|
||||
await cursor.close();
|
||||
});
|
||||
}); // 15.2.1
|
||||
|
||||
it('15.2.2 should prevent conversion to stream after getRows is invoked', async function() {
|
||||
const sql = `
|
||||
|
@ -196,14 +142,13 @@ describe('15. resultsetToStream.js', function() {
|
|||
const result = await connection.execute(sql, binds);
|
||||
const cursor = result.outBinds.cursor;
|
||||
await cursor.getRows(5);
|
||||
try {
|
||||
const stream = cursor.toQueryStream();
|
||||
should.not.exist(stream);
|
||||
} catch (err) {
|
||||
(err.message).should.startWith('NJS-041:');
|
||||
}
|
||||
assert.throws(
|
||||
() => cursor.toQueryStream(),
|
||||
// NJS-041: cannot convert to stream after invoking methods
|
||||
/NJS-041:/
|
||||
);
|
||||
await cursor.close();
|
||||
});
|
||||
}); // 15.2.2
|
||||
|
||||
it('15.2.3 should prevent conversion to stream after close is invoked', async function() {
|
||||
const sql = `
|
||||
|
@ -216,126 +161,86 @@ describe('15. resultsetToStream.js', function() {
|
|||
const result = await connection.execute(sql, binds);
|
||||
const cursor = result.outBinds.cursor;
|
||||
await cursor.close();
|
||||
try {
|
||||
const stream = cursor.toQueryStream();
|
||||
should.not.exist(stream);
|
||||
} catch (err) {
|
||||
(err.message).should.startWith('NJS-041:');
|
||||
}
|
||||
});
|
||||
|
||||
it('15.2.4 should prevent invoking getRow after conversion to stream', function(done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var cursor = result.outBinds.cursor;
|
||||
var stream = cursor.toQueryStream();
|
||||
|
||||
stream.on('close', done);
|
||||
stream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
cursor.getRow(function(err) {
|
||||
(err.message).should.startWith('NJS-042:');
|
||||
// NJS-042: cannot invoke methods after converting to stream
|
||||
stream.destroy();
|
||||
});
|
||||
}
|
||||
assert.throws(
|
||||
() => cursor.toQueryStream(),
|
||||
// NJS-041: cannot convert to stream after invoking methods
|
||||
/NJS-041:/
|
||||
);
|
||||
});
|
||||
}); // 15.2.3
|
||||
|
||||
it('15.2.5 should prevent invoking getRows after conversion to stream', function(done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var cursor = result.outBinds.cursor;
|
||||
var stream = cursor.toQueryStream();
|
||||
|
||||
stream.on('close', done);
|
||||
stream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
cursor.getRows(5, function(err) {
|
||||
(err.message).should.startWith('NJS-042:');
|
||||
stream.destroy();
|
||||
});
|
||||
}
|
||||
it('15.2.4 should prevent invoking getRow after conversion to stream', async function() {
|
||||
const sql = `
|
||||
begin
|
||||
open :cursor for select employees_name from nodb_rs2stream;
|
||||
end;`;
|
||||
const binds = {
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
};
|
||||
const result = await connection.execute(sql, binds);
|
||||
const cursor = result.outBinds.cursor;
|
||||
const stream = cursor.toQueryStream();
|
||||
await assert.rejects(
|
||||
async () => await cursor.getRow(),
|
||||
// NJS-042: cannot invoke methods after converting to stream
|
||||
/NJS-042:/
|
||||
);
|
||||
});
|
||||
stream.destroy();
|
||||
}); // 15.2.4
|
||||
|
||||
it('15.2.6 should prevent invoking close after conversion to stream', function(done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var cursor = result.outBinds.cursor;
|
||||
var stream = cursor.toQueryStream();
|
||||
|
||||
stream.on('close', done);
|
||||
stream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
cursor.close(function(err) {
|
||||
(err.message).should.startWith('NJS-042:');
|
||||
stream.destroy();
|
||||
});
|
||||
}
|
||||
it('15.2.5 should prevent invoking getRows after conversion to stream', async function() {
|
||||
const sql = `
|
||||
begin
|
||||
open :cursor for select employees_name from nodb_rs2stream;
|
||||
end;`;
|
||||
const binds = {
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
};
|
||||
const result = await connection.execute(sql, binds);
|
||||
const cursor = result.outBinds.cursor;
|
||||
const stream = cursor.toQueryStream();
|
||||
await assert.rejects(
|
||||
async () => await cursor.getRows(5),
|
||||
// NJS-042: cannot invoke methods after converting to stream
|
||||
/NJS-042:/
|
||||
);
|
||||
});
|
||||
stream.destroy();
|
||||
}); // 15.2.5
|
||||
|
||||
it('15.2.7 should prevent calling toQueryStream more than once', function(done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var cursor = result.outBinds.cursor;
|
||||
|
||||
// First conversion to stream
|
||||
var stream = cursor.toQueryStream();
|
||||
|
||||
stream.on('close', done);
|
||||
stream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
try {
|
||||
// Second conversion to stream
|
||||
stream = cursor.toQueryStream();
|
||||
} catch (err) {
|
||||
(err.message).should.startWith('NJS-043:');
|
||||
stream.destroy();
|
||||
}
|
||||
}
|
||||
it('15.2.6 should prevent invoking close after conversion to stream', async function() {
|
||||
const sql = `
|
||||
begin
|
||||
open :cursor for select employees_name from nodb_rs2stream;
|
||||
end;`;
|
||||
const binds = {
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
};
|
||||
const result = await connection.execute(sql, binds);
|
||||
const cursor = result.outBinds.cursor;
|
||||
const stream = cursor.toQueryStream();
|
||||
await assert.rejects(
|
||||
async () => await cursor.close(),
|
||||
// NJS-042: cannot invoke methods after converting to stream
|
||||
/NJS-042:/
|
||||
);
|
||||
stream.destroy();
|
||||
}); // 15.2.6
|
||||
|
||||
it('15.2.7 should prevent calling toQueryStream more than once', async function() {
|
||||
const sql = `
|
||||
begin
|
||||
open :cursor for select employees_name from nodb_rs2stream;
|
||||
end;`;
|
||||
const binds = {
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
};
|
||||
const result = await connection.execute(sql, binds);
|
||||
const cursor = result.outBinds.cursor;
|
||||
const stream = cursor.toQueryStream();
|
||||
assert.throws(
|
||||
() => cursor.toQueryStream(),
|
||||
/NJS-043:/
|
||||
);
|
||||
stream.destroy();
|
||||
}); // 15.2.7
|
||||
|
||||
}); // 15.2
|
||||
|
|
97
test/sql.js
97
test/sql.js
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -30,9 +30,6 @@
|
|||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
|
||||
const sql = exports;
|
||||
module.exports = sql;
|
||||
|
||||
|
@ -71,95 +68,3 @@ sql.createTable = function(tableName, dataType) {
|
|||
END;`;
|
||||
return sql;
|
||||
};
|
||||
|
||||
sql.createAllTable = function(tableName, dataTypeArray) {
|
||||
let sql = `BEGIN
|
||||
DECLARE
|
||||
e_table_missing EXCEPTION;
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942);
|
||||
BEGIN
|
||||
EXECUTE IMMEDIATE ('DROP TABLE ` + tableName + ` PURGE' );
|
||||
EXCEPTION
|
||||
WHEN e_table_missing
|
||||
THEN NULL;
|
||||
END;
|
||||
EXECUTE IMMEDIATE ( '
|
||||
CREATE TABLE ` + tableName + ` (
|
||||
id NUMBER, `;
|
||||
|
||||
async.eachSeries(dataTypeArray, function(element, cb) {
|
||||
const index = dataTypeArray.indexOf(element);
|
||||
const length = dataTypeArray.length;
|
||||
const col_name = "col_" + (index + 1);
|
||||
let col_type = element;
|
||||
let isLast;
|
||||
|
||||
if (col_type === "CHAR") {
|
||||
element = element + "(2000)";
|
||||
}
|
||||
if (col_type === "NCHAR") {
|
||||
element = element + "(1000)";
|
||||
}
|
||||
if (col_type === "VARCHAR2") {
|
||||
element = element + "(4000)";
|
||||
}
|
||||
if (col_type === "RAW") {
|
||||
element = element + "(2000)";
|
||||
}
|
||||
isLast = (index == (length - 1)) ? true : false;
|
||||
sql = appendSql(sql, col_name, element, isLast);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
sql = sql +
|
||||
` )
|
||||
');
|
||||
END;`;
|
||||
return sql;
|
||||
};
|
||||
|
||||
sql.executeSql = function(connection, sql, bindVar, option, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
option,
|
||||
function(err) {
|
||||
if (err) {
|
||||
let stack = new Error().stack;
|
||||
console.error(err);
|
||||
console.error(stack);
|
||||
}
|
||||
should.not.exist(err);
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
sql.createRowid = function(connection, rowid_type, object_number, relative_fno, block_number, row_number, callback) {
|
||||
// Parameter Description
|
||||
// rowid_type Type (restricted or extended), set the rowid_type parameter to 0 for a restricted ROWID. Set it to 1 to create an extended ROWID.
|
||||
// If you specify rowid_type as 0, then the required object_number parameter is ignored, and ROWID_CREATE returns a restricted ROWID.
|
||||
// object_number The data object number for the ROWID. For a restricted ROWID, use the ROWID_OBJECT_UNDEFINED constant.
|
||||
// relative_fno The relative file number for the ROWID.
|
||||
// block_number The block number for the ROWID.
|
||||
// row_number The row number for the ROWID.
|
||||
let myRowid = "";
|
||||
connection.execute(
|
||||
"select DBMS_ROWID.ROWID_CREATE(" + rowid_type + ", " + object_number + ", " + relative_fno + ", " + block_number + ", " + row_number + ") create_rowid from dual",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
myRowid = result.rows[0][0];
|
||||
callback(myRowid);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const appendSql = function(sql, col_name, col_type, isLast) {
|
||||
if (isLast === true) {
|
||||
sql = sql + " " + col_name + " " + col_type + " \n";
|
||||
} else {
|
||||
sql = sql + " " + col_name + " " + col_type + ", \n";
|
||||
}
|
||||
return sql;
|
||||
};
|
||||
|
|
172
test/sqlClone.js
172
test/sqlClone.js
|
@ -1,172 +0,0 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This software is dual-licensed to you under the Universal Permissive License
|
||||
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
|
||||
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
|
||||
* either license.
|
||||
*
|
||||
* If you elect to accept the software under the Apache License, Version 2.0,
|
||||
* the following applies:
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://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.
|
||||
*
|
||||
* NAME
|
||||
* sql.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* generate sql
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
|
||||
const sql = exports;
|
||||
module.exports = sql;
|
||||
|
||||
sql.createTable = function(tableName, dataType) {
|
||||
let element = dataType;
|
||||
|
||||
if (dataType === "CHAR") {
|
||||
element = element + "(1000)";
|
||||
}
|
||||
if (dataType === "NCHAR") {
|
||||
element = element + "(1000)";
|
||||
}
|
||||
if (dataType === "VARCHAR2") {
|
||||
element = element + "(1000)";
|
||||
}
|
||||
if (dataType === "RAW") {
|
||||
element = element + "(1000)";
|
||||
}
|
||||
|
||||
const sql = `BEGIN
|
||||
DECLARE
|
||||
e_table_missing EXCEPTION;
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942);
|
||||
BEGIN
|
||||
EXECUTE IMMEDIATE ('DROP TABLE ` + tableName + ` PURGE' );
|
||||
EXCEPTION
|
||||
WHEN e_table_missing
|
||||
THEN NULL;
|
||||
END;
|
||||
EXECUTE IMMEDIATE ( '
|
||||
CREATE TABLE ` + tableName + ` (
|
||||
id NUMBER,
|
||||
content ` + element + `
|
||||
)
|
||||
');
|
||||
END;`;
|
||||
return sql;
|
||||
};
|
||||
|
||||
sql.createAllTable = function(tableName, dataTypeArray) {
|
||||
let sql = `BEGIN
|
||||
DECLARE
|
||||
e_table_missing EXCEPTION;
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942);
|
||||
BEGIN
|
||||
EXECUTE IMMEDIATE ('DROP TABLE ` + tableName + ` PURGE' );
|
||||
EXCEPTION
|
||||
WHEN e_table_missing
|
||||
THEN NULL;
|
||||
END;
|
||||
EXECUTE IMMEDIATE ( '
|
||||
CREATE TABLE ` + tableName + ` (
|
||||
id NUMBER, `;
|
||||
|
||||
async.eachSeries(dataTypeArray, function(element, cb) {
|
||||
const index = dataTypeArray.indexOf(element);
|
||||
const length = dataTypeArray.length;
|
||||
const col_name = "col_" + (index + 1);
|
||||
let col_type = element;
|
||||
let isLast;
|
||||
|
||||
if (col_type === "CHAR") {
|
||||
element = element + "(2000)";
|
||||
}
|
||||
if (col_type === "NCHAR") {
|
||||
element = element + "(1000)";
|
||||
}
|
||||
if (col_type === "VARCHAR2") {
|
||||
element = element + "(4000)";
|
||||
}
|
||||
if (col_type === "RAW") {
|
||||
element = element + "(2000)";
|
||||
}
|
||||
isLast = (index == (length - 1)) ? true : false;
|
||||
sql = appendSql(sql, col_name, element, isLast);
|
||||
cb();
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
sql = sql +
|
||||
` )
|
||||
');
|
||||
END;`;
|
||||
return sql;
|
||||
};
|
||||
|
||||
// sql.executeSql = function(connection, sql, bindVar, option, callback) {
|
||||
// connection.execute(sql,
|
||||
// bindVar,
|
||||
// option,
|
||||
// function(err) {
|
||||
// if (err) {
|
||||
// let stack = new Error().stack;
|
||||
// console.error(err);
|
||||
// console.error(stack);
|
||||
// }
|
||||
// should.not.exist(err);
|
||||
// callback(err);
|
||||
// }
|
||||
// );
|
||||
// };
|
||||
|
||||
sql.executeSql = async function(connection, sql, bindVar, option) {
|
||||
try {
|
||||
await connection.execute(sql, bindVar, option);
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
}
|
||||
};
|
||||
|
||||
sql.createRowid = function(connection, rowid_type, object_number, relative_fno, block_number, row_number, callback) {
|
||||
// Parameter Description
|
||||
// rowid_type Type (restricted or extended), set the rowid_type parameter to 0 for a restricted ROWID. Set it to 1 to create an extended ROWID.
|
||||
// If you specify rowid_type as 0, then the required object_number parameter is ignored, and ROWID_CREATE returns a restricted ROWID.
|
||||
// object_number The data object number for the ROWID. For a restricted ROWID, use the ROWID_OBJECT_UNDEFINED constant.
|
||||
// relative_fno The relative file number for the ROWID.
|
||||
// block_number The block number for the ROWID.
|
||||
// row_number The row number for the ROWID.
|
||||
let myRowid = "";
|
||||
connection.execute(
|
||||
"select DBMS_ROWID.ROWID_CREATE(" + rowid_type + ", " + object_number + ", " + relative_fno + ", " + block_number + ", " + row_number + ") create_rowid from dual",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
myRowid = result.rows[0][0];
|
||||
callback(myRowid);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const appendSql = function(sql, col_name, col_type, isLast) {
|
||||
if (isLast === true) {
|
||||
sql = sql + " " + col_name + " " + col_type + " \n";
|
||||
} else {
|
||||
sql = sql + " " + col_name + " " + col_type + ", \n";
|
||||
}
|
||||
return sql;
|
||||
};
|
|
@ -34,36 +34,26 @@
|
|||
"use strict";
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('64. sqlWithWarnings.js', function() {
|
||||
|
||||
let connection = null;
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
}
|
||||
);
|
||||
before('get one connection', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after('release connection', async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe('64.1 test case offered by GitHub user', function() {
|
||||
|
||||
var tableName = "nodb_aggregate";
|
||||
const tableName = "nodb_aggregate";
|
||||
|
||||
before('prepare table', function(done) {
|
||||
var sqlCreateTab =
|
||||
before('prepare table', async function() {
|
||||
const sqlCreateTab =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_missing EXCEPTION; " +
|
||||
|
@ -81,86 +71,39 @@ describe('64. sqlWithWarnings.js', function() {
|
|||
" '); " +
|
||||
"END; ";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlCreateTab,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO " + tableName + " VALUES(1)",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO " + tableName + " VALUES(null)",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.commit(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
await connection.execute(sqlCreateTab);
|
||||
await connection.execute("INSERT INTO " + tableName + " VALUES(1)");
|
||||
await connection.execute("INSERT INTO " + tableName + " VALUES(null)");
|
||||
await connection.commit();
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
after(async function() {
|
||||
await connection.execute("DROP TABLE " + tableName + " PURGE");
|
||||
});
|
||||
|
||||
it('64.1.1 Executes an aggregate query which causes warnings', function(done) {
|
||||
connection.execute(
|
||||
it('64.1.1 Executes an aggregate query which causes warnings', async function() {
|
||||
await connection.execute(
|
||||
"SELECT MAX(NUM_COL) AS NUM_COL FROM " + tableName,
|
||||
[],
|
||||
{ maxRows: 1 },
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
{ maxRows: 1 }
|
||||
);
|
||||
});
|
||||
}); // 64.1.1
|
||||
|
||||
}); // 64.1
|
||||
|
||||
describe('64.2 PL/SQL - Success With Info', function() {
|
||||
|
||||
var plsqlWithWarning =
|
||||
const plsqlWithWarning =
|
||||
" CREATE OR REPLACE PROCEDURE get_emp_rs_inout " +
|
||||
" (p_in IN NUMBER, p_out OUT SYS_REFCURSOR ) AS " +
|
||||
" BEGIN " +
|
||||
" OPEN p_out FOR SELECT * FROM nodb_sql_emp " +
|
||||
" END;";
|
||||
|
||||
it('64.2.1 Execute SQL Statement to create PLSQL procedure with warnings', function(done) {
|
||||
connection.should.be.an.Object;
|
||||
connection.execute (
|
||||
plsqlWithWarning,
|
||||
function(err) {
|
||||
should.not.exist (err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
it('64.2.1 Execute SQL Statement to create PLSQL procedure with warnings', async function() {
|
||||
assert.strictEqual(typeof connection, "object");
|
||||
await connection.execute (plsqlWithWarning);
|
||||
}); // 64.2.1
|
||||
|
||||
}); // 64.2
|
||||
|
||||
|
|
Loading…
Reference in New Issue