From f3a1ea518dd4bce8bef1847456f0419491029240 Mon Sep 17 00:00:00 2001 From: Sharad Chandran R Date: Tue, 14 Mar 2023 12:10:28 +0530 Subject: [PATCH] Further test refactoring --- test/binding_defaultBindIn.js | 1 - test/binding_functionBindOut.js | 2 - test/callTimeout.js | 6 +- test/fetchClobAsString2.js | 3064 ++++++++++++------------------- test/testsUtil.js | 3 +- test/urowidDMLBindAsString2.js | 1 - 6 files changed, 1206 insertions(+), 1871 deletions(-) diff --git a/test/binding_defaultBindIn.js b/test/binding_defaultBindIn.js index 8e05279a..4d6d95b8 100644 --- a/test/binding_defaultBindIn.js +++ b/test/binding_defaultBindIn.js @@ -109,7 +109,6 @@ describe('100.binding_defaultBindIn.js', function() { "END ; "; let sqlRun = "BEGIN :output := " + fun_name + " (:i, :c); END;"; let proc_drop = "DROP FUNCTION " + fun_name; - // console.log(proc); await connection.execute(createTable); await connection.execute(proc); diff --git a/test/binding_functionBindOut.js b/test/binding_functionBindOut.js index 9ea6e46a..2b8ae8e1 100644 --- a/test/binding_functionBindOut.js +++ b/test/binding_functionBindOut.js @@ -98,7 +98,6 @@ describe('97.binding_functionBindOut.js', function() { "END ; "; let sqlRun = "BEGIN :output := " + fun_name + " (:i, :c); END;"; let proc_drop = "DROP FUNCTION " + fun_name; - // console.log(proc); let inserted = getInsertVal(dbColType, nullBind); let insertSql = "insert into " + table_name + " (id, content) values (:c1, :c2)"; await executeSql(createTable); @@ -107,7 +106,6 @@ describe('97.binding_functionBindOut.js', function() { c2: { val: inserted[0], type: inserted[1], dir: oracledb.BIND_IN } }; - // console.log(insertSql); await connection.execute(insertSql, bind); await executeSql(proc); diff --git a/test/callTimeout.js b/test/callTimeout.js index 6df47021..ca535886 100644 --- a/test/callTimeout.js +++ b/test/callTimeout.js @@ -104,7 +104,7 @@ describe('222. callTimeout.js', function() { () => { conn.callTimeout = TIME_OUT; }, - /NJS-004: invalid value for property callTimeout/ + /NJS-004:/ ); }); // 222.4 @@ -115,7 +115,7 @@ describe('222. callTimeout.js', function() { () => { conn.callTimeout = TIME_OUT; }, - /NJS-004: invalid value for property callTimeout/ + /NJS-004:/ ); }); @@ -126,7 +126,7 @@ describe('222. callTimeout.js', function() { () => { conn.callTimeout = TIME_OUT; }, - /NJS-004: invalid value for property callTimeout/ + /NJS-004:/ ); }); diff --git a/test/fetchClobAsString2.js b/test/fetchClobAsString2.js index d3943198..67d15b47 100644 --- a/test/fetchClobAsString2.js +++ b/test/fetchClobAsString2.js @@ -35,8 +35,7 @@ 'use strict'; const oracledb = require('oracledb'); -const async = require('async'); -const should = require('should'); +const assert = require('assert'); const fsPromises = require('fs/promises'); const dbConfig = require('./dbconfig.js'); const random = require('./random.js'); @@ -78,2204 +77,1543 @@ describe('85. fetchClobAsString2.js', function() { await fsPromises.unlink(inFileName); }); // after - const insertIntoClobTable1 = function(id, content, callback) { - if (content == "EMPTY_CLOB") { - connection.execute( + const insertIntoClobTable1 = async function(id, content) { + let result; + if (content === "EMPTY_CLOB") { + result = await connection.execute( "INSERT INTO nodb_clob1 VALUES (:ID, EMPTY_CLOB())", - [ id ], - function(err, result) { - should.not.exist(err); - should.strictEqual(result.rowsAffected, 1); - callback(); - } + [ id ] ); + assert.strictEqual(result.rowsAffected, 1); } else { - connection.execute( + result = await connection.execute( "INSERT INTO nodb_clob1 VALUES (:ID, :C)", { ID : { val : id }, C : { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING } - }, - function(err, result) { - should.not.exist(err); - should.strictEqual(result.rowsAffected, 1); - callback(); } ); + assert.strictEqual(result.rowsAffected, 1); } }; - var updateClobTable1 = function(id, content, callback) { - connection.execute( + const updateClobTable1 = async function(id, content) { + let result = await connection.execute( "UPDATE nodb_clob1 set C = :C where ID = :ID", - { ID: id, C: content }, - function(err, result) { - should.not.exist(err); - should.strictEqual(result.rowsAffected, 1); - callback(); - } + { ID: id, C: content } ); + assert.strictEqual(result.rowsAffected, 1); }; - // compare fetch result - var compareClientFetchResult = function(err, resultVal, specialStr, content, contentLength) { - should.not.exist(err); - compareStrings(resultVal, specialStr, content, contentLength); - }; - - // compare two string - var compareStrings = function(resultVal, specialStr, content, contentLength) { - var specialStrLen = specialStr.length; - var resultLen = resultVal.length; - should.equal(resultLen, contentLength); - should.strictEqual(resultVal.substring(0, specialStrLen), specialStr); - should.strictEqual(resultVal.substring(resultLen - specialStrLen, resultLen), specialStr); + // compare fetch result (two strings) + const compareStrings = function(resultVal, specialStr, content, contentLength) { + let specialStrLen = specialStr.length; + let resultLen = resultVal.length; + assert.equal(resultLen, contentLength); + assert.strictEqual(resultVal.substring(0, specialStrLen), specialStr); + assert.strictEqual(resultVal.substring(resultLen - specialStrLen, resultLen), specialStr); }; describe('85.1 fetch CLOB columns by setting fetchInfo option', function() { - before('Create table and populate', function(done) { - connection.execute( - proc_create_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + before('Create table and populate', async function() { + await connection.execute(proc_create_table1); }); // before - after('drop table', function(done) { - connection.execute( - drop_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + after('drop table', async function() { + await connection.execute(drop_table1); }); // after insertID = 0; - var insertAndFetch = function(id, specialStr, insertContent, insertContentLength, callback) { - async.series([ - function(cb) { - insertIntoClobTable1(id, insertContent, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = :id", - { id : id }, - { - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - var resultVal = result.rows[0][1]; - if (specialStr === null) { - should.not.exist(err); - should.equal(resultVal, null); - } else { - compareClientFetchResult(err, resultVal, specialStr, insertContent, insertContentLength); - } - cb(); - } - ); + const insertAndFetch = async function(id, specialStr, insertContent, insertContentLength) { + await insertIntoClobTable1(id, insertContent); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = :id", + { id : id }, + { + fetchInfo : { C : { type : oracledb.STRING } } } - ], callback); + ); + let resultVal = result.rows[0][1]; + if (specialStr === null) { + assert.equal(resultVal, null); + } else { + compareStrings(resultVal, specialStr, insertContent, insertContentLength); + } }; - it('85.1.1 works with NULL value', function(done) { - var id = insertID++; - var content = null; + it('85.1.1 works with NULL value', async function() { + let id = insertID++; + let content = null; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.1.1 - it('85.1.2 works with empty String', function(done) { - var id = insertID++; - var content = ""; + it('85.1.2 works with empty String', async function() { + let id = insertID++; + let content = ""; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.1.2 - it('85.1.3 works with small value', function(done) { - var id = insertID++; - var specialStr = '85.1.3'; - var contentLength = 20; - var content = random.getRandomString(contentLength, specialStr); + it('85.1.3 works with small value', async function() { + let id = insertID++; + let specialStr = '85.1.3'; + let contentLength = 20; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.1.3 - it('85.1.4 works with (64K - 1) value', function(done) { - var id = insertID++; - var specialStr = '85.1.4'; - var contentLength = 65535; - var content = random.getRandomString(contentLength, specialStr); + it('85.1.4 works with (64K - 1) value', async function() { + let id = insertID++; + let specialStr = '85.1.4'; + let contentLength = 65535; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.1.4 - it('85.1.5 works with (64K + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.1.5'; - var contentLength = 65537; - var content = random.getRandomString(contentLength, specialStr); + it('85.1.5 works with (64K + 1) value', async function() { + let id = insertID++; + let specialStr = '85.1.5'; + let contentLength = 65537; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.1.5 - it('85.1.6 works with (1MB + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.1.6'; - var contentLength = 1048577; // 1MB + 1 - var content = random.getRandomString(contentLength, specialStr); + it('85.1.6 works with (1MB + 1) value', async function() { + let id = insertID++; + let specialStr = '85.1.6'; + let contentLength = 1048577; // 1MB + 1 + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.1.6 - it('85.1.7 works with dbms_lob.substr()', function(done) { - var id = insertID++; - var specialStr = '85.1.7'; - var contentLength = 200; - var specialStrLength = specialStr.length; - var content = random.getRandomString(contentLength, specialStr); + it('85.1.7 works with dbms_lob.substr()', async function() { + let id = insertID++; + let specialStr = '85.1.7'; + let contentLength = 200; + let specialStrLength = specialStr.length; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", - { id : id }, - { - fetchInfo : { C1 : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - // console.log(result); - var resultVal = result.rows[0][0]; - compareClientFetchResult(err, resultVal, specialStr, specialStr, specialStrLength); - cb(); - } - ); + await insertIntoClobTable1(id, content); + + let result = await connection.execute( + "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", + { id : id }, + { + fetchInfo : { C1 : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0][0]; + compareStrings(resultVal, specialStr, content, specialStrLength); }); // 85.1.7 - it('85.1.8 works with EMPTY_CLOB()', function(done) { - var id = insertID++; - var content = "EMPTY_CLOB"; + it('85.1.8 works with EMPTY_CLOB()', async function() { + let id = insertID++; + let content = "EMPTY_CLOB"; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.1.8 - it('85.1.9 fetch multiple CLOB rows as String', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.1.9_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.1.9_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.1.9 fetch multiple CLOB rows as String', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.1.9_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.1.9_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, - { }, - { - fetchInfo : { C : { type : oracledb.STRING } } - }, - 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[1][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, + { }, + { + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = result.rows[1][1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); }); // 85.1.9 - it('85.1.10 fetch the same CLOB column multiple times', function(done) { - var id = insertID++; - var specialStr = '85.1.10'; - var contentLength = 200; - var content = random.getRandomString(contentLength, specialStr); + it('85.1.10 fetch the same CLOB column multiple times', async function() { + let id = insertID++; + let specialStr = '85.1.10'; + let contentLength = 200; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, - { }, - { - fetchInfo : { - C1 : { type : oracledb.STRING }, - C2 : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - resultVal = result.rows[0][2]; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - cb(); - } - ); + await insertIntoClobTable1(id, content); + + let result = await connection.execute( + "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, + { }, + { + fetchInfo : { + C1 : { type : oracledb.STRING }, + C2 : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr, content, contentLength); + resultVal = result.rows[0][2]; + compareStrings(resultVal, specialStr, content, contentLength); }); // 85.1.10 - it('85.1.11 works with update statement', function(done) { - var id = insertID++; - var specialStr_1 = '85.1.11_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var specialStr_2 = '85.1.11_2'; - var contentLength_2 = 208; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.1.11 works with update statement', async function() { + let id = insertID++; + let specialStr_1 = '85.1.11_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let specialStr_2 = '85.1.11_2'; + let contentLength_2 = 208; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertAndFetch(id, specialStr_1, content_1, contentLength_1, cb); - }, - function(cb) { - updateClobTable1(id, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id, - { }, - { - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - cb(); - } - ); + await insertAndFetch(id, specialStr_1, content_1, contentLength_1); + await updateClobTable1(id, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id, + { }, + { + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); - }); // 85.1.8 + ); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + }); // 85.1.11 - it('85.1.12 works with setting oracledb.maxRows < actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.1.12_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.1.12_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.1.12 works with setting oracledb.maxRows < actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.1.12_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.1.12_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 1; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - result.rows.length.should.eql(1); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - oracledb.maxRows = maxRowsBak; - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + assert.strictEqual(result.rows.length, 1); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + oracledb.maxRows = maxRowsBak; }); // 85.1.12 - it('85.1.13 works with setting oracledb.maxRows > actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.1.13_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.1.13_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.1.13 works with setting oracledb.maxRows > actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.1.13_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.1.13_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 10; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - result.rows.length.should.eql(2); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = result.rows[1][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - oracledb.maxRows = maxRowsBak; - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + assert.strictEqual(result.rows.length, 2); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = result.rows[1][1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + oracledb.maxRows = maxRowsBak; }); // 85.1.13 - it('85.1.14 works with connection.queryStream()', function(done) { - var id = insertID++; - var specialStr = '85.1.14'; - var contentLength = 200; - var content = random.getRandomString(contentLength, specialStr); + it('85.1.14 works with connection.queryStream()', async function() { + let id = insertID++; + let specialStr = '85.1.14'; + let contentLength = 200; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id; - var stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); - stream.on('error', function(error) { - should.fail(error, null, 'Error event should not be triggered'); - }); + await insertIntoClobTable1(id, content); - var counter = 0; - stream.on('data', function(data) { - should.exist(data); - var result = data[1]; - should.strictEqual(typeof result, "string"); - compareStrings(result, specialStr, content, contentLength); - counter++; - }); - - stream.on('end', function() { - should.equal(counter, 1); - stream.destroy(); - }); - - stream.on('close', function() { - cb(); - }); - } - ], done); + let sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id; + let stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); + let counter = 0; + await new Promise((resolve, reject) => { + stream.on('error', reject); + stream.on('data', (data) => { + const result = data[1]; + assert.strictEqual(typeof result, "string"); + compareStrings(result, specialStr, content, contentLength); + counter++; + }); + stream.on('end', stream.destroy); + stream.on('close', resolve); + }); + assert.strictEqual(counter, 1); }); // 85.1.14 - it('85.1.15 works with connection.queryStream() and oracledb.maxRows > actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.1.15_1'; - var contentLength_1 = 26; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.1.15_2'; - var contentLength_2 = 30; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.1.15 works with connection.queryStream() and oracledb.maxRows > actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.1.15_1'; + let contentLength_1 = 26; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.1.15_2'; + let contentLength_2 = 30; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 20; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - var sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2; - var stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); - 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); - var result = data[1]; - should.strictEqual(typeof result, "string"); - counter++; - if (counter == 1) { - compareStrings(result, specialStr_1, content_1, contentLength_1); - } else { - compareStrings(result, specialStr_2, content_2, contentLength_2); - } - }); - - stream.on('end', function() { - should.equal(counter, 2); - oracledb.maxRows = maxRowsBak; - stream.destroy(); - }); - - stream.on('close', function() { - cb(); - }); - } - ], done); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + const sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2; + const stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); + let counter = 0; + await new Promise((resolve, reject) => { + stream.on('error', reject); + stream.on('data', (data) => { + const result = data[1]; + assert.strictEqual(typeof result, "string"); + counter++; + if (counter === 1) { + compareStrings(result, specialStr_1, content_1, contentLength_1); + } else { + compareStrings(result, specialStr_2, content_2, contentLength_2); + } + }); + stream.on('end', stream.destroy); + stream.on('close', resolve); + }); + assert.strictEqual(counter, 2); + oracledb.maxRows = maxRowsBak; }); // 85.1.15 - it('85.1.16 works with connection.queryStream() and oracledb.maxRows = actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.1.16_1'; - var contentLength_1 = 26; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.1.16_2'; - var contentLength_2 = 30; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.1.16 works with connection.queryStream() and oracledb.maxRows = actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.1.16_1'; + let contentLength_1 = 26; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.1.16_2'; + let contentLength_2 = 30; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 2; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - var sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2; - var stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); - stream.on('error', function(error) { - should.fail(error, null, 'Error event should not be triggered'); - }); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); - var counter = 0; - stream.on('data', function(data) { - should.exist(data); - var result = data[1]; - should.strictEqual(typeof result, "string"); - counter++; - if (counter == 1) { - compareStrings(result, specialStr_1, content_1, contentLength_1); - } else { - compareStrings(result, specialStr_2, content_2, contentLength_2); - } - }); - - stream.on('end', function() { - should.equal(counter, 2); - oracledb.maxRows = maxRowsBak; - stream.destroy(); - }); - - stream.on('close', function() { - cb(); - }); - } - ], done); + const sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2; + const stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); + let counter = 0; + await new Promise((resolve, reject) => { + stream.on('error', reject); + stream.on('data', (data) => { + const result = data[1]; + assert.strictEqual(typeof result, "string"); + counter++; + if (counter === 1) { + compareStrings(result, specialStr_1, content_1, contentLength_1); + } else { + compareStrings(result, specialStr_2, content_2, contentLength_2); + } + }); + stream.on('end', stream.destroy); + stream.on('close', resolve); + }); + assert.strictEqual(counter, 2); + oracledb.maxRows = maxRowsBak; }); // 85.1.16 - it('85.1.17 works with connection.queryStream() and oracledb.maxRows < actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.1.17_1'; - var contentLength_1 = 26; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.1.17_2'; - var contentLength_2 = 30; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.1.17 works with connection.queryStream() and oracledb.maxRows < actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.1.17_1'; + let contentLength_1 = 26; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.1.17_2'; + let contentLength_2 = 30; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 1; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - var sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2; - var stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); - 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); - var result = data[1]; - should.strictEqual(typeof result, "string"); - counter++; - if (counter == 1) { - compareStrings(result, specialStr_1, content_1, contentLength_1); - } else { - compareStrings(result, specialStr_2, content_2, contentLength_2); - } - }); - - stream.on('end', function() { - should.equal(counter, 2); - oracledb.maxRows = maxRowsBak; - stream.destroy(); - }); - - stream.on('close', function() { - cb(); - }); - } - ], done); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + const sql = "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2; + const stream = connection.queryStream(sql, {}, { fetchInfo : { C : { type : oracledb.STRING } } }); + let counter = 0; + await new Promise((resolve, reject) => { + stream.on('error', reject); + stream.on('data', (data) => { + const result = data[1]; + assert.strictEqual(typeof result, "string"); + counter++; + if (counter === 1) { + compareStrings(result, specialStr_1, content_1, contentLength_1); + } else { + compareStrings(result, specialStr_2, content_2, contentLength_2); + } + }); + stream.on('end', stream.destroy); + stream.on('close', resolve); + }); + assert.strictEqual(counter, 2); + oracledb.maxRows = maxRowsBak; }); // 85.1.17 - it('85.1.18 works with REF CURSOR', function(done) { - var id = insertID++; - var specialStr = '85.1.18'; - var contentLength = 26; - var content = random.getRandomString(contentLength, specialStr); + it('85.1.18 works with REF CURSOR', async function() { + let id = insertID++; + let specialStr = '85.1.18'; + let contentLength = 26; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + + await insertIntoClobTable1(id, content); + + const ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + "AS \n" + "BEGIN \n" + " OPEN clob_cursor FOR \n" + " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + "END;"; - connection.execute( - ref_proc, - function(err) { - should.not.exist(err); - cb(); - } - ); - }, - function(cb) { - var sql = "BEGIN nodb_ref(:c); END;"; - var bindVar = { - c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }; - connection.execute( - sql, - bindVar, - { fetchInfo : { C : { type : oracledb.STRING } } }, - function(err, result) { - result.outBinds.c.getRows(3, function(err, rows) { - var resultVal = rows[0][0]; - should.strictEqual(typeof resultVal, 'string'); - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - result.outBinds.c.close(cb); - }); - } - ); - }, - function(cb) { - var ref_proc_drop = "DROP PROCEDURE nodb_ref"; - connection.execute( - ref_proc_drop, - function(err) { - should.not.exist(err); - cb(); - } - ); - } - ], done); - }); + await connection.execute(ref_proc); + let sql = "BEGIN nodb_ref(:c); END;"; + let bindVar = { + c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }; + let result = await connection.execute( + sql, + bindVar, + { fetchInfo : { C : { type : oracledb.STRING } } } + ); + let rows = await result.outBinds.c.getRows(3); + let resultVal = rows[0][0]; + assert.strictEqual(typeof resultVal, 'string'); + compareStrings(resultVal, specialStr, content, contentLength); + await result.outBinds.c.close(); + + const ref_proc_drop = "DROP PROCEDURE nodb_ref"; + await connection.execute(ref_proc_drop); + }); // 85.1.18 }); // 85.1 describe('85.2 fetch CLOB columns by setting fetchInfo option and outFormat = oracledb.OUT_FORMAT_OBJECT', function() { - before('Create table and populate', function(done) { - connection.execute( - proc_create_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + before('Create table and populate', async function() { + await connection.execute(proc_create_table1); }); // before - after('drop table', function(done) { - connection.execute( - drop_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + after('drop table', async function() { + await connection.execute(drop_table1); }); // after insertID = 0; - var insertAndFetch = function(id, specialStr, insertContent, insertContentLength, callback) { - async.series([ - function(cb) { - insertIntoClobTable1(id, insertContent, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = :id", - { id : id }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - var resultVal = result.rows[0].C; - if (specialStr === null) { - should.not.exist(err); - should.equal(resultVal, null); - } else { - compareClientFetchResult(err, resultVal, specialStr, insertContent, insertContentLength); - } - cb(); - } - ); + let insertAndFetch = async function(id, specialStr, insertContent, insertContentLength) { + await insertIntoClobTable1(id, insertContent); + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = :id", + { id : id }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } } } - ], callback); + ); + let resultVal = result.rows[0].C; + if (specialStr === null) { + assert.equal(resultVal, null); + } else { + compareStrings(resultVal, specialStr, insertContent, insertContentLength); + } }; - it('85.2.1 works with NULL value', function(done) { - var id = insertID++; - var content = null; + it('85.2.1 works with NULL value', async function() { + let id = insertID++; + let content = null; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.2.1 - it('85.2.2 works with empty buffer', function(done) { - var id = insertID++; - var content = ""; + it('85.2.2 works with empty buffer', async function() { + let id = insertID++; + let content = ""; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.2.2 - it('85.2.3 works with small value', function(done) { - var id = insertID++; - var specialStr = '85.2.3'; - var contentLength = 20; - var content = random.getRandomString(contentLength, specialStr); + it('85.2.3 works with small value', async function() { + let id = insertID++; + let specialStr = '85.2.3'; + let contentLength = 20; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.2.3 - it('85.2.4 works with (64K - 1) value', function(done) { - var id = insertID++; - var specialStr = '85.2.4'; - var contentLength = 65535; - var content = random.getRandomString(contentLength, specialStr); + it('85.2.4 works with (64K - 1) value', async function() { + let id = insertID++; + let specialStr = '85.2.4'; + let contentLength = 65535; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.2.4 - it('85.2.5 works with (64K + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.2.5'; - var contentLength = 65537; - var content = random.getRandomString(contentLength, specialStr); + it('85.2.5 works with (64K + 1) value', async function() { + let id = insertID++; + let specialStr = '85.2.5'; + let contentLength = 65537; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.2.5 - it('85.2.6 works with (1MB + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.2.6'; - var contentLength = 1048577; // 1MB + 1 - var content = random.getRandomString(contentLength, specialStr); + it('85.2.6 works with (1MB + 1) value', async function() { + let id = insertID++; + let specialStr = '85.2.6'; + let contentLength = 1048577; // 1MB + 1 + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.2.6 - it('85.2.7 works with dbms_lob.substr()', function(done) { - var id = insertID++; - var specialStr = '85.2.7'; - var contentLength = 200; - var specialStrLength = specialStr.length; - var content = random.getRandomString(contentLength, specialStr); + it('85.2.7 works with dbms_lob.substr()', async function() { + let id = insertID++; + let specialStr = '85.2.7'; + let contentLength = 200; + let specialStrLength = specialStr.length; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", - { id : id }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C1 : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0].C1; - compareClientFetchResult(err, resultVal, specialStr, specialStr, specialStrLength); - cb(); - } - ); + await insertIntoClobTable1(id, content); + + let result = await connection.execute( + "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", + { id : id }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C1 : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0].C1; + compareStrings(resultVal, specialStr, specialStr, specialStrLength); }); // 85.2.7 - it('85.2.8 works with EMPTY_CLOB()', function(done) { - var id = insertID++; - var content = "EMPTY_CLOB"; + it('85.2.8 works with EMPTY_CLOB()', async function() { + let id = insertID++; + let content = "EMPTY_CLOB"; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.2.8 - it('85.2.9 fetch multiple CLOB rows as String', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.2.9_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.2.9_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.2.9 fetch multiple CLOB rows as String', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.2.9_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.2.9_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0].C; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = result.rows[1].C; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0].C; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = result.rows[1].C; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); }); // 85.2.9 - it('85.2.10 fetch the same CLOB column multiple times', function(done) { - var id = insertID++; - var specialStr = '85.2.10'; - var contentLength = 200; - var content = random.getRandomString(contentLength, specialStr); + it('85.2.10 fetch the same CLOB column multiple times', async function() { + let id = insertID++; + let specialStr = '85.2.10'; + let contentLength = 200; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { - C1 : { type : oracledb.STRING }, - C2 : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0].C1; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - resultVal = result.rows[0].C2; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - cb(); - } - ); + await insertIntoClobTable1(id, content); + + let result = await connection.execute( + "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { + C1 : { type : oracledb.STRING }, + C2 : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0].C1; + compareStrings(resultVal, specialStr, content, contentLength); + resultVal = result.rows[0].C2; + compareStrings(resultVal, specialStr, content, contentLength); }); // 85.2.10 - it('85.2.11 works with update statement', function(done) { - var id = insertID++; - var specialStr_1 = '85.2.11_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var specialStr_2 = '85.2.11_2'; - var contentLength_2 = 202; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.2.11 works with update statement', async function() { + let id = insertID++; + let specialStr_1 = '85.2.11_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let specialStr_2 = '85.2.11_2'; + let contentLength_2 = 202; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertAndFetch(id, specialStr_1, content_1, contentLength_1, cb); - }, - function(cb) { - updateClobTable1(id, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0].C; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - cb(); - } - ); + await insertAndFetch(id, specialStr_1, content_1, contentLength_1); + await updateClobTable1(id, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0].C; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); }); // 85.2.11 - it('85.2.12 works with setting oracledb.maxRows < actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.2.12_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.2.12_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.2.12 works with setting oracledb.maxRows < actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.2.12_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.2.12_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 1; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - result.rows.length.should.eql(1); - var resultVal = result.rows[0].C; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - oracledb.maxRows = maxRowsBak; - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + assert.strictEqual(result.rows.length, 1); + let resultVal = result.rows[0].C; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + oracledb.maxRows = maxRowsBak; }); // 85.2.12 - it('85.2.13 works with setting oracledb.maxRows > actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.2.13_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.2.13_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.2.13 works with setting oracledb.maxRows > actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.2.13_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.2.13_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 10; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0].C; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = result.rows[1].C; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - result.rows.length.should.eql(2); - oracledb.maxRows = maxRowsBak; - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0].C; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = result.rows[1].C; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + assert.strictEqual(result.rows.length, 2); + oracledb.maxRows = maxRowsBak; }); // 85.2.13 - it('85.2.14 works with REF CURSOR', function(done) { - var id = insertID++; - var specialStr = '85.2.14'; - var contentLength = 26; - var content = random.getRandomString(contentLength, specialStr); + it('85.2.14 works with REF CURSOR', async function() { + let id = insertID++; + let specialStr = '85.2.14'; + let contentLength = 26; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + - "AS \n" + - "BEGIN \n" + - " OPEN clob_cursor FOR \n" + - " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + - "END;"; - connection.execute( - ref_proc, - function(err) { - should.not.exist(err); - cb(); - } - ); - }, - function(cb) { - var sql = "BEGIN nodb_ref(:c); END;"; - var bindVar = { - c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }; - connection.execute( - sql, - bindVar, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - result.outBinds.c.getRows(3, function(err, rows) { - var resultVal = rows[0].C; - should.strictEqual(typeof resultVal, 'string'); - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - result.outBinds.c.close(cb); - }); - } - ); - }, - function(cb) { - var ref_proc_drop = "DROP PROCEDURE nodb_ref"; - connection.execute( - ref_proc_drop, - function(err) { - should.not.exist(err); - cb(); - } - ); + await insertIntoClobTable1(id, content); + let ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + + "AS \n" + + "BEGIN \n" + + " OPEN clob_cursor FOR \n" + + " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + + "END;"; + await connection.execute(ref_proc); + + let sql = "BEGIN nodb_ref(:c); END;"; + let bindVar = { + c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }; + let result = await connection.execute( + sql, + bindVar, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); - }); + ); + let rows = await result.outBinds.c.getRows(3); + let resultVal = rows[0].C; + assert.strictEqual(typeof resultVal, 'string'); + compareStrings(resultVal, specialStr, content, contentLength); + await result.outBinds.c.close(); + }); //85.2.14 }); // 85.2 describe('85.3 fetch CLOB columns by setting fetchInfo option, outFormat = oracledb.OUT_FORMAT_OBJECT and resultSet = true', function() { - before('Create table and populate', function(done) { - connection.execute( - proc_create_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + before('Create table and populate', async function() { + await connection.execute(proc_create_table1); }); // before - after('drop table', function(done) { - connection.execute( - drop_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + after('drop table', async function() { + await connection.execute(drop_table1); }); // after insertID = 0; - var insertAndFetch = function(id, specialStr, insertContent, insertContentLength, callback) { - async.series([ - function(cb) { - insertIntoClobTable1(id, insertContent, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = :id", - { id : id }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - var resultVal; - resultVal = row.C; - if (specialStr === null) { - should.not.exist(err); - should.equal(resultVal, null); - } else { - compareClientFetchResult(err, resultVal, specialStr, insertContent, insertContentLength, callback); - } - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + let insertAndFetch = async function(id, specialStr, insertContent, insertContentLength) { + await insertIntoClobTable1(id, insertContent); + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = :id", + { id : id }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], callback); + ); + let row = await result.resultSet.getRow(); + let resultVal = row.C; + + if (specialStr === null) { + assert.equal(resultVal, null); + } else { + compareStrings(resultVal, specialStr, insertContent, insertContentLength); + } + await result.resultSet.close(); }; - it('85.3.1 works with NULL value', function(done) { - var id = insertID++; - var content = null; + it('85.3.1 works with NULL value', async function() { + let id = insertID++; + let content = null; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.3.1 - it('85.3.2 works with empty buffer', function(done) { - var id = insertID++; - var content = ""; + it('85.3.2 works with empty buffer', async function() { + let id = insertID++; + let content = ""; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.3.2 - it('85.3.3 works with small value', function(done) { - var id = insertID++; - var specialStr = '85.3.3'; - var contentLength = 20; - var content = random.getRandomString(contentLength, specialStr); + it('85.3.3 works with small value', async function() { + let id = insertID++; + let specialStr = '85.3.3'; + let contentLength = 20; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.3.3 - it('85.3.4 works with (64K - 1) value', function(done) { - var id = insertID++; - var specialStr = '85.3.4'; - var contentLength = 65535; - var content = random.getRandomString(contentLength, specialStr); + it('85.3.4 works with (64K - 1) value', async function() { + let id = insertID++; + let specialStr = '85.3.4'; + let contentLength = 65535; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.3.4 - it('85.3.5 works with (64K + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.3.4'; - var contentLength = 65537; - var content = random.getRandomString(contentLength, specialStr); + it('85.3.5 works with (64K + 1) value', async function() { + let id = insertID++; + let specialStr = '85.3.4'; + let contentLength = 65537; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.3.5 - it('85.3.6 works with (1MB + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.3.6'; - var contentLength = 1048577; // 1MB + 1 - var content = random.getRandomString(contentLength, specialStr); + it('85.3.6 works with (1MB + 1) value', async function() { + let id = insertID++; + let specialStr = '85.3.6'; + let contentLength = 1048577; // 1MB + 1 + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.3.6 - it('85.3.7 works with dbms_lob.substr()', function(done) { - var id = insertID++; - var specialStr = '85.3.7'; - var contentLength = 200; - var specialStrLength = specialStr.length; - var content = random.getRandomString(contentLength, specialStr); + it('85.3.7 works with dbms_lob.substr()', async function() { + let id = insertID++; + let specialStr = '85.3.7'; + let contentLength = 200; + let specialStrLength = specialStr.length; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", - { id : id }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C1 : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - should.not.exist(err); - var resultVal = row.C1; - compareClientFetchResult(err, resultVal, specialStr, specialStr, specialStrLength); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id, content); + let result = await connection.execute( + "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", + { id : id }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C1 : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let row = await result.resultSet.getRow(); + let resultVal = row.C1; + compareStrings(resultVal, specialStr, specialStr, specialStrLength); + await result.resultSet.close(); }); // 85.3.7 - it('85.3.8 works with EMPTY_CLOB()', function(done) { - var id = insertID++; - var content = "EMPTY_CLOB"; + it('85.3.8 works with EMPTY_CLOB()', async function() { + let id = insertID++; + let content = "EMPTY_CLOB"; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.3.8 - it('85.3.9 fetch multiple CLOB rows as String', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.3.9_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.3.9_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.3.9 fetch multiple CLOB rows as String', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.3.9_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.3.9_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - var rowNumFetched = 2; - result.resultSet.getRows( - rowNumFetched, - function(err, row) { - should.not.exist(err); - var resultVal = row[0].C; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = row[1].C; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + + let rowNumFetched = 2; + let row = await result.resultSet.getRows(rowNumFetched); + let resultVal = row[0].C; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = row[1].C; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + await result.resultSet.close(); }); // 85.3.9 - it('85.3.10 fetch the same CLOB column multiple times', function(done) { - var id = insertID++; - var specialStr = '85.3.10'; - var contentLength = 200; - var content = random.getRandomString(contentLength, specialStr); + it('85.3.10 fetch the same CLOB column multiple times', async function() { + let id = insertID++; + let specialStr = '85.3.10'; + let contentLength = 200; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { - C1 : { type : oracledb.STRING }, - C2 : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - should.not.exist(err); - var resultVal = row.C1; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - resultVal = row.C2; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id, content); + + let result = await connection.execute( + "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { + C1 : { type : oracledb.STRING }, + C2 : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let row = await result.resultSet.getRow(); + let resultVal = row.C1; + compareStrings(resultVal, specialStr, content, contentLength); + resultVal = row.C2; + compareStrings(resultVal, specialStr, content, contentLength); + await result.resultSet.close(); }); // 85.3.10 - it('85.3.11 works with update statement', function(done) { - var id = insertID++; - var specialStr_1 = '85.3.11_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var specialStr_2 = '85.3.11_2'; - var contentLength_2 = 202; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.3.11 works with update statement', async function() { + let id = insertID++; + let specialStr_1 = '85.3.11_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let specialStr_2 = '85.3.11_2'; + let contentLength_2 = 202; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertAndFetch(id, specialStr_1, content_1, contentLength_1, cb); - }, - function(cb) { - updateClobTable1(id, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - should.not.exist(err); - var resultVal = row.C; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertAndFetch(id, specialStr_1, content_1, contentLength_1); + await updateClobTable1(id, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let row = await result.resultSet.getRow(); + let resultVal = row.C; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + await result.resultSet.close(); }); // 85.3.11 - it('85.3.12 works with setting oracledb.maxRows < actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.3.12_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.3.12_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.3.12 works with setting oracledb.maxRows < actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.3.12_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.3.12_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 1; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - var rowNumFetched = 2; - result.resultSet.getRows( - rowNumFetched, - function(err, row) { - should.not.exist(err); - should.equal(row.length, 2); - var resultVal = row[0].C; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = row[1].C; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - oracledb.maxRows = maxRowsBak; - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let rowNumFetched = 2; + let row = await result.resultSet.getRows(rowNumFetched); + assert.strictEqual(row.length, 2); + let resultVal = row[0].C; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = row[1].C; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + oracledb.maxRows = maxRowsBak; + await result.resultSet.close(); }); // 85.3.12 - it('85.3.13 works with setting oracledb.maxRows > actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.3.13_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.3.13_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.3.13 works with setting oracledb.maxRows > actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.3.13_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.3.13_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 10; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_OBJECT, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - var rowNumFetched = 2; - result.resultSet.getRows( - rowNumFetched, - function(err, row) { - should.not.exist(err); - should.equal(row.length, 2); - var resultVal = row[0].C; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = row[1].C; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - oracledb.maxRows = maxRowsBak; - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_OBJECT, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + + let rowNumFetched = 2; + let row = await result.resultSet.getRows(rowNumFetched); + assert.strictEqual(row.length, 2); + let resultVal = row[0].C; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = row[1].C; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + oracledb.maxRows = maxRowsBak; + await result.resultSet.close(); }); // 85.3.13 }); // 85.3 describe('85.4 fetch CLOB columns by setting fetchInfo option and outFormat = oracledb.OUT_FORMAT_ARRAY', function() { - before('Create table and populate', function(done) { - connection.execute( - proc_create_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + before('Create table and populate', async function() { + await connection.execute(proc_create_table1); }); // before - after('drop table', function(done) { - connection.execute( - drop_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + after('drop table', async function() { + await connection.execute(drop_table1); }); // after insertID = 0; - var insertAndFetch = function(id, specialStr, insertContent, insertContentLength, callback) { - async.series([ - function(cb) { - insertIntoClobTable1(id, insertContent, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = :id", - { id : id }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - var resultVal = result.rows[0][1]; - if (specialStr === null) { - should.not.exist(err); - should.equal(resultVal, null); - } else { - compareClientFetchResult(err, resultVal, specialStr, insertContent, insertContentLength); - } - cb(); - } - ); + let insertAndFetch = async function(id, specialStr, insertContent, insertContentLength) { + await insertIntoClobTable1(id, insertContent); + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = :id", + { id : id }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } } } - ], callback); + ); + let resultVal = result.rows[0][1]; + if (specialStr === null) { + assert.equal(resultVal, null); + } else { + compareStrings(resultVal, specialStr, insertContent, insertContentLength); + } }; - it('85.4.1 works with NULL value', function(done) { - var id = insertID++; - var content = null; + it('85.4.1 works with NULL value', async function() { + let id = insertID++; + let content = null; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.4.1 - it('85.4.2 works with empty String', function(done) { - var id = insertID++; - var content = ""; + it('85.4.2 works with empty String', async function() { + let id = insertID++; + let content = ""; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.4.2 - it('85.4.3 works with small value', function(done) { - var id = insertID++; - var specialStr = '85.4.3'; - var contentLength = 20; - var content = random.getRandomString(contentLength, specialStr); + it('85.4.3 works with small value', async function() { + let id = insertID++; + let specialStr = '85.4.3'; + let contentLength = 20; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.4.3 - it('85.4.4 works with (64K - 1) value', function(done) { - var id = insertID++; - var specialStr = '85.4.4'; - var contentLength = 65535; - var content = random.getRandomString(contentLength, specialStr); + it('85.4.4 works with (64K - 1) value', async function() { + let id = insertID++; + let specialStr = '85.4.4'; + let contentLength = 65535; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.4.4 - it('85.4.5 works with (64K + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.4.5'; - var contentLength = 65537; - var content = random.getRandomString(contentLength, specialStr); + it('85.4.5 works with (64K + 1) value', async function() { + let id = insertID++; + let specialStr = '85.4.5'; + let contentLength = 65537; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.4.5 - it('85.4.6 works with (1MB + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.4.6'; - var contentLength = 1048577; // 1MB + 1 - var content = random.getRandomString(contentLength, specialStr); + it('85.4.6 works with (1MB + 1) value', async function() { + let id = insertID++; + let specialStr = '85.4.6'; + let contentLength = 1048577; // 1MB + 1 + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.4.6 - it('85.4.7 works with dbms_lob.substr()', function(done) { - var id = insertID++; - var specialStr = '85.4.7'; - var contentLength = 200; - var specialStrLength = specialStr.length; - var content = random.getRandomString(contentLength, specialStr); + it('85.4.7 works with dbms_lob.substr()', async function() { + let id = insertID++; + let specialStr = '85.4.7'; + let contentLength = 200; + let specialStrLength = specialStr.length; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", - { id : id }, - { - fetchInfo : { C1 : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - // console.log(result); - var resultVal = result.rows[0][0]; - compareClientFetchResult(err, resultVal, specialStr, specialStr, specialStrLength); - cb(); - } - ); + await insertIntoClobTable1(id, content); + let result = await connection.execute( + "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", + { id : id }, + { + fetchInfo : { C1 : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0][0]; + compareStrings(resultVal, specialStr, specialStr, specialStrLength); }); // 85.4.7 - it('85.4.8 works with EMPTY_CLOB()', function(done) { - var id = insertID++; - var content = "EMPTY_CLOB"; + it('85.4.8 works with EMPTY_CLOB()', async function() { + let id = insertID++; + let content = "EMPTY_CLOB"; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.4.8 - it('85.4.9 fetch multiple CLOB rows as String', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.4.9_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.4.9_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.4.9 fetch multiple CLOB rows as String', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.4.9_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.4.9_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } } - }, - 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[1][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = result.rows[1][1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); }); // 85.4.9 - it('85.4.10 fetch the same CLOB column multiple times', function(done) { - var id = insertID++; - var specialStr = '85.4.10'; - var contentLength = 200; - var content = random.getRandomString(contentLength, specialStr); + it('85.4.10 fetch the same CLOB column multiple times', async function() { + let id = insertID++; + let specialStr = '85.4.10'; + let contentLength = 200; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, - { }, - { - fetchInfo : { - C1 : { type : oracledb.STRING }, - C2 : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - resultVal = result.rows[0][2]; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - cb(); - } - ); + await insertIntoClobTable1(id, content); + let result = await connection.execute( + "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, + { }, + { + fetchInfo : { + C1 : { type : oracledb.STRING }, + C2 : { type : oracledb.STRING } } } - ], done); + ); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr, content, contentLength); + resultVal = result.rows[0][2]; + compareStrings(resultVal, specialStr, content, contentLength); }); // 85.4.10 - it('85.4.11 works with update statement', function(done) { - var id = insertID++; - var specialStr_1 = '85.4.11_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var specialStr_2 = '85.4.11_2'; - var contentLength_2 = 208; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.4.11 works with update statement', async function() { + let id = insertID++; + let specialStr_1 = '85.4.11_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let specialStr_2 = '85.4.11_2'; + let contentLength_2 = 208; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertAndFetch(id, specialStr_1, content_1, contentLength_1, cb); - }, - function(cb) { - updateClobTable1(id, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - cb(); - } - ); + await insertAndFetch(id, specialStr_1, content_1, contentLength_1); + await updateClobTable1(id, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); - }); // 85.4.8 + ); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + }); // 85.4.11 - it('85.4.12 works with setting oracledb.maxRows < actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.4.12_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.4.12_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.4.12 works with setting oracledb.maxRows < actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.4.12_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.4.12_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 1; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - result.rows.length.should.eql(1); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - oracledb.maxRows = maxRowsBak; - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + assert.strictEqual(result.rows.length, 1); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + oracledb.maxRows = maxRowsBak; }); // 85.4.12 - it('85.4.13 works with setting oracledb.maxRows > actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.4.13_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.4.13_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.4.13 works with setting oracledb.maxRows > actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.4.13_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.4.13_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 10; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - should.not.exist(err); - result.rows.length.should.eql(2); - var resultVal = result.rows[0][1]; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = result.rows[1][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - oracledb.maxRows = maxRowsBak; - cb(); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); + ); + assert.strictEqual(result.rows.length, 2); + let resultVal = result.rows[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = result.rows[1][1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + oracledb.maxRows = maxRowsBak; }); // 85.4.13 - it('85.4.14 works with REF CURSOR', function(done) { - var id = insertID++; - var specialStr = '85.4.14'; - var contentLength = 100; - var content = random.getRandomString(contentLength, specialStr); + it('85.4.14 works with REF CURSOR', async function() { + let id = insertID++; + let specialStr = '85.4.14'; + let contentLength = 100; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - var ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + - "AS \n" + - "BEGIN \n" + - " OPEN clob_cursor FOR \n" + - " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + - "END;"; - connection.execute( - ref_proc, - function(err) { - should.not.exist(err); - cb(); - } - ); - }, - function(cb) { - var sql = "BEGIN nodb_ref(:c); END;"; - var bindVar = { - c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }; - connection.execute( - sql, - bindVar, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } } - }, - function(err, result) { - result.outBinds.c.getRows(3, function(err, rows) { - var resultVal = rows[0][0]; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - result.outBinds.c.close(cb); - }); - } - ); - }, - function(cb) { - var ref_proc_drop = "DROP PROCEDURE nodb_ref"; - connection.execute( - ref_proc_drop, - function(err) { - should.not.exist(err); - cb(); - } - ); + await insertIntoClobTable1(id, content); + const ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(clob_cursor OUT SYS_REFCURSOR)\n" + + "AS \n" + + "BEGIN \n" + + " OPEN clob_cursor FOR \n" + + " SELECT C from nodb_clob1 WHERE ID = " + id + "; \n" + + "END;"; + await connection.execute(ref_proc); + + let sql = "BEGIN nodb_ref(:c); END;"; + let bindVar = { + c: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }; + let result = await connection.execute( + sql, + bindVar, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } } } - ], done); - }); + ); + let rows = await result.outBinds.c.getRows(3); + let resultVal = rows[0][0]; + compareStrings(resultVal, specialStr, content, contentLength); + await result.outBinds.c.close(); + + let ref_proc_drop = "DROP PROCEDURE nodb_ref"; + await connection.execute(ref_proc_drop); + }); // 85.4.14 }); // 85.4 describe('85.5 fetch CLOB columns by setting fetchInfo option, outFormat = oracledb.OUT_FORMAT_ARRAY and resultSet = true', function() { - before('Create table and populate', function(done) { - connection.execute( - proc_create_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + before('Create table and populate', async function() { + await connection.execute(proc_create_table1); }); // before - after('drop table', function(done) { - connection.execute( - drop_table1, - function(err) { - should.not.exist(err); - done(); - } - ); + after('drop table', async function() { + await connection.execute(drop_table1); }); // after insertID = 0; - var insertAndFetch = function(id, specialStr, insertContent, insertContentLength, callback) { - async.series([ - function(cb) { - insertIntoClobTable1(id, insertContent, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = :id", - { id : id }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - var resultVal; - resultVal = row[1]; - if (specialStr === null) { - should.not.exist(err); - should.equal(resultVal, null); - } else { - compareClientFetchResult(err, resultVal, specialStr, insertContent, insertContentLength); - } - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + const insertAndFetch = async function(id, specialStr, insertContent, insertContentLength) { + await insertIntoClobTable1(id, insertContent); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = :id", + { id : id }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], callback); + ); + let row = await result.resultSet.getRow(); + + let resultVal = row[1]; + if (specialStr === null) { + assert.equal(resultVal, null); + } else { + compareStrings(resultVal, specialStr, insertContent, insertContentLength); + } + await result.resultSet.close(); }; - it('85.5.1 works with NULL value', function(done) { - var id = insertID++; - var content = null; + it('85.5.1 works with NULL value', async function() { + let id = insertID++; + let content = null; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.5.1 - it('85.5.2 works with empty String', function(done) { - var id = insertID++; - var content = ""; + it('85.5.2 works with empty String', async function() { + let id = insertID++; + let content = ""; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.5.2 - it('85.5.3 works with small value', function(done) { - var id = insertID++; - var specialStr = '85.5.3'; - var contentLength = 20; - var content = random.getRandomString(contentLength, specialStr); + it('85.5.3 works with small value', async function() { + let id = insertID++; + let specialStr = '85.5.3'; + let contentLength = 20; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.5.3 - it('85.5.4 works with (64K - 1) value', function(done) { - var id = insertID++; - var specialStr = '85.5.4'; - var contentLength = 65535; - var content = random.getRandomString(contentLength, specialStr); + it('85.5.4 works with (64K - 1) value', async function() { + let id = insertID++; + let specialStr = '85.5.4'; + let contentLength = 65535; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.5.4 - it('85.5.5 works with (64K + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.5.5'; - var contentLength = 65537; - var content = random.getRandomString(contentLength, specialStr); + it('85.5.5 works with (64K + 1) value', async function() { + let id = insertID++; + let specialStr = '85.5.5'; + let contentLength = 65537; + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.5.5 - it('85.5.6 works with (1MB + 1) value', function(done) { - var id = insertID++; - var specialStr = '85.5.6'; - var contentLength = 1048577; // 1MB + 1 - var content = random.getRandomString(contentLength, specialStr); + it('85.5.6 works with (1MB + 1) value', async function() { + let id = insertID++; + let specialStr = '85.5.6'; + let contentLength = 1048577; // 1MB + 1 + let content = random.getRandomString(contentLength, specialStr); - insertAndFetch(id, specialStr, content, contentLength, done); + await insertAndFetch(id, specialStr, content, contentLength); }); // 85.5.6 - it('85.5.7 works with dbms_lob.substr()', function(done) { - var id = insertID++; - var specialStr = '85.5.7'; - var contentLength = 200; - var specialStrLength = specialStr.length; - var content = random.getRandomString(contentLength, specialStr); + it('85.5.7 works with dbms_lob.substr()', async function() { + let id = insertID++; + let specialStr = '85.5.7'; + let contentLength = 200; + let specialStrLength = specialStr.length; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", - { id : id }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C1 : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - should.not.exist(err); - var resultVal = row[0]; - compareClientFetchResult(err, resultVal, specialStr, specialStr, specialStrLength); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id, content); + let result = await connection.execute( + "SELECT dbms_lob.substr(C, " + specialStrLength + ", 1) AS C1 from nodb_clob1 WHERE ID = :id", + { id : id }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C1 : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let row = await result.resultSet.getRow(); + let resultVal = row[0]; + compareStrings(resultVal, specialStr, specialStr, specialStrLength); + await result.resultSet.close(); }); // 85.5.7 - it('85.5.8 works with EMPTY_CLOB()', function(done) { - var id = insertID++; - var content = "EMPTY_CLOB"; + it('85.5.8 works with EMPTY_CLOB()', async function() { + let id = insertID++; + let content = "EMPTY_CLOB"; - insertAndFetch(id, null, content, null, done); + await insertAndFetch(id, null, content, null); }); // 85.5.8 - it('85.5.9 fetch multiple CLOB rows as String', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.5.9_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.5.9_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.5.9 fetch multiple CLOB rows as String', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.5.9_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.5.9_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - var rowNumFetched = 2; - result.resultSet.getRows( - rowNumFetched, - function(err, row) { - should.not.exist(err); - should.strictEqual(row.length, 2); - var resultVal = row[0][1]; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = row[1][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + + let rowNumFetched = 2; + let row = await result.resultSet.getRows(rowNumFetched); + assert.strictEqual(row.length, 2); + let resultVal = row[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = row[1][1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + await result.resultSet.close(); }); // 85.5.9 - it('85.5.10 fetch the same CLOB column multiple times', function(done) { - var id = insertID++; - var specialStr = '85.5.10'; - var contentLength = 200; - var content = random.getRandomString(contentLength, specialStr); + it('85.5.10 fetch the same CLOB column multiple times', async function() { + let id = insertID++; + let specialStr = '85.5.10'; + let contentLength = 200; + let content = random.getRandomString(contentLength, specialStr); - async.series([ - function(cb) { - insertIntoClobTable1(id, content, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { - C1 : { type : oracledb.STRING }, - C2 : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - should.not.exist(err); - var resultVal = row[1]; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - resultVal = row[2]; - compareClientFetchResult(err, resultVal, specialStr, content, contentLength); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id, content); + + let result = await connection.execute( + "SELECT ID, C AS C1, C AS C2 from nodb_clob1 WHERE ID = " + id, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { + C1 : { type : oracledb.STRING }, + C2 : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let row = await result.resultSet.getRow(); + let resultVal = row[1]; + compareStrings(resultVal, specialStr, content, contentLength); + resultVal = row[2]; + compareStrings(resultVal, specialStr, content, contentLength); + + await result.resultSet.close(); }); // 85.5.10 - it('85.5.11 works with update statement', function(done) { - var id = insertID++; - var specialStr_1 = '85.5.11_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var specialStr_2 = '85.5.11_2'; - var contentLength_2 = 208; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); + it('85.5.11 works with update statement', async function() { + let id = insertID++; + let specialStr_1 = '85.5.11_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let specialStr_2 = '85.5.11_2'; + let contentLength_2 = 208; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); - async.series([ - function(cb) { - insertAndFetch(id, specialStr_1, content_1, contentLength_1, cb); - }, - function(cb) { - updateClobTable1(id, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE ID = " + id, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - result.resultSet.getRow( - function(err, row) { - should.not.exist(err); - var resultVal = row[1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertAndFetch(id, specialStr_1, content_1, contentLength_1); + await updateClobTable1(id, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE ID = " + id, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let row = await result.resultSet.getRow(); + let resultVal = row[1]; + compareStrings(resultVal, specialStr_2, content_2, contentLength_2); + + await result.resultSet.close(); }); // 85.5.11 - it('85.5.12 works with setting oracledb.maxRows < actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.5.12_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.5.12_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.5.12 works with setting oracledb.maxRows < actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.5.12_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.5.12_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 1; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - var rowNumFetched = 2; - result.resultSet.getRows( - rowNumFetched, - function(err, row) { - should.not.exist(err); - should.strictEqual(row.length, 2); - var resultVal = row[0][1]; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = row[1][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - oracledb.maxRows = maxRowsBak; - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let rowNumFetched = 2; + let row = await result.resultSet.getRows(rowNumFetched); + assert.strictEqual(row.length, 2); + + let resultVal = row[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = row[1][1]; + oracledb.maxRows = maxRowsBak; + await result.resultSet.close(); }); // 85.5.12 - it('85.5.13 works with setting oracledb.maxRows > actual number of rows in the table', function(done) { - var id_1 = insertID++; - var specialStr_1 = '85.5.13_1'; - var contentLength_1 = 200; - var content_1 = random.getRandomString(contentLength_1, specialStr_1); - var id_2 = insertID++; - var specialStr_2 = '85.5.13_2'; - var contentLength_2 = 100; - var content_2 = random.getRandomString(contentLength_2, specialStr_2); - var maxRowsBak = oracledb.maxRows; + it('85.5.13 works with setting oracledb.maxRows > actual number of rows in the table', async function() { + let id_1 = insertID++; + let specialStr_1 = '85.5.13_1'; + let contentLength_1 = 200; + let content_1 = random.getRandomString(contentLength_1, specialStr_1); + let id_2 = insertID++; + let specialStr_2 = '85.5.13_2'; + let contentLength_2 = 100; + let content_2 = random.getRandomString(contentLength_2, specialStr_2); + let maxRowsBak = oracledb.maxRows; oracledb.maxRows = 10; - async.series([ - function(cb) { - insertIntoClobTable1(id_1, content_1, cb); - }, - function(cb) { - insertIntoClobTable1(id_2, content_2, cb); - }, - function(cb) { - connection.execute( - "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, - { }, - { - outFormat : oracledb.OUT_FORMAT_ARRAY, - fetchInfo : { C : { type : oracledb.STRING } }, - resultSet : true - }, - function(err, result) { - should.not.exist(err); - var rowNumFetched = 2; - result.resultSet.getRows( - rowNumFetched, - function(err, row) { - should.not.exist(err); - should.strictEqual(row.length, 2); - var resultVal = row[0][1]; - compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1); - resultVal = row[1][1]; - compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2); - oracledb.maxRows = maxRowsBak; - result.resultSet.close(function(err) { - should.not.exist(err); - cb(); - }); - } - ); - } - ); + await insertIntoClobTable1(id_1, content_1); + await insertIntoClobTable1(id_2, content_2); + + let result = await connection.execute( + "SELECT ID, C from nodb_clob1 WHERE id = " + id_1 + " or id = " + id_2, + { }, + { + outFormat : oracledb.OUT_FORMAT_ARRAY, + fetchInfo : { C : { type : oracledb.STRING } }, + resultSet : true } - ], done); + ); + let rowNumFetched = 2; + let row = await result.resultSet.getRows(rowNumFetched); + assert.strictEqual(row.length, 2); + + let resultVal = row[0][1]; + compareStrings(resultVal, specialStr_1, content_1, contentLength_1); + resultVal = row[1][1]; + oracledb.maxRows = maxRowsBak; + await result.resultSet.close(); }); // 85.5.13 }); // 85.5 diff --git a/test/testsUtil.js b/test/testsUtil.js index 9c21f278..e521053b 100644 --- a/test/testsUtil.js +++ b/test/testsUtil.js @@ -437,5 +437,6 @@ testsUtil.checkUrowidLength = function(urowidLen, expectedLength) { // ROWID is returned which has a fixed size of 18 bytes if (dbConfig.test.isCloudService) expectedLength = 18; - assert(urowidLen >= expectedLength); + assert(urowidLen >= expectedLength, + `${urowidLen} should be >= ${expectedLength}`); }; diff --git a/test/urowidDMLBindAsString2.js b/test/urowidDMLBindAsString2.js index bec08efd..494f3dc7 100755 --- a/test/urowidDMLBindAsString2.js +++ b/test/urowidDMLBindAsString2.js @@ -560,4 +560,3 @@ describe('115. urowidDMLBindAsString2.js', function() { }; }); -