From db4c7ea2d308185fdb68da7a09a7a3d2a7ba17d8 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Sat, 17 Jun 2017 09:40:09 +1000 Subject: [PATCH] Test updates --- test/autoCommitForSelect.js | 12 +- test/bindTimestamp.js | 4 +- test/binding.js | 136 +- test/blobStream.js | 272 ++++ test/clobPlsqlBindAsString_bindout.js | 2 +- test/clobStream.js | 271 ++++ test/connClose.js | 18 +- test/connection.js | 14 +- test/dataTypeNclob.js | 12 +- test/dataTypeNumber2.js | 2 +- test/dataTypeRaw.js | 52 +- test/examples.js | 6 +- test/fetchBlobAsBuffer3.js | 6 +- test/fetchClobAsString1.js | 10 +- test/fetchClobAsString3.js | 6 +- test/fetchRowidAsString.js | 38 +- test/fetchTimestampAsString.js | 8 +- test/fetchUrowidAsString.js | 65 +- test/fetchUrowidAsString_indexed.js | 74 +- test/file.js | 8 + test/lobBindAsStringBuffer.js | 50 +- test/longDMLBind.js | 39 +- test/longrawDMLBind.js | 102 +- test/nclobDMLBindAsString.js | 12 +- test/nestedCursor.js | 136 +- test/nullColumnValues.js | 20 +- test/opts/mocha.opts | 3 + test/plsqlBindIndexedTable2.js | 4 +- test/plsqlBindScalar.js | 220 ++-- test/pool.js | 2 +- test/poolCache.js | 2 +- test/poolClose.js | 72 +- test/resultSet1.js | 14 +- test/resultSet2.js | 1131 ++++++++--------- test/resultSetClose.js | 52 +- test/rowidDMLBindAsString.js | 64 +- test/rowidProcedureBindAsString_bindinout.js | 18 +- test/rowidProcedureBindAsString_bindout.js | 18 +- test/urowidDMLBindAsString_indexed.js | 270 +++- test/urowidProcedureBindAsString_bindinout.js | 18 +- test/urowidProcedureBindAsString_bindout.js | 18 +- test/writableProperties.js | 4 +- 42 files changed, 2010 insertions(+), 1275 deletions(-) create mode 100644 test/blobStream.js create mode 100644 test/clobStream.js diff --git a/test/autoCommitForSelect.js b/test/autoCommitForSelect.js index 4834b91f..153c7c33 100644 --- a/test/autoCommitForSelect.js +++ b/test/autoCommitForSelect.js @@ -137,12 +137,12 @@ describe('8. autoCommitForSelect.js', function(){ afterEach(function(done){ connection.execute( - 'DROP TABLE nodb_commit4_dept purge', - function(err){ - if(err) { console.error(err.message); return; } - done(); - } - ); + 'DROP TABLE nodb_commit4_dept purge', + function(err){ + if(err) { console.error(err.message); return; } + done(); + } + ); }); it('8.1 should return previous value when autoCommit is false', function(done){ diff --git a/test/bindTimestamp.js b/test/bindTimestamp.js index 05132b09..75676eab 100644 --- a/test/bindTimestamp.js +++ b/test/bindTimestamp.js @@ -257,7 +257,7 @@ describe('102. bindTimestamp.js', function() { connection.execute( "insert into nodb_tab_tsbind values (:1, :2, :3) returning id, tstz into :4, :5", [id, bv, bv, { type: oracledb.NUMBER, dir: oracledb.BIND_OUT}, - { type: oracledb.DATE, dir: oracledb.BIND_OUT} ], + { type: oracledb.DATE, dir: oracledb.BIND_OUT} ], { autoCommit: true}, function(err, result) { should.not.exist(err); @@ -330,7 +330,7 @@ describe('102. bindTimestamp.js', function() { connection.execute( "insert into nodb_tab_tsbind values (:1, :2, :3) returning id, tstz into :4, :5", [id, bv, bv, { type: oracledb.NUMBER, dir: oracledb.BIND_OUT}, - { type: oracledb.NUMBER, dir: oracledb.BIND_OUT} ], + { type: oracledb.NUMBER, dir: oracledb.BIND_OUT} ], { autoCommit: true}, function(err) { should.exist(err); diff --git a/test/binding.js b/test/binding.js index ccd88ff9..15c97f9c 100644 --- a/test/binding.js +++ b/test/binding.js @@ -676,15 +676,15 @@ describe('4. binding.js', function() { it('4.4.3 Negative - bind out data exceeds default length', function(done) { connection.execute( "BEGIN :o := lpad('A',201,'x'); END;", - { o: { type: oracledb.STRING, dir : oracledb.BIND_OUT } }, - function (err, result) { - should.exist(err); - // ORA-06502: PL/SQL: numeric or value error - err.message.should.startWith('ORA-06502:'); - // console.log(result.outBinds.o.length); - should.not.exist(result); - done(); - } + { o: { type: oracledb.STRING, dir : oracledb.BIND_OUT } }, + function (err, result) { + should.exist(err); + // ORA-06502: PL/SQL: numeric or value error + err.message.should.startWith('ORA-06502:'); + // console.log(result.outBinds.o.length); + should.not.exist(result); + done(); + } ); }); @@ -805,47 +805,47 @@ describe('4. binding.js', function() { // Test cases involving JSON value as input describe ('4.7 Value as JSON named/unamed test cases', function () { it ( '4.7.1 valid case when numeric values are passed as it is', - function (done ) { - var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 "; - var binds = [ 1, 456 ]; + function (done ) { + var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 "; + var binds = [ 1, 456 ]; - oracledb.getConnection ( - dbConfig, - function (err, connection ){ + oracledb.getConnection ( + dbConfig, + function (err, connection ){ - should.not.exist ( err ) ; - connection.execute ( - sql, - binds, - function ( err, result ) { - (result.rows[0][0]).should.be.a.Date(); - should.not.exist ( err ); - done (); - } - ); - }); - }); + should.not.exist ( err ) ; + connection.execute ( + sql, + binds, + function ( err, result ) { + (result.rows[0][0]).should.be.a.Date(); + should.not.exist ( err ); + done (); + } + ); + }); + }); it ( '4.7.2 Valid values when one of the value is passed as JSON ', - function (done ) { - var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 "; - var binds = [ 1, { val : 456 } ]; + function (done ) { + var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 "; + var binds = [ 1, { val : 456 } ]; - oracledb.getConnection ( - dbConfig, - function (err, connection ){ + oracledb.getConnection ( + dbConfig, + function (err, connection ){ - should.not.exist ( err ) ; - connection.execute ( - sql, - binds, - function ( err, result ) { - (result.rows[0][0]).should.be.a.Date(); - should.not.exist ( err ); - done (); - } ); - }); - }); + should.not.exist ( err ) ; + connection.execute ( + sql, + binds, + function ( err, result ) { + (result.rows[0][0]).should.be.a.Date(); + should.not.exist ( err ); + done (); + } ); + }); + }); it ( '4.7.3 Valid test case when one of the value is passed as JSON ', function (done ) { @@ -853,19 +853,19 @@ describe('4. binding.js', function() { var binds = [ {val : 1}, 456 ]; oracledb.getConnection ( - dbConfig, - function (err, connection ){ + dbConfig, + function (err, connection ){ - should.not.exist ( err ) ; - connection.execute ( - sql, - binds, - function ( err, result ) { - (result.rows[0][0]).should.be.a.Date(); - should.not.exist ( err ); - done (); - } ); - }); + should.not.exist ( err ) ; + connection.execute ( + sql, + binds, + function ( err, result ) { + (result.rows[0][0]).should.be.a.Date(); + should.not.exist ( err ); + done (); + } ); + }); }); it ( '4.7.4 Valid Test case when both values are passed as JSON', @@ -874,19 +874,19 @@ describe('4. binding.js', function() { var binds = [ {val : 1}, {val : 456 } ]; oracledb.getConnection ( - dbConfig, - function (err, connection ){ + dbConfig, + function (err, connection ){ - should.not.exist ( err ) ; - connection.execute ( - sql, - binds, - function ( err, result ) { - (result.rows[0][0]).should.be.a.Date(); - should.not.exist ( err ); - done (); - } ); - }); + should.not.exist ( err ) ; + connection.execute ( + sql, + binds, + function ( err, result ) { + (result.rows[0][0]).should.be.a.Date(); + should.not.exist ( err ); + done (); + } ); + }); }); it ( '4.7.5 Invalid Test case when value is passed as named JSON', diff --git a/test/blobStream.js b/test/blobStream.js new file mode 100644 index 00000000..89e228cd --- /dev/null +++ b/test/blobStream.js @@ -0,0 +1,272 @@ +/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. */ + +/****************************************************************************** + * + * You may not use the identified files except in compliance with the Apache + * License, Version 2.0 (the "License.") + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + * The node-oracledb test suite uses 'mocha', 'should' and 'async'. + * See LICENSE.md for relevant licenses. + * + * NAME + * 127. blobStream.js + * + * DESCRIPTION + * Testing stream txt file into BLOB. + * + * NUMBERING RULE + * Test numbers follow this numbering rule: + * 1 - 20 are reserved for basic functional tests + * 21 - 50 are reserved for data type supporting tests + * 51 onwards are for other tests + * + *****************************************************************************/ +'use strict'; + +var oracledb = require('oracledb'); +var should = require('should'); +var async = require('async'); +var dbConfig = require('./dbconfig.js'); +var file = require('./file.js'); +var sql = require('./sql.js'); +var fs = require('fs'); + +describe('127.blobStream.js', function() { + var connection = null; + var fileRoot = "."; + var insertID = 1; + var inFileName; + + var proc_blob_prepare_tab = "BEGIN \n" + + " DECLARE \n" + + " e_table_missing EXCEPTION; \n" + + " PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" + + " BEGIN \n" + + " EXECUTE IMMEDIATE('DROP TABLE nodb_tab_lobs_pre PURGE'); \n" + + " EXCEPTION \n" + + " WHEN e_table_missing \n" + + " THEN NULL; \n" + + " END; \n" + + " EXECUTE IMMEDIATE (' \n" + + " CREATE TABLE nodb_tab_lobs_pre ( \n" + + " id NUMBER, \n" + + " blob BLOB \n" + + " ) \n" + + " '); \n" + + "END; "; + + before(function(done) { + async.series([ + function(cb) { + oracledb.getConnection(dbConfig, function(err, conn) { + should.not.exist(err); + connection = conn; + + cb(); + }); + }, + function(cb) { + setupAllTable(cb); + } + ], done); + }); // before + + after(function(done) { + async.series([ + function(cb) { + dropAllTable(cb); + }, + function(cb) { + connection.release(function(err) { + should.not.exist(err); + cb(); + }); + } + ], done); + }); // after + + beforeEach(function(done) { + insertID++; + done(); + }); + + describe('127.1 stream txt file into BLOB column', function() { + it('127.1.1 works with 64K txt file', function(done) { + inFileName = fileRoot + '/smallString.txt'; + var selectID = insertID + 100; + var fileSize = 64 * 1024; + var specialStr = '127.1.1'; + + bindSmallFile(inFileName, fileSize, selectID, insertID, specialStr, done); + }); + + it('127.1.2 works with 64K+1 txt file', function(done) { + inFileName = fileRoot + '/smallString.txt'; + var selectID = insertID + 100; + var fileSize = 64 * 1024 + 1; + var specialStr = '127.1.2'; + + bindSmallFile(inFileName, fileSize, selectID, insertID, specialStr, done); + }); + + it('127.1.3 works with 1MB+1 txt file', function(done) { + inFileName = fileRoot + '/smallString.txt'; + var selectID = insertID + 100; + var fileSize = 1 * 1024 * 1024 + 1; + var specialStr = '127.1.3'; + + bindSmallFile(inFileName, fileSize, selectID, insertID, specialStr, done); + }); + + }); // 1.1 + + var bindSmallFile = function(inFileName, fileSize, selectID, insertID, specialStr, callback) { + async.series([ + function(cb) { + file.createFileInKB(inFileName, fileSize, specialStr); + cb(); + }, + function(cb) { + insetTableWithBlob(selectID, inFileName, cb); + }, + function(cb) { + verifyBlob(selectID, insertID, fileSize, cb); + }, + function(cb) { + file.delete(inFileName); + cb(); + } + ], callback); + }; + + var setupAllTable = function(callback) { + connection.execute( + proc_blob_prepare_tab, + function(err) { + should.not.exist(err); + callback(); + }); + }; + + var dropAllTable = function(callback) { + connection.execute( + "DROP TABLE nodb_tab_lobs_pre PURGE", + function(err) { + should.not.exist(err); + callback(); + }); + }; + + var insetTableWithBlob = function(id, inFileName, callback) { + var sql = "INSERT INTO nodb_tab_lobs_pre (id, blob) VALUES (:i, EMPTY_BLOB()) RETURNING blob INTO :lobbv"; + var bindVar = { i: id, lobbv: { type: oracledb.BLOB, dir: oracledb.BIND_OUT } }; + + connection.execute( + sql, + bindVar, + { autoCommit: false }, // a transaction needs to span the INSERT and pipe() + function(err, result) { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + (result.outBinds.lobbv.length).should.be.exactly(1); + + var inStream = fs.createReadStream(inFileName); + var lob = result.outBinds.lobbv[0]; + + lob.on('error', function(err) { + should.not.exist(err); + }); + + inStream.on('error', function(err) { + should.not.exist(err); + }); + + lob.on('close', function() { + connection.commit( function(err) { + should.not.exist(err); + callback(); + }); + }); + + inStream.pipe(lob); // copies the text to the BLOB + } + ); + }; + + var verifyBlob = function(selectID, insertID, lenExpected, callback) { + var lob = {}; + var selectSql = "select blob from nodb_tab_lobs_pre where id = " + selectID; + var insetSql = "INSERT INTO nodb_tab_lobs_pre (id, blob) VALUES (:i, :c)"; + var proc_compare_blob = "CREATE OR REPLACE PROCEDURE nodb_blob_compare(result OUT NUMBER, len OUT NUMBER) \n" + + "IS \n" + + " blob1 BLOB; \n" + + " blob2 BLOB; \n" + + "BEGIN \n" + + " select blob into blob1 from nodb_tab_lobs_pre where id = " + selectID + "; \n" + + " select blob into blob2 from nodb_tab_lobs_pre where id = " + insertID + "; \n" + + " result := DBMS_LOB.COMPARE(blob1, blob2); \n" + // Zero if the comparison succeeds, nonzero if not. + " len := length(blob1); \n" + + "END nodb_blob_compare;"; + var sqlRunComparePorc = "begin nodb_blob_compare(:r, :l); end;"; + var sqlDropComparePorc = "DROP PROCEDURE nodb_blob_compare"; + + async.series([ + function(cb) { + connection.execute( + selectSql, + function(err, result) { + should.not.exist(err); + lob = result.rows[0][0]; + should.exist(lob); + cb(); + } + ); + }, + function(cb) { + var bindVar = { i: insertID, c: { val: lob, type: oracledb.BLOB, dir: oracledb.BIND_IN } }; + connection.execute( + insetSql, + bindVar, + { autoCommit: true }, + function(err) { + should.not.exist(err); + cb(); + } + ); + }, + function(cb) { + sql.executeSql(connection, proc_compare_blob, {}, {}, cb); + }, + function(cb) { + var bindVar = { + r: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }, + l: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT } + }; + connection.execute( + sqlRunComparePorc, + bindVar, + function(err, result) { + should.not.exist(err); + result.outBinds.r.should.eql(0); + should.strictEqual(result.outBinds.l, lenExpected); + cb(); + }); + }, + function(cb) { + sql.executeSql(connection, sqlDropComparePorc, {}, {}, cb); + } + ], callback); + + }; + +}); diff --git a/test/clobPlsqlBindAsString_bindout.js b/test/clobPlsqlBindAsString_bindout.js index 2107c9cd..aacd28d9 100644 --- a/test/clobPlsqlBindAsString_bindout.js +++ b/test/clobPlsqlBindAsString_bindout.js @@ -1283,7 +1283,7 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() { bindVar, function(err) { should.exist(err); - // ORA-06502: PL/SQL: numeric or value error + // ORA-06502: PL/SQL: numeric or value error (err.message).should.startWith('ORA-06502:'); cb(); } diff --git a/test/clobStream.js b/test/clobStream.js new file mode 100644 index 00000000..d65d17fb --- /dev/null +++ b/test/clobStream.js @@ -0,0 +1,271 @@ +/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. */ + +/****************************************************************************** + * + * You may not use the identified files except in compliance with the Apache + * License, Version 2.0 (the "License.") + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + * The node-oracledb test suite uses 'mocha', 'should' and 'async'. + * See LICENSE.md for relevant licenses. + * + * NAME + * 128. clobStream.js + * + * DESCRIPTION + * Testing stream txt file into CLOB. + * + * NUMBERING RULE + * Test numbers follow this numbering rule: + * 1 - 20 are reserved for basic functional tests + * 21 - 50 are reserved for data type supporting tests + * 51 onwards are for other tests + * + *****************************************************************************/ +'use strict'; + +var oracledb = require('oracledb'); +var should = require('should'); +var async = require('async'); +var dbConfig = require('./dbconfig.js'); +var file = require('./file.js'); +var sql = require('./sql.js'); +var fs = require('fs'); + +describe('128.clobStream.js', function() { + var connection = null; + var fileRoot = "."; + var insertID = 1; + var inFileName; + + var proc_clob_prepare_tab = "BEGIN \n" + + " DECLARE \n" + + " e_table_missing EXCEPTION; \n" + + " PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" + + " BEGIN \n" + + " EXECUTE IMMEDIATE('DROP TABLE nodb_tab_lobs_pre PURGE'); \n" + + " EXCEPTION \n" + + " WHEN e_table_missing \n" + + " THEN NULL; \n" + + " END; \n" + + " EXECUTE IMMEDIATE (' \n" + + " CREATE TABLE nodb_tab_lobs_pre ( \n" + + " id NUMBER, \n" + + " clob CLOB \n" + + " ) \n" + + " '); \n" + + "END; "; + + before(function(done) { + async.series([ + function(cb) { + oracledb.getConnection(dbConfig, function(err, conn) { + should.not.exist(err); + connection = conn; + cb(); + }); + }, + function(cb) { + setupAllTable(cb); + } + ], done); + }); // before + + after(function(done) { + async.series([ + function(cb) { + dropAllTable(cb); + }, + function(cb) { + connection.release(function(err) { + should.not.exist(err); + cb(); + }); + } + ], done); + }); // after + + beforeEach(function(done) { + insertID++; + done(); + }); + + describe('128.1 stream txt file into CLOB column', function() { + it('128.1.1 works with 64KB txt file', function(done) { + inFileName = fileRoot + '/smallString.txt'; + var selectID = insertID + 200; + var specialStr = '128.1.1'; + var fileSize = 65536; + + bindIn_small(inFileName, fileSize, selectID, insertID, specialStr, done); + }); + + it('128.1.2 works with 64KB+1 txt file', function(done) { + inFileName = fileRoot + '/smallString.txt'; + var selectID = insertID + 200; + var specialStr = '128.1.2'; + var fileSize = 655376; + + bindIn_small(inFileName, fileSize, selectID, insertID, specialStr, done); + }); + + it('128.1.3 works with 1MB+1 txt file', function(done) { + inFileName = fileRoot + '/smallString.txt'; + var selectID = insertID + 200; + var specialStr = '128.1.3'; + var fileSize = 1 * 1024 * 1024; + + bindIn_small(inFileName, fileSize, selectID, insertID, specialStr, done); + }); + + }); // 4.1 + + var bindIn_small = function(inFileName, fileSize, selectID, insertID, specialStr, callback) { + async.series([ + function(cb) { + file.createFileInKB(inFileName, fileSize, specialStr); + cb(); + }, + function(cb) { + insetTableWithClob(selectID, inFileName, cb); + }, + function(cb) { + verifyClob(selectID, insertID, fileSize, cb); + }, + function(cb) { + file.delete(inFileName); + cb(); + } + ], callback); + }; + + var setupAllTable = function(callback) { + connection.execute( + proc_clob_prepare_tab, + function(err) { + should.not.exist(err); + callback(); + }); + }; + + var dropAllTable = function(callback) { + connection.execute( + "DROP TABLE nodb_tab_lobs_pre PURGE", + function(err) { + should.not.exist(err); + callback(); + }); + }; + + var insetTableWithClob = function(id, inFileName, callback) { + var sql = "INSERT INTO nodb_tab_lobs_pre (id, clob) VALUES (:i, EMPTY_CLOB()) RETURNING clob INTO :lobbv"; + var bindVar = { i: id, lobbv: { type: oracledb.CLOB, dir: oracledb.BIND_OUT } }; + + connection.execute( + sql, + bindVar, + { autoCommit: false }, // a transaction needs to span the INSERT and pipe() + function(err, result) { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + (result.outBinds.lobbv.length).should.be.exactly(1); + + var inStream = fs.createReadStream(inFileName); + var lob = result.outBinds.lobbv[0]; + + lob.on('error', function(err) { + should.not.exist(err); + }); + + inStream.on('error', function(err) { + should.not.exist(err); + }); + + lob.on('close', function() { + connection.commit( function(err) { + should.not.exist(err); + callback(); + }); + }); + + inStream.pipe(lob); // copies the text to the CLOB + } + ); + }; + + var verifyClob = function(selectID, insertID, lenExpected, callback) { + var lob = {}; + var selectSql = "select clob from nodb_tab_lobs_pre where id = " + selectID; + var insetSql = "INSERT INTO nodb_tab_lobs_pre (id, clob) VALUES (:i, :c)"; + var proc_compare_clob = "CREATE OR REPLACE PROCEDURE nodb_clob_compare(result OUT NUMBER, len OUT NUMBER) \n" + + "IS \n" + + " clob1 CLOB; \n" + + " clob2 CLOB; \n" + + "BEGIN \n" + + " select clob into clob1 from nodb_tab_lobs_pre where id = " + selectID + "; \n" + + " select clob into clob2 from nodb_tab_lobs_pre where id = " + insertID + "; \n" + + " result := DBMS_LOB.COMPARE(clob1, clob2); \n" + // Zero if the comparison succeeds, nonzero if not. + " len := length(clob1); \n" + + "END nodb_clob_compare;"; + var sqlRunComparePorc = "begin nodb_clob_compare(:r, :l); end;"; + var sqlDropComparePorc = "DROP PROCEDURE nodb_clob_compare"; + + async.series([ + function(cb) { + connection.execute( + selectSql, + function(err, result) { + should.not.exist(err); + lob = result.rows[0][0]; + should.exist(lob); + cb(); + } + ); + }, + function(cb) { + var bindVar = { i: insertID, c: { val: lob, type: oracledb.CLOB, dir: oracledb.BIND_IN } }; + connection.execute( + insetSql, + bindVar, + { autoCommit: true }, + function(err) { + should.not.exist(err); + cb(); + } + ); + }, + function(cb) { + sql.executeSql(connection, proc_compare_clob, {}, {}, cb); + }, + function(cb) { + var bindVar = { + r: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }, + l: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT } + }; + connection.execute( + sqlRunComparePorc, + bindVar, + function(err, result) { + should.not.exist(err); + result.outBinds.r.should.eql(0); + should.strictEqual(result.outBinds.l, lenExpected); + cb(); + }); + }, + function(cb) { + sql.executeSql(connection, sqlDropComparePorc, {}, {}, cb); + } + ], callback); + + }; + +}); diff --git a/test/connClose.js b/test/connClose.js index ab93e433..5810a0c0 100644 --- a/test/connClose.js +++ b/test/connClose.js @@ -175,14 +175,18 @@ describe('52. connClose.js', function() { connection.release(function(err) { should.not.exist(err); - should.throws( - function() { - var sql = "select sysdate from dual"; - connection.execute(sql, function() {}); - }, - /NJS-003: invalid connection/ + connection.execute( + "select sysdate from dual", + function(err, result) { + should.not.exist(result); + should.exist(err); + should.strictEqual( + err.message, + "NJS-003: invalid connection" + ); + done(); + } ); - done(); }); } ); diff --git a/test/connection.js b/test/connection.js index cad1f757..9d657a8a 100644 --- a/test/connection.js +++ b/test/connection.js @@ -124,13 +124,13 @@ describe('1. connection.js', function(){ it('1.1.2 ARRAY format explicitly', function(done) { connection.should.be.ok(); connection.execute( - query, {id: 20}, {outFormat: oracledb.ARRAY}, - function(err, result){ - should.not.exist(err); - (result.rows).should.eql([[ 20, 'Marketing' ]]); - done(); - } - ); + query, {id: 20}, {outFormat: oracledb.ARRAY}, + function(err, result){ + should.not.exist(err); + (result.rows).should.eql([[ 20, 'Marketing' ]]); + done(); + } + ); }); it('1.1.3 OBJECT format', function(done){ diff --git a/test/dataTypeNclob.js b/test/dataTypeNclob.js index a4ae0c69..90dea479 100644 --- a/test/dataTypeNclob.js +++ b/test/dataTypeNclob.js @@ -271,12 +271,12 @@ describe('123. dataTypeNclob.js', function() { var insertData = function(tableName, insertStr, callback) { var sql = "INSERT INTO " + tableName + "(num, content) VALUES(" + insertID + ", TO_NCLOB('" + insertStr + "'))"; connection.execute( - sql, - function(err) { - should.not.exist(err); - callback(); - } - ); + sql, + function(err) { + should.not.exist(err); + callback(); + } + ); }; var streamLob = function(tableName, originalStr, callback) { diff --git a/test/dataTypeNumber2.js b/test/dataTypeNumber2.js index ac568331..d43eacf7 100644 --- a/test/dataTypeNumber2.js +++ b/test/dataTypeNumber2.js @@ -125,7 +125,7 @@ describe('27. dataTypeNumber2.js', function() { if(Math.abs( numbers[rows[i].NUM] ) == 0.00000123) rows[i].CONTENT.should.be.exactly(0); else - rows[i].CONTENT.should.be.exactly(numbers[rows[i].NUM]); + rows[i].CONTENT.should.be.exactly(numbers[rows[i].NUM]); } return fetchRowsFromRS(rs); } else if(rows.length == 0) { diff --git a/test/dataTypeRaw.js b/test/dataTypeRaw.js index 6b305043..3aab5ee3 100644 --- a/test/dataTypeRaw.js +++ b/test/dataTypeRaw.js @@ -137,14 +137,14 @@ describe('42. dataTypeRaw.js', function() { it('42.1.5 a negative case which hits NJS-011 error', function(done) { connection.execute( "INSERT INTO " + tableName + " (content ) VALUES (:c)", - { c : { val: 1234, type: oracledb.BUFFER, dir:oracledb.BIND_IN } }, - function(err, result) { - should.exist(err); + { c : { val: 1234, type: oracledb.BUFFER, dir:oracledb.BIND_IN } }, + function(err, result) { + should.exist(err); // NJS-011: encountered bind value and type mismatch - (err.message).should.startWith('NJS-011:'); - should.not.exist(result); - done(); - } + (err.message).should.startWith('NJS-011:'); + should.not.exist(result); + done(); + } ); }); @@ -415,7 +415,7 @@ describe('42. dataTypeRaw.js', function() { }); }); // 42.4 - describe('45.5 INSERT and SELECT', function() { + describe('42.5 INSERT and SELECT', function() { before(function(done) { assist.createTable(connection, tableName, done); }); @@ -435,27 +435,27 @@ describe('42. dataTypeRaw.js', function() { done(); }); - it('45.5.1 works with data size 100', function(done) { + it('42.5.1 works with data size 100', function(done) { var insertedStr = random.getRandomLengthString(100); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); test1(insertedBuf, done); }); - it('45.5.2 works with data size 2000', function(done) { + it('42.5.2 works with data size 2000', function(done) { var insertedStr = random.getRandomLengthString(2000); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); test1(insertedBuf, done); }); - it('45.5.3 works with default type/dir', function(done) { + it('42.5.3 works with default type/dir', function(done) { var insertedStr = random.getRandomLengthString(2000); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); test1_default(insertedBuf, done); }); - }); // 45.5 + }); // 42.5 - describe('45.6 UPDATE', function() { + describe('42.6 UPDATE', function() { before(function(done) { assist.createTable(connection, tableName, done); }); @@ -475,31 +475,31 @@ describe('42. dataTypeRaw.js', function() { done(); }); - it('45.6.1 works with data size 100', function(done) { + it('42.6.1 works with data size 100', function(done) { var insertedStr = random.getRandomLengthString(20); var updateStr = random.getRandomLengthString(100); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); test2(insertedBuf, updateBuf, done); }); - it('45.6.2 works with data size 2000', function(done) { + it('42.6.2 works with data size 2000', function(done) { var insertedStr = random.getRandomLengthString(30); var updateStr = random.getRandomLengthString(2000); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); test2(insertedBuf, updateBuf, done); }); - it('45.6.3 works with default type/dir', function(done) { + it('42.6.3 works with default type/dir', function(done) { var insertedStr = random.getRandomLengthString(30); var updateStr = random.getRandomLengthString(2000); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); test2_default(insertedBuf, updateBuf, done); }); - }); // 45.6 + }); // 42.6 var test1 = function(content, callback) { async.series([ diff --git a/test/examples.js b/test/examples.js index ea01465f..f628c479 100644 --- a/test/examples.js +++ b/test/examples.js @@ -135,7 +135,7 @@ describe('3. examples.js', function(){ }, function(callback){ connection.execute( - "SELECT department_id, department_name " + "SELECT department_id, department_name " + "FROM nodb_eg_dept " + "WHERE department_id = :did", [180], @@ -194,7 +194,7 @@ describe('3. examples.js', function(){ }, function(callback){ connection.execute( - "SELECT location_id, city " + "SELECT location_id, city " + "FROM nodb_locations " + "WHERE city LIKE 'S%' " + "ORDER BY city", @@ -209,7 +209,7 @@ describe('3. examples.js', function(){ }, function(callback){ connection.execute( - "SELECT location_id, city " + "SELECT location_id, city " + "FROM nodb_locations " + "WHERE city LIKE 'S%' " + "ORDER BY city", diff --git a/test/fetchBlobAsBuffer3.js b/test/fetchBlobAsBuffer3.js index bae36d32..7c1d06cb 100644 --- a/test/fetchBlobAsBuffer3.js +++ b/test/fetchBlobAsBuffer3.js @@ -161,7 +161,7 @@ describe('89. fetchBlobAsBuffer3.js', function() { }, function(cb) { connection.execute( - "SELECT ID, B1, B2 from nodb_blob2", + "SELECT ID, B1, B2 from nodb_blob2", function(err, result){ should.not.exist(err); var resultVal = result.rows[0][1]; @@ -193,7 +193,7 @@ describe('89. fetchBlobAsBuffer3.js', function() { }, function(cb) { connection.execute( - "SELECT ID, B1 from nodb_blob2 where ID = :id", + "SELECT ID, B1 from nodb_blob2 where ID = :id", { id : id }, function(err, result){ should.not.exist(err); @@ -207,7 +207,7 @@ describe('89. fetchBlobAsBuffer3.js', function() { oracledb.fetchAsBuffer = []; connection.execute( - "SELECT B2 from nodb_blob2 where ID = :id", + "SELECT B2 from nodb_blob2 where ID = :id", { id : id }, function(err, result){ should.not.exist(err); diff --git a/test/fetchClobAsString1.js b/test/fetchClobAsString1.js index bcf9ade8..8cf8b20c 100644 --- a/test/fetchClobAsString1.js +++ b/test/fetchClobAsString1.js @@ -312,7 +312,7 @@ describe('84. fetchClobAsString1.js', function() { }, function(cb) { connection.execute( - "SELECT ID, C from nodb_clob1 where id = " + id_1 + " or id = " +id_2, + "SELECT ID, C from nodb_clob1 where id = " + id_1 + " or id = " +id_2, function(err, result){ should.not.exist(err); var resultVal = result.rows[0][1]; @@ -345,7 +345,7 @@ describe('84. fetchClobAsString1.js', function() { }, function(cb) { connection.execute( - "SELECT ID, C AS C1, C AS C2 from nodb_clob1 where id = " + id_1 + " or id = " +id_2, + "SELECT ID, C AS C1, C AS C2 from nodb_clob1 where id = " + id_1 + " or id = " +id_2, function(err, result){ should.not.exist(err); var resultVal = result.rows[0][1]; @@ -382,7 +382,7 @@ describe('84. fetchClobAsString1.js', function() { }, function(cb) { connection.execute( - "SELECT ID, C from nodb_clob1 where id = " + id, + "SELECT ID, C from nodb_clob1 where id = " + id, function(err, result){ should.not.exist(err); var resultVal = result.rows[0][1]; @@ -518,7 +518,7 @@ describe('84. fetchClobAsString1.js', function() { }, function(cb) { connection.execute( - "SELECT ID, C from nodb_clob1 where id = " + id_1 + " or id = " +id_2, + "SELECT ID, C from nodb_clob1 where id = " + id_1 + " or id = " +id_2, function(err, result){ should.not.exist(err); result.rows.length.should.eql(1); @@ -553,7 +553,7 @@ describe('84. fetchClobAsString1.js', function() { }, function(cb) { connection.execute( - "SELECT ID, C from nodb_clob1 where id = " + id_1 + " or id = " +id_2, + "SELECT ID, C from nodb_clob1 where id = " + id_1 + " or id = " +id_2, function(err, result){ should.not.exist(err); var resultVal = result.rows[0][1]; diff --git a/test/fetchClobAsString3.js b/test/fetchClobAsString3.js index ab0b0ed1..4b40b836 100644 --- a/test/fetchClobAsString3.js +++ b/test/fetchClobAsString3.js @@ -140,7 +140,7 @@ describe('86. fetchClobAsString3.js', function() { }, function(cb) { connection.execute( - "SELECT ID, C1, C2 from nodb_clob2", + "SELECT ID, C1, C2 from nodb_clob2", function(err, result){ should.not.exist(err); var specialStrLen_1 = specialStr_1.length; @@ -177,7 +177,7 @@ describe('86. fetchClobAsString3.js', function() { }, function(cb) { connection.execute( - "SELECT ID, C1 from nodb_clob2 where ID = :id", + "SELECT ID, C1 from nodb_clob2 where ID = :id", { id: id }, function(err, result){ should.not.exist(err); @@ -194,7 +194,7 @@ describe('86. fetchClobAsString3.js', function() { oracledb.fetchAsString = []; connection.execute( - "SELECT C2 from nodb_clob2 where ID = :id", + "SELECT C2 from nodb_clob2 where ID = :id", { id: id }, function(err, result){ should.not.exist(err); diff --git a/test/fetchRowidAsString.js b/test/fetchRowidAsString.js index f15c4c15..f416755e 100644 --- a/test/fetchRowidAsString.js +++ b/test/fetchRowidAsString.js @@ -589,22 +589,22 @@ describe('106. fetchRowidAsString.js', function() { async.forEach(array, function(element, cb) { var sql = "select content,rowid from " + tableName + " where num = " + element; connection.execute( - sql, - [], - option, - function(err, result) { - should.not.exist(err); - var resultVal_1 = result.rows[0][0]; - var resultVal_2 = result.rows[0][1]; - if(object === true) { - resultVal_1 = result.rows[0].CONTENT; - resultVal_2 = result.rows[0].ROWID; - } - should.strictEqual(typeof resultVal_1, "string"); - should.strictEqual(resultVal_1, resultVal_2); - cb(); + sql, + [], + option, + function(err, result) { + should.not.exist(err); + var resultVal_1 = result.rows[0][0]; + var resultVal_2 = result.rows[0][1]; + if(object === true) { + resultVal_1 = result.rows[0].CONTENT; + resultVal_2 = result.rows[0].ROWID; } - ); + should.strictEqual(typeof resultVal_1, "string"); + should.strictEqual(resultVal_1, resultVal_2); + cb(); + } + ); }, function(err) { should.not.exist(err); callback(); @@ -662,10 +662,10 @@ describe('106. fetchRowidAsString.js', function() { function testQueryStream(option, callback) { var sql = "select CONTENT from " + tableName; var stream = connection.queryStream( - sql, - [], - option - ); + sql, + [], + option + ); var result = []; stream.on('data', function(data) { diff --git a/test/fetchTimestampAsString.js b/test/fetchTimestampAsString.js index 6c6eb1fc..f5ee1ee6 100644 --- a/test/fetchTimestampAsString.js +++ b/test/fetchTimestampAsString.js @@ -479,10 +479,10 @@ describe('19. fetchTimestampAsString.js', function() { function test9(table, want, callback) { var sql = "select content from " + table + " order by num"; var stream = connection.queryStream( - sql, - [], - { fetchInfo: { "CONTENT": { type: oracledb.STRING } } } - ); + sql, + [], + { fetchInfo: { "CONTENT": { type: oracledb.STRING } } } + ); var result = []; stream.on('data', function(data) { diff --git a/test/fetchUrowidAsString.js b/test/fetchUrowidAsString.js index 93529746..096cc040 100644 --- a/test/fetchUrowidAsString.js +++ b/test/fetchUrowidAsString.js @@ -45,8 +45,8 @@ describe('116. fetchUrowidAsString.js', function() { var connection = null; var tableName = "nodb_rowid"; - var array = random.getRandomNumArray(30); - var numRows = array.length; // number of rows to return from each call to getRows() + var dataArray = random.getRandomNumArray(30); + var numRows = dataArray.length; // number of rows to return from each call to getRows() var proc_create_table = "BEGIN \n" + " DECLARE \n" + @@ -83,7 +83,7 @@ describe('116. fetchUrowidAsString.js', function() { }); var insertData = function(connection, tableName, callback) { - async.forEach(array, function(element, cb) { + async.forEach(dataArray, function(element, cb) { var sql = "INSERT INTO " + tableName + "(num) VALUES(" + element + ")"; connection.execute( sql, @@ -99,7 +99,7 @@ describe('116. fetchUrowidAsString.js', function() { }; var updateDate = function(connection, tableName, callback) { - async.forEach(array, function(element, cb) { + async.forEach(dataArray, function(element, cb) { var sql = "UPDATE " + tableName + " T SET content = T.ROWID where num = " + element; connection.execute( sql, @@ -275,7 +275,7 @@ describe('116. fetchUrowidAsString.js', function() { describe('116.3 works with fetchInfo and outFormat = ARRAY', function() { var maxRowBak = oracledb.maxRows; var option = { - outFormat: oracledb.OBJECT, + outFormat: oracledb.ARRAY, fetchInfo: { "CONTENT": { type: oracledb.STRING } } }; before(function(done) { @@ -345,6 +345,7 @@ describe('116. fetchUrowidAsString.js', function() { it('116.3.8 fetchInfo, resultSet = true', function(done) { var option_rs = { resultSet: true, + outFormat: oracledb.ARRAY, fetchInfo: { "CONTENT": { type: oracledb.STRING } } }; test2(option_rs, false, true, done); @@ -499,6 +500,7 @@ describe('116. fetchUrowidAsString.js', function() { it('116.5.8 resultSet = true', function(done) { var option_rs = { resultSet: true, + outFormat: oracledb.OBJECT }; test2(option_rs, true, false, done); }); @@ -507,7 +509,7 @@ describe('116. fetchUrowidAsString.js', function() { describe('116.6 fetch as string by default with outFormat = ARRAY', function() { var maxRowBak = oracledb.maxRows; - var option = { outFormat: oracledb.OBJECT }; + var option = { outFormat: oracledb.ARRAY }; before(function(done) { async.series([ function makeTable(callback) { @@ -576,6 +578,7 @@ describe('116. fetchUrowidAsString.js', function() { it('116.6.8 resultSet = true', function(done) { var option_rs = { resultSet: true, + outFormat: oracledb.ARRAY, }; test2(option_rs, false, false, done); }); @@ -583,29 +586,25 @@ describe('116. fetchUrowidAsString.js', function() { }); function test1(option, object, array, callback) { - async.forEach(array, function(element, cb) { + async.forEach(dataArray, function(element, cb) { var sql = "select content,rowid from " + tableName + " where num = " + element; connection.execute( - sql, - [], - option, - function(err, result) { - should.not.exist(err); - var resultVal_1 = result.rows[0][0]; - var resultVal_2 = result.rows[0][1]; - if(object === true) { - resultVal_1 = result.rows[0].CONTENT; - resultVal_2 = result.rows[0].ROWID; - } - if(array === true) { - resultVal_1 = result.outBinds.CONTENT; - resultVal_2 = result.outBinds.ROWID; - } - should.strictEqual(typeof resultVal_1, "string"); - should.strictEqual(resultVal_1, resultVal_2); - cb(); + sql, + [], + option, + function(err, result) { + should.not.exist(err); + var resultVal_1 = result.rows[0][0]; + var resultVal_2 = result.rows[0][1]; + if(object === true) { + resultVal_1 = result.rows[0].CONTENT; + resultVal_2 = result.rows[0].ROWID; } - ); + should.strictEqual(typeof resultVal_1, "string"); + should.strictEqual(resultVal_1, resultVal_2); + cb(); + } + ); }, function(err) { should.not.exist(err); callback(); @@ -613,7 +612,7 @@ describe('116. fetchUrowidAsString.js', function() { } function test2(option, object, array, callback) { - async.forEach(array, function(element, cb) { + async.forEach(dataArray, function(element, cb) { var sql = "select content,rowid from " + tableName + " where num = " + element; connection.execute( sql, @@ -629,10 +628,6 @@ describe('116. fetchUrowidAsString.js', function() { resultVal_1 = row.CONTENT; resultVal_2 = row.ROWID; } - if(array === true) { - resultVal_1 = row.outBinds.CONTENT; - resultVal_2 = row.outBinds.ROWID; - } should.strictEqual(typeof resultVal_1, "string"); should.strictEqual(resultVal_1, resultVal_2); result.resultSet.close(function(err) { @@ -667,10 +662,10 @@ describe('116. fetchUrowidAsString.js', function() { function testQueryStream(option, callback) { var sql = "select CONTENT from " + tableName; var stream = connection.queryStream( - sql, - [], - option - ); + sql, + [], + option + ); var result = []; stream.on('data', function(data) { diff --git a/test/fetchUrowidAsString_indexed.js b/test/fetchUrowidAsString_indexed.js index 77948944..fbfaf79b 100644 --- a/test/fetchUrowidAsString_indexed.js +++ b/test/fetchUrowidAsString_indexed.js @@ -24,7 +24,7 @@ * DESCRIPTION * Testing Oracle data type support - UROWID. * To fetch UROWID columns as strings. - * Test UROWID greater than 200/500/4000 bytes. + * Test UROWID greater than 200/500 bytes. * * NUMBERING RULE * Test numbers follow this numbering rule: @@ -107,7 +107,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() { done(); }); - describe('117.1 works with fetchInfo option and urowid length > 200/500/4000', function() { + describe('117.1 works with fetchInfo option and urowid length > 200/500', function() { var option = { fetchInfo: { "content": { type: oracledb.STRING } } }; var maxRowBak; @@ -187,7 +187,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() { }); - describe('117.2 works with fetchInfo and outFormat = OBJECT, urowid length > 200/500/4000', function() { + describe('117.2 works with fetchInfo and outFormat = OBJECT, urowid length > 200/500', function() { var option = { outFormat: oracledb.OBJECT, fetchInfo: { "content": { type: oracledb.STRING } } @@ -271,7 +271,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() { }); - describe('117.3 works with fetchInfo and outFormat = ARRAY, urowid length > 200/500/4000', function() { + describe('117.3 works with fetchInfo and outFormat = ARRAY, urowid length > 200/500', function() { var option = { outFormat: oracledb.ARRAY, fetchInfo: { "content": { type: oracledb.STRING } } @@ -355,7 +355,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() { }); - describe('117.4 fetch as string by default, urowid length > 200/500/4000', function() { + describe('117.4 fetch as string by default, urowid length > 200/500', function() { var option = {}; var maxRowBak; @@ -434,7 +434,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() { }); - describe('117.5 fetch as string by default with outFormat = OBJECT, urowid length > 200/500/4000', function() { + describe('117.5 fetch as string by default with outFormat = OBJECT, urowid length > 200/500', function() { var option = { outFormat: oracledb.OBJECT }; var maxRowBak; @@ -514,7 +514,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() { }); - describe('117.6 fetch as string by default with outFormat = ARRAY, urowid length > 200/500/4000', function() { + describe('117.6 fetch as string by default with outFormat = ARRAY, urowid length > 200/500', function() { var option = { outFormat: oracledb.ARRAY }; var maxRowBak; @@ -609,13 +609,6 @@ describe('117. fetchUrowidAsString_indexed.js', function() { var id = insertID++; if(rsFlag === true) fetchRowid_rs(id, strLength, rowidLenExpected, option, object, cb); else fetchRowid(id, strLength, rowidLenExpected, option, object, cb); - }, - function(cb) { - var strLength = 3000; - var rowidLenExpected = 4000; - var id = insertID++; - if(rsFlag === true) fetchRowid_rs(id, strLength, rowidLenExpected, option, object, cb); - else fetchRowid(id, strLength, rowidLenExpected, option, object, cb); } ], callback); } @@ -646,27 +639,19 @@ describe('117. fetchUrowidAsString_indexed.js', function() { option, function(err, result) { should.not.exist(err); - if(rowidLenExpected < 4000) { - urowid_2 = result.rows[0][0]; - if(object === true) { - urowid_2 = result.rows[0].CONTENT; - } - should.strictEqual(typeof urowid_2, "string"); - } else { - should.strictEqual(typeof urowid_2, "undefined"); + urowid_2 = result.rows[0][0]; + if(object === true) { + urowid_2 = result.rows[0].CONTENT; } + should.strictEqual(typeof urowid_2, "string"); cb(); } ); }, function(cb) { - if(rowidLenExpected < 4000) { - urowid_1.length.should.above(rowidLenExpected); - urowid_2.length.should.above(rowidLenExpected); - should.strictEqual(urowid_1, urowid_2); - } else { - urowid_1.length.should.above(rowidLenExpected); - } + urowid_1.length.should.above(rowidLenExpected); + urowid_2.length.should.above(rowidLenExpected); + should.strictEqual(urowid_1, urowid_2); cb(); } ], callback); @@ -701,15 +686,11 @@ describe('117. fetchUrowidAsString_indexed.js', function() { result.resultSet.getRow( function(error, row) { should.not.exist(error); - if(rowidLenExpected < 4000) { - urowid_2 = row[0]; - if(object === true) { - urowid_2 = row.CONTENT; - } - should.strictEqual(typeof urowid_2, "string"); - } else { - should.strictEqual(typeof urowid_2, "undefined"); + urowid_2 = row[0]; + if(object === true) { + urowid_2 = row.CONTENT; } + should.strictEqual(typeof urowid_2, "string"); result.resultSet.close(function(err) { should.not.exist(err); cb(); @@ -720,13 +701,9 @@ describe('117. fetchUrowidAsString_indexed.js', function() { ); }, function(cb) { - if(rowidLenExpected < 4000) { - urowid_1.length.should.above(rowidLenExpected); - urowid_2.length.should.above(rowidLenExpected); - should.strictEqual(urowid_1, urowid_2); - } else { - urowid_1.length.should.above(rowidLenExpected); - } + urowid_1.length.should.above(rowidLenExpected); + urowid_2.length.should.above(rowidLenExpected); + should.strictEqual(urowid_1, urowid_2); cb(); } ], callback); @@ -889,13 +866,8 @@ describe('117. fetchUrowidAsString_indexed.js', function() { connection.execute( "insert into " + tableName_normal + " (id, content) values (" + id + ", '" + urowid + "')", function(err, result) { - if(urowidLen > 4000) { - should.exist(err); - should.strictEqual(err.message, "ORA-01704: string literal too long"); - } else { - should.not.exist(err); - (result.rowsAffected).should.be.exactly(1); - } + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); cb(); } ); diff --git a/test/file.js b/test/file.js index b9dbfa33..702ab34f 100644 --- a/test/file.js +++ b/test/file.js @@ -27,6 +27,7 @@ 'use strict'; var should = require('should'); var fs = require('fs'); +var random = require('./random.js'); var file = exports; module.exports = file; @@ -48,3 +49,10 @@ file.delete = function(filePath) { }); } }; + +file.createFileInKB = function(fileName, length, specialStr) { + var bigStr = random.getRandomString(length, specialStr); + var stream = fs.createWriteStream(fileName, { flags: 'w', defaultEncoding: 'utf8', autoClose: true }); + stream.write(bigStr); + stream.end(); +}; \ No newline at end of file diff --git a/test/lobBindAsStringBuffer.js b/test/lobBindAsStringBuffer.js index 4e33e3d6..06a427c9 100644 --- a/test/lobBindAsStringBuffer.js +++ b/test/lobBindAsStringBuffer.js @@ -688,35 +688,35 @@ describe('80. lobBindAsStringBuffer.js', function() { }, function(cb) { connection.execute( - sqlRun, - bindVar, - function(err, result) { - should.not.exist(err); - var specStrLength = specialStr.length; - var resultLength1 = result.outBinds.b.length; - should.strictEqual(resultLength1, size); - should.strictEqual(result.outBinds.b.toString('utf8', 0, specStrLength), specialStr); - should.strictEqual(result.outBinds.b.toString('utf8', (resultLength1 - specStrLength), resultLength1), specialStr); - var lob = result.outBinds.c; - should.exist(lob); - lob.setEncoding("utf8"); - var clobData = ''; - lob.on('data', function(chunk) { - clobData += chunk; - }); + sqlRun, + bindVar, + function(err, result) { + should.not.exist(err); + var specStrLength = specialStr.length; + var resultLength1 = result.outBinds.b.length; + should.strictEqual(resultLength1, size); + should.strictEqual(result.outBinds.b.toString('utf8', 0, specStrLength), specialStr); + should.strictEqual(result.outBinds.b.toString('utf8', (resultLength1 - specStrLength), resultLength1), specialStr); + var lob = result.outBinds.c; + should.exist(lob); + lob.setEncoding("utf8"); + var clobData = ''; + lob.on('data', function(chunk) { + clobData += chunk; + }); - lob.on('error', function(err) { - should.not.exist(err, "lob.on 'error' event."); - }); + lob.on('error', function(err) { + should.not.exist(err, "lob.on 'error' event."); + }); - lob.on('end', function() { - fs.readFile( inFileName, { encoding: 'utf8' }, function(err, originalData) { - should.not.exist(err); - should.strictEqual(clobData, originalData); - cb(); - }); + lob.on('end', function() { + fs.readFile( inFileName, { encoding: 'utf8' }, function(err, originalData) { + should.not.exist(err); + should.strictEqual(clobData, originalData); + cb(); }); }); + }); } ], done); }); // 80.2.3 diff --git a/test/longDMLBind.js b/test/longDMLBind.js index cb5883bf..1852c2e5 100644 --- a/test/longDMLBind.js +++ b/test/longDMLBind.js @@ -103,23 +103,23 @@ describe('125. longDMLBind.js', function() { it('125.1.1 works with data size 64K - 1', function(done) { var insertedStr = random.getRandomLengthString(65535); - test1(insertedStr, done); + test1(insertedStr, 65535, done); }); it('125.1.2 works with data size 64K', function(done) { var insertedStr = random.getRandomLengthString(65536); - test1(insertedStr, done); + test1(insertedStr, 65536, done); }); it('125.1.3 works with data size 64K + 1', function(done) { var insertedStr = random.getRandomLengthString(65537); - test1(insertedStr, done); + test1(insertedStr, 65537, done); }); it('125.1.4 works with data size 1MB + 1', function(done) { var size = 1 * 1024 * 1024 + 1; var insertedStr = random.getRandomLengthString(size); - test1(insertedStr, done); + test1(insertedStr, size, done); }); }); // 125.1 @@ -129,26 +129,26 @@ describe('125. longDMLBind.js', function() { it('125.2.1 works with data size 64K - 1', function(done) { var insertedStr = random.getRandomLengthString(100); var updateStr = random.getRandomLengthString(65535); - test2(insertedStr, updateStr, done); + test2(insertedStr, updateStr, 65535, done); }); it('125.2.2 works with data size 64K', function(done) { var insertedStr = random.getRandomLengthString(200); var updateStr = random.getRandomLengthString(65536); - test2(insertedStr, updateStr, done); + test2(insertedStr, updateStr, 65536, done); }); it('125.2.3 works with data size 64K + 1', function(done) { var insertedStr = random.getRandomLengthString(10); var updateStr = random.getRandomLengthString(65537); - test2(insertedStr, updateStr, done); + test2(insertedStr, updateStr, 65537, done); }); it('125.2.4 works with data size 1MB + 1', function(done) { var size = 1 * 1024 * 1024 + 1; var insertedStr = random.getRandomLengthString(65536); var updateStr = random.getRandomLengthString(size); - test2(insertedStr, updateStr, done); + test2(insertedStr, updateStr, size, done); }); }); // 125.3 @@ -163,10 +163,10 @@ describe('125. longDMLBind.js', function() { }); // 125.3 - var test1 = function(content, callback) { + var test1 = function(content, maxsize, callback) { async.series([ function(cb) { - insert(content, cb); + insert(content, maxsize, cb); }, function(cb) { fetch(content, cb); @@ -174,13 +174,13 @@ describe('125. longDMLBind.js', function() { ], callback); }; - var test2 = function(insertedStr, updateStr, callback) { + var test2 = function(insertedStr, updateStr, maxsize, callback) { async.series([ function(cb) { - insert(insertedStr, cb); + insert(insertedStr, insertedStr.length, cb); }, function(cb) { - update(updateStr, cb); + update(updateStr, maxsize, cb); }, function(cb) { fetch(updateStr, cb); @@ -191,7 +191,7 @@ describe('125. longDMLBind.js', function() { var test3 = function(insertedStr, updateStr, callback) { async.series([ function(cb) { - insert(insertedStr, cb); + insert(insertedStr, insertedStr.length, cb); }, function(cb) { returning(updateStr, cb); @@ -199,11 +199,11 @@ describe('125. longDMLBind.js', function() { ], callback); }; - var insert = function(content, callback) { + var insert = function(content, maxsize, callback) { var sql = "insert into " + tableName + " (id, content) values (:i, :c)"; var bindVar = { i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER }, - c: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING } + c: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: maxsize } }; connection.execute( sql, @@ -216,11 +216,11 @@ describe('125. longDMLBind.js', function() { ); }; - var update = function(content, callback) { + var update = function(content, maxsize, callback) { var sql = "update " + tableName + " set content = :c where id = :i"; var bindVar = { i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER }, - c: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING } + c: { val: content, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: maxsize } }; connection.execute( sql, @@ -245,7 +245,8 @@ describe('125. longDMLBind.js', function() { bindVar, function(err) { should.exist(err); - should.strictEqual(err.message, "ORA-22816: unsupported feature with RETURNING clause"); + // ORA-22816: unsupported feature with RETURNING clause + (err.message).should.startWith("ORA-22816:"); callback(); } ); diff --git a/test/longrawDMLBind.js b/test/longrawDMLBind.js index c6d3051c..bf5a8496 100644 --- a/test/longrawDMLBind.js +++ b/test/longrawDMLBind.js @@ -108,33 +108,50 @@ describe('126. longrawDMLBind.js', function() { it('126.1.1 works with data size 64K - 1', function(done) { var insertedStr = random.getRandomLengthString(65535); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - test1(insertedBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var maxsize = 65535; + test1(insertedBuf, maxsize, done); }); it('126.1.2 works with data size 64K', function(done) { var insertedStr = random.getRandomLengthString(65536); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - test1(insertedBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var maxsize = 65536; + test1(insertedBuf, maxsize, done); }); it('126.1.3 works with data size 64K + 1', function(done) { var insertedStr = random.getRandomLengthString(65537); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - test1(insertedBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var maxsize = 65537; + test1(insertedBuf, maxsize, done); }); it('126.1.4 works with data size 1MB + 1', function(done) { var size = 1 * 1024 * 1024 + 1; var insertedStr = random.getRandomLengthString(size); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - test1(insertedBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + test1(insertedBuf, size, done); }); it('126.1.5 works with data size 100', function(done) { var insertedStr = random.getRandomLengthString(100); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - test1(insertedBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + test1(insertedBuf, 100, done); + }); + + it('126.1.6 set maxSize to 2000', function(done) { + var insertedStr = random.getRandomLengthString(100); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var maxsize = 2000; + test1(insertedBuf, maxsize, done); + }); + + it('126.1.7 set maxSize to 4GB', function(done) { + var insertedStr = random.getRandomLengthString(100); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var maxsize = 4 * 1024 * 1024 * 1024; + test1(insertedBuf, maxsize, done); }); }); // 126.1 @@ -144,34 +161,51 @@ describe('126. longrawDMLBind.js', function() { it('126.2.1 works with data size 64K - 1', function(done) { var insertedStr = random.getRandomLengthString(100); var updateStr = random.getRandomLengthString(65535); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); - test2(insertedBuf, updateBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); + test2(insertedBuf, updateBuf, 65535, done); }); it('126.2.2 works with data size 64K', function(done) { var insertedStr = random.getRandomLengthString(200); var updateStr = random.getRandomLengthString(65536); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); - test2(insertedBuf, updateBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); + test2(insertedBuf, updateBuf, 65536, done); }); it('126.2.3 works with data size 64K + 1', function(done) { var insertedStr = random.getRandomLengthString(10); var updateStr = random.getRandomLengthString(65537); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); - test2(insertedBuf, updateBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); + test2(insertedBuf, updateBuf, 65537, done); }); it('126.2.4 works with data size 1MB + 1', function(done) { var size = 1 * 1024 * 1024 + 1; var insertedStr = random.getRandomLengthString(65536); var updateStr = random.getRandomLengthString(size); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); - test2(insertedBuf, updateBuf, done); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); + test2(insertedBuf, updateBuf, size, done); + }); + + it('126.2.5 set maxSize to 2000', function(done) { + var insertedStr = random.getRandomLengthString(100); + var updateStr = random.getRandomLengthString(500); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); + test2(insertedBuf, updateBuf, 2000, done); + }); + + it('126.2.6 set maxSize to 4GB', function(done) { + var insertedStr = random.getRandomLengthString(100); + var updateStr = random.getRandomLengthString(500); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); + var maxsize = 4 * 1024 * 1024 * 1024; + test2(insertedBuf, updateBuf, maxsize, done); }); }); // 126.2 @@ -181,17 +215,17 @@ describe('126. longrawDMLBind.js', function() { it('126.3.1 do not support in returning into', function(done) { var insertedStr = random.getRandomLengthString(100); var updateStr = random.getRandomLengthString(65535); - var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr); - var updateBuf = node6plus ? new Buffer(updateStr) : Buffer.from(updateStr); + var insertedBuf = node6plus ? Buffer.from(insertedStr) : new Buffer(insertedStr); + var updateBuf = node6plus ? Buffer.from(updateStr) : new Buffer(updateStr); test3(insertedBuf, updateBuf, done); }); }); // 126.3 - var test1 = function(content, callback) { + var test1 = function(content, maxsize, callback) { async.series([ function(cb) { - insert(content, cb); + insert(content, maxsize, cb); }, function(cb) { fetch(content, cb); @@ -199,13 +233,13 @@ describe('126. longrawDMLBind.js', function() { ], callback); }; - var test2 = function(insertedStr, updateStr, callback) { + var test2 = function(insertedStr, updateStr, maxsize, callback) { async.series([ function(cb) { - insert(insertedStr, cb); + insert(insertedStr, insertedStr.length, cb); }, function(cb) { - update(updateStr, cb); + update(updateStr, maxsize, cb); }, function(cb) { fetch(updateStr, cb); @@ -216,7 +250,7 @@ describe('126. longrawDMLBind.js', function() { var test3 = function(insertedStr, updateStr, callback) { async.series([ function(cb) { - insert(insertedStr, cb); + insert(insertedStr, insertedStr.length, cb); }, function(cb) { returning(updateStr, cb); @@ -224,11 +258,11 @@ describe('126. longrawDMLBind.js', function() { ], callback); }; - var insert = function(content, callback) { + var insert = function(content, maxsize, callback) { var sql = "insert into " + tableName + " (id, content) values (:i, :c)"; var bindVar = { i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER }, - c: { val: content, dir: oracledb.BIND_IN, type: oracledb.BUFFER } + c: { val: content, dir: oracledb.BIND_IN, type: oracledb.BUFFER, maxSize: maxsize } }; connection.execute( sql, @@ -241,11 +275,11 @@ describe('126. longrawDMLBind.js', function() { ); }; - var update = function(content, callback) { + var update = function(content, maxsize, callback) { var sql = "update " + tableName + " set content = :c where id = :i"; var bindVar = { i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER }, - c: { val: content, dir: oracledb.BIND_IN, type: oracledb.BUFFER } + c: { val: content, dir: oracledb.BIND_IN, type: oracledb.BUFFER, maxSize: maxsize } }; connection.execute( sql, diff --git a/test/nclobDMLBindAsString.js b/test/nclobDMLBindAsString.js index 26d95572..be1ff161 100644 --- a/test/nclobDMLBindAsString.js +++ b/test/nclobDMLBindAsString.js @@ -144,12 +144,12 @@ describe('124. nclobDMLBindAsString.js', function() { var insertData = function(tableName, insertStr, callback) { var sql = "INSERT INTO " + tableName + "(num, content) VALUES(" + insertID + ", TO_NCLOB('" + insertStr + "'))"; connection.execute( - sql, - function(err) { - should.not.exist(err); - callback(); - } - ); + sql, + function(err) { + should.not.exist(err); + callback(); + } + ); }; var bindIn = function(tableName, insertStr, callback) { diff --git a/test/nestedCursor.js b/test/nestedCursor.js index 17306982..de45b84a 100644 --- a/test/nestedCursor.js +++ b/test/nestedCursor.js @@ -34,17 +34,17 @@ * 51 onwards are for other tests * *****************************************************************************/ - "use strict"; +"use strict"; - var oracledb = require('oracledb'); - var should = require('should'); - var async = require('async'); - var dbConfig = require('./dbconfig.js'); +var oracledb = require('oracledb'); +var should = require('should'); +var async = require('async'); +var dbConfig = require('./dbconfig.js'); - describe('57. nestedCursor.js', function() { +describe('57. nestedCursor.js', function() { - var connection = null; - var createParentTable = + var connection = null; + var createParentTable = "BEGIN \ DECLARE \ e_table_missing EXCEPTION; \ @@ -79,7 +79,7 @@ '); \ END; "; - var createChildTable = + var createChildTable = "BEGIN \ DECLARE \ e_table_missing EXCEPTION; \ @@ -131,78 +131,78 @@ '); \ END; "; - before(function(done) { - async.series([ - function(callback) { - oracledb.getConnection( - { - user: dbConfig.user, - password: dbConfig.password, - connectString: dbConfig.connectString - }, + before(function(done) { + async.series([ + function(callback) { + oracledb.getConnection( + { + user: dbConfig.user, + password: dbConfig.password, + connectString: dbConfig.connectString + }, function(err, conn) { connection = conn; callback(); } ); - }, - function(callback) { - connection.should.be.ok(); - connection.execute( + }, + function(callback) { + connection.should.be.ok(); + connection.execute( createParentTable, function(err) { should.not.exist(err); callback(); } ); - }, - function(callback) { - connection.should.be.ok(); - connection.execute( + }, + function(callback) { + connection.should.be.ok(); + connection.execute( createChildTable, function(err) { should.not.exist(err); callback(); } ); - } - ], done); + } + ], done); - }); + }); - after(function(done) { - async.series([ - function(callback) { - connection.execute( + after(function(done) { + async.series([ + function(callback) { + connection.execute( "DROP TABLE nodb_child_tab PURGE", function(err) { should.not.exist(err); callback(); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "DROP TABLE nodb_parent_tab PURGE", function(err) { should.not.exist(err); callback(); } ); - }, - function(callback) { - connection.release( function(err) { - should.not.exist(err); - callback(); - }); - } - ], done); - }); + }, + function(callback) { + connection.release( function(err) { + should.not.exist(err); + callback(); + }); + } + ], done); + }); - it('57.1 testing nested cursor support - result set', function(done) { - connection.should.be.ok(); + it('57.1 testing nested cursor support - result set', function(done) { + connection.should.be.ok(); - var sql = + var sql = "SELECT p.description, \ CURSOR( \ SELECT c.description \ @@ -211,7 +211,7 @@ ) children \ FROM nodb_parent_tab p"; - connection.execute( + connection.execute( sql, [], { resultSet: true }, @@ -224,10 +224,10 @@ } ); - }); // 57.1 + }); // 57.1 - it('57.2 testing nested cursor support - REF Cursor', function(done) { - var testproc = + it('57.2 testing nested cursor support - REF Cursor', function(done) { + var testproc = "CREATE OR REPLACE PROCEDURE nodb_get_family_tree(p_out OUT SYS_REFCURSOR) \ AS \ BEGIN \ @@ -241,22 +241,22 @@ FROM nodb_parent_tab p; \ END; "; - async.series([ - function(callback) { - connection.execute( + async.series([ + function(callback) { + connection.execute( testproc, function(err) { should.not.exist(err); callback(); } ); - }, - function(callback){ - connection.execute( + }, + function(callback){ + connection.execute( "BEGIN nodb_get_family_tree(:out); END;", - { - out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }, + { + out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, function(err, result) { should.exist(err); (err.message).should.startWith('NJS-010:'); @@ -265,17 +265,17 @@ callback(); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "DROP PROCEDURE nodb_get_family_tree", function(err) { should.not.exist(err); callback(); } ); - } - ], done); - }); // 57.2 + } + ], done); + }); // 57.2 - }); +}); diff --git a/test/nullColumnValues.js b/test/nullColumnValues.js index e13c0c64..159dca8f 100644 --- a/test/nullColumnValues.js +++ b/test/nullColumnValues.js @@ -222,16 +222,16 @@ describe('10. nullColumnValues.js', function() { rdname: { type: oracledb.STRING, dir: oracledb.BIND_OUT }, rmid: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT } }, - { autoCommit: true }, - function(err, result) { - should.not.exist(err); - //console.log(result); - result.outBinds.should.eql({rdid: [90], rdname: [null], rmid: [null]}); - result.outBinds.rdid.should.eql( [90] ); - should.not.exist(result.outBinds.rdname[0]); // null - should.not.exist(result.outBinds.rmid[0]); // null - done(); - } + { autoCommit: true }, + function(err, result) { + should.not.exist(err); + //console.log(result); + result.outBinds.should.eql({rdid: [90], rdname: [null], rmid: [null]}); + result.outBinds.rdid.should.eql( [90] ); + should.not.exist(result.outBinds.rdname[0]); // null + should.not.exist(result.outBinds.rmid[0]); // null + done(); + } ); }); diff --git a/test/opts/mocha.opts b/test/opts/mocha.opts index b524d0f4..4ce4693b 100644 --- a/test/opts/mocha.opts +++ b/test/opts/mocha.opts @@ -1,3 +1,4 @@ + --require should --require async --reporter spec @@ -124,5 +125,7 @@ test/urowidFunctionBindAsString_bind.js test/urowidFunctionBindAsString_bindinout.js test/dataTypeNclob.js test/nclobDMLBindAsString.js +test/blobStream.js +test/clobStream.js test/longDMLBind.js test/longrawDMLBind.js diff --git a/test/plsqlBindIndexedTable2.js b/test/plsqlBindIndexedTable2.js index ddb98c03..0df93160 100644 --- a/test/plsqlBindIndexedTable2.js +++ b/test/plsqlBindIndexedTable2.js @@ -326,7 +326,7 @@ describe('44. plsqlBindIndexedTable2.js', function() { "BEGIN nodb_beachpkg.array_in(:beach_in, :depth_in); END;", { beach_in: { //type: oracledb.STRING, - //dir: oracledb.BIND_IN, + //dir: oracledb.BIND_IN, val: ["Malibu Beach", "Bondi Beach", "Waikiki Beach"] }, depth_in: { type: oracledb.NUMBER, dir: oracledb.BIND_IN, @@ -400,7 +400,7 @@ describe('44. plsqlBindIndexedTable2.js', function() { "BEGIN nodb_beachpkg.array_in(:1, :2); END;", [ { type: oracledb.STRING, - // dir: oracledb.BIND_IN, + // dir: oracledb.BIND_IN, val: ["Malibu Beach", "Bondi Beach", "Waikiki Beach"] }, { type: oracledb.NUMBER, dir: oracledb.BIND_IN, diff --git a/test/plsqlBindScalar.js b/test/plsqlBindScalar.js index 0b09dff3..f6a3c8eb 100644 --- a/test/plsqlBindScalar.js +++ b/test/plsqlBindScalar.js @@ -1029,12 +1029,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc508, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc508, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -1079,12 +1079,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc509, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc509, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -1129,12 +1129,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc510, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc510, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -1180,35 +1180,35 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc511, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc511, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( - sqlrun511, - bindVar, - function(err, result) { - should.not.exist(err); - // console.log(result); - var resultVar = "Pack my bag with fiv"; - //var resultVar=strVar.substr(0,(strVar.length-1)/2); - should.strictEqual(result.outBinds.p_inout, resultVar); - cb(); - } - ); + sqlrun511, + bindVar, + function(err, result) { + should.not.exist(err); + // console.log(result); + var resultVar = "Pack my bag with fiv"; + //var resultVar=strVar.substr(0,(strVar.length-1)/2); + should.strictEqual(result.outBinds.p_inout, resultVar); + cb(); + } + ); }, function(cb) { connection.execute( - sqldrop, - function(err) { - should.not.exist(err); - cb(); - } - ); + sqldrop, + function(err) { + should.not.exist(err); + cb(); + } + ); } ], done); }); // 70.5.11 @@ -1452,12 +1452,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc610, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc610, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -1502,12 +1502,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc611, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc611, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -1774,12 +1774,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc710, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc710, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -1824,12 +1824,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc711, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc711, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -3430,15 +3430,15 @@ describe('70. plsqlBindScalar.js', function() { }; connection.execute( - sqlrun_dt, - bindVar, - function(err, result) { - should.not.exist(err); - var expectDate = "2016-09-10 14:10:10.123000000"; - (result.outBinds.output).should.eql(expectDate); - done(); - } - ); + sqlrun_dt, + bindVar, + function(err, result) { + should.not.exist(err); + var expectDate = "2016-09-10 14:10:10.123000000"; + (result.outBinds.output).should.eql(expectDate); + done(); + } + ); }); // 70.12.1 it('70.12.2 val: null', function(done) { @@ -3929,12 +3929,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc71410, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc71410, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -3978,12 +3978,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc71411, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc71411, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -4726,12 +4726,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc71810, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc71810, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -4775,12 +4775,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc71811, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc71811, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -5525,12 +5525,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc72210, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc72210, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( @@ -5574,12 +5574,12 @@ describe('70. plsqlBindScalar.js', function() { async.series([ function(cb) { connection.execute( - proc72211, - function(err) { - should.not.exist(err); - cb(); - } - ); + proc72211, + function(err) { + should.not.exist(err); + cb(); + } + ); }, function(cb) { connection.execute( diff --git a/test/pool.js b/test/pool.js index a9a54a12..a9d8195d 100644 --- a/test/pool.js +++ b/test/pool.js @@ -74,7 +74,7 @@ describe('2. pool.js', function() { done(); }); } - ); + ); }); diff --git a/test/poolCache.js b/test/poolCache.js index 4a3f9d5d..e5ca6891 100644 --- a/test/poolCache.js +++ b/test/poolCache.js @@ -613,7 +613,7 @@ describe('67. poolCache.js', function() { }); }); // 67.2 -// This suite extends 67.1.6 case with various types + // This suite extends 67.1.6 case with various types describe('67.3 poolAlias attribute', function() { it('67.3.1 throws an error if poolAttrs.poolAlias is an object', function(done) { diff --git a/test/poolClose.js b/test/poolClose.js index 00ec3da1..c21c1277 100644 --- a/test/poolClose.js +++ b/test/poolClose.js @@ -81,12 +81,10 @@ describe('51. poolClose.js', function(){ ); var inUse; - should.throws( - function() { - inUse = pool.connectionsInUse; - }, - /NJS-002: invalid pool/ - ); + pool.terminate(function(err) { + should.exist(err); + should.strictEqual(err.message, "NJS-002: invalid pool"); + }); should.not.exist(inUse); done(); @@ -122,14 +120,15 @@ describe('51. poolClose.js', function(){ function(err, pool) { should.not.exist(err); pool.should.be.ok(); + pool.terminate(function(err) { should.not.exist(err); - should.throws( - function() { - pool.terminate(function() {}); - }, - /NJS-002: invalid pool/ - ); + + pool.terminate(function(err) { + should.exist(err); + should.strictEqual(err.message, "NJS-002: invalid pool"); + }); + done(); }); // terminate() } @@ -142,14 +141,15 @@ describe('51. poolClose.js', function(){ function(err, pool) { should.not.exist(err); pool.should.be.ok(); + pool.close(function(err) { should.not.exist(err); - should.throws( - function() { - pool.close(function() {}); - }, - /NJS-002: invalid pool/ - ); + + pool.close(function(err) { + should.exist(err); + should.strictEqual(err.message, "NJS-002: invalid pool"); + }); + done(); }); // terminate() } @@ -216,13 +216,11 @@ describe('51. poolClose.js', function(){ }); }, function close2(cb) { - should.throws( - function() { - conn.close(function() {}); - }, - /NJS-003: invalid connection/ - ); - cb(); + conn.close(function(err) { + should.exist(err); + should.strictEqual(err.message, 'NJS-003: invalid connection'); + cb(); + }); }, function(cb) { pool.terminate(function(err) { @@ -233,7 +231,7 @@ describe('51. poolClose.js', function(){ ], done); }); // 51.6 - it.skip('51.7 can not get connection in promise version from the terminated pool', function(done) { + it('51.7 can not get connection in promise version from the terminated pool', function(done) { oracledb.createPool( dbConfig, function(err, pool) { @@ -243,16 +241,22 @@ describe('51. poolClose.js', function(){ pool.terminate(function(err) { should.not.exist(err); - try { - var conn = pool.getConnection(); - should.strictEqual(Object.prototype.toString.call(conn), "[object Promise]"); - } catch(err) { - should.exist(err); - should.strictEqual(err.message, "NJS-002: invalid pool"); - } - done(); + var promise = pool.getConnection(); + + promise + .then(function(conn) { + should.not.exist(conn); + }) + .catch(function(err) { + should.exist(err); + should.strictEqual(err.message, "NJS-002: invalid pool"); + }) + .then(function() { + done(); + }); }); // terminate() } ); // createPool() }); // 51.7 + }); diff --git a/test/resultSet1.js b/test/resultSet1.js index a2f10987..ed470442 100644 --- a/test/resultSet1.js +++ b/test/resultSet1.js @@ -961,13 +961,11 @@ describe('12. resultSet1.js', function() { rs.close(function(err) { should.not.exist(err); accessCount.should.be.exactly(10); - try { - rs.close(function() {}); - } catch (err) { + rs.close(function(err) { should.exist(err); (err.message).should.startWith('NJS-018:'); done(); - } + }); }); } }); @@ -997,13 +995,11 @@ describe('12. resultSet1.js', function() { } else { rs.close(function(err) { should.not.exist(err); - try { - rs.getRows(numRows, function() {}); - } catch (err) { + rs.getRows(numRows, function(err) { should.exist(err); (err.message).should.startWith('NJS-018:'); done(); - } + }); }); } }); @@ -1418,7 +1414,7 @@ describe('12. resultSet1.js', function() { should.strictEqual( err.message, 'NJS-019: ResultSet cannot be returned for non-query statements' - ); + ); done(); } ); diff --git a/test/resultSet2.js b/test/resultSet2.js index 56e6c9df..6acc68c6 100644 --- a/test/resultSet2.js +++ b/test/resultSet2.js @@ -31,46 +31,46 @@ * 51 onwards are for other tests * *****************************************************************************/ - "use strict"; +"use strict"; - var oracledb = require('oracledb'); - var should = require('should'); - var async = require('async'); - var dbConfig = require('./dbconfig.js'); +var oracledb = require('oracledb'); +var should = require('should'); +var async = require('async'); +var dbConfig = require('./dbconfig.js'); - describe('55. resultSet2.js', function() { +describe('55. resultSet2.js', function() { - var connection = null; - var tableName = "nodb_rs2_emp"; - var rowsAmount = 300; + var connection = null; + var tableName = "nodb_rs2_emp"; + var rowsAmount = 300; - before('get one connection', function(done) { - oracledb.getConnection( - { - user: dbConfig.user, - password: dbConfig.password, - connectString: dbConfig.connectString - }, + before('get one connection', function(done) { + oracledb.getConnection( + { + user: dbConfig.user, + password: dbConfig.password, + connectString: dbConfig.connectString + }, function(err, conn) { should.not.exist(err); connection = conn; done(); } ); - }); + }); - after('release connection', function(done) { - connection.release( function(err) { - should.not.exist(err); - done(); - }); - }); + after('release connection', function(done) { + connection.release( function(err) { + should.not.exist(err); + done(); + }); + }); - describe('55.1 query a RDBMS function', function() { + describe('55.1 query a RDBMS function', function() { - it('55.1.1 LPAD function', function(done) { - connection.should.be.ok(); - connection.execute( + it('55.1.1 LPAD function', function(done) { + connection.should.be.ok(); + connection.execute( "select lpad('a',100,'x') from dual", [], { resultSet: true }, @@ -80,37 +80,37 @@ } ); - function fetchRowFromRS(rs) { - rs.getRow(function(err, row) { - should.not.exist(err); - if(row) { + function fetchRowFromRS(rs) { + rs.getRow(function(err, row) { + should.not.exist(err); + if(row) { // console.log(row); - row[0].length.should.be.exactly(100); - return fetchRowFromRS(rs); - } else { - rs.close(function(err) { - should.not.exist(err); - done(); - }); - } - }); - } - }); - }); // 55.1 + row[0].length.should.be.exactly(100); + return fetchRowFromRS(rs); + } else { + rs.close(function(err) { + should.not.exist(err); + done(); + }); + } + }); + } + }); + }); // 55.1 - describe('55.2 binding variables', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.2 binding variables', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - it('55.2.1 query with one binding variable', function(done) { - connection.should.be.ok(); - var rowCount = 0; - connection.execute( + it('55.2.1 query with one binding variable', function(done) { + connection.should.be.ok(); + var rowCount = 0; + connection.execute( "SELECT * FROM nodb_rs2_emp WHERE employees_id > :1", [200], { resultSet: true }, @@ -121,40 +121,40 @@ } ); - function fetchRowFromRS(rs) { - rs.getRow(function(err, row) { - should.not.exist(err); - if(row) { - rowCount++; - return fetchRowFromRS(rs); - } else { - rs.close(function(err) { - rowCount.should.be.exactly(100); - should.not.exist(err); - done(); - }); - } - }); - } - }); + function fetchRowFromRS(rs) { + rs.getRow(function(err, row) { + should.not.exist(err); + if(row) { + rowCount++; + return fetchRowFromRS(rs); + } else { + rs.close(function(err) { + rowCount.should.be.exactly(100); + should.not.exist(err); + done(); + }); + } + }); + } + }); - }); + }); - describe('55.3 alternating getRow() & getRows() function', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.3 alternating getRow() & getRows() function', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - it('55.3.1 result set', function(done) { - connection.should.be.ok(); - var accessCount = 0; - var numRows = 4; - var flag = 1; // 1 - getRow(); 2 - getRows(); 3 - to close resultSet. - connection.execute( + it('55.3.1 result set', function(done) { + connection.should.be.ok(); + var accessCount = 0; + var numRows = 4; + var flag = 1; // 1 - getRow(); 2 - getRows(); 3 - to close resultSet. + connection.execute( "SELECT * FROM nodb_rs2_emp WHERE employees_id > :1", [200], { resultSet: true }, @@ -165,151 +165,149 @@ } ); - function fetchRowFromRS(rs) { - if(flag === 1) { - rs.getRow(function(err, row) { - should.not.exist(err); - if(row) { - flag = 2; - accessCount++; - return fetchRowFromRS(rs); - } else { - flag = 3; - return fetchRowFromRS(rs); - } - }); - } - else if(flag === 2) { - rs.getRows(numRows, function(err, rows) { - should.not.exist(err); - if(rows.length > 0) { - flag = 1; - accessCount++; - return fetchRowFromRS(rs); - } else { - flag = 3; - return fetchRowFromRS(rs); - } - }); - } - else if(flag === 3) { + function fetchRowFromRS(rs) { + if(flag === 1) { + rs.getRow(function(err, row) { + should.not.exist(err); + if(row) { + flag = 2; + accessCount++; + return fetchRowFromRS(rs); + } else { + flag = 3; + return fetchRowFromRS(rs); + } + }); + } + else if(flag === 2) { + rs.getRows(numRows, function(err, rows) { + should.not.exist(err); + if(rows.length > 0) { + flag = 1; + accessCount++; + return fetchRowFromRS(rs); + } else { + flag = 3; + return fetchRowFromRS(rs); + } + }); + } + else if(flag === 3) { // console.log("resultSet is empty!"); - rs.close(function(err) { - should.not.exist(err); + rs.close(function(err) { + should.not.exist(err); // console.log("Total access count is " + accessCount); - accessCount.should.be.exactly((100/(numRows + 1)) * 2); - done(); - }); - } - } - }); + accessCount.should.be.exactly((100/(numRows + 1)) * 2); + done(); + }); + } + } + }); - it('55.3.2 REF Cursor', function(done) { - connection.should.be.ok(); - var accessCount = 0; - var numRows = 4; - var flag = 1; // 1 - getRow(); 2 - getRows(); 3 - to close resultSet. + it('55.3.2 REF Cursor', function(done) { + connection.should.be.ok(); + var accessCount = 0; + var numRows = 4; + var flag = 1; // 1 - getRow(); 2 - getRows(); 3 - to close resultSet. - connection.execute( + connection.execute( "BEGIN nodb_rs2_get_emp(:in, :out); END;", - { - in: 200, - out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }, + { + in: 200, + out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, function(err, result) { should.not.exist(err); fetchRowFromRS(result.outBinds.out, done); } ); - function fetchRowFromRS(rs, cb) { - if(flag === 1) { - rs.getRow(function(err, row) { - should.not.exist(err); - if(row) { - flag = 2; - accessCount++; - return fetchRowFromRS(rs, cb); - } else { - flag = 3; - return fetchRowFromRS(rs, cb); - } - }); - } - else if(flag === 2) { - rs.getRows(numRows, function(err, rows) { - should.not.exist(err); - if(rows.length > 0) { - flag = 1; - accessCount++; - return fetchRowFromRS(rs, cb); - } else { - flag = 3; - return fetchRowFromRS(rs, cb); - } - }); - } - else if(flag === 3) { + function fetchRowFromRS(rs, cb) { + if(flag === 1) { + rs.getRow(function(err, row) { + should.not.exist(err); + if(row) { + flag = 2; + accessCount++; + return fetchRowFromRS(rs, cb); + } else { + flag = 3; + return fetchRowFromRS(rs, cb); + } + }); + } + else if(flag === 2) { + rs.getRows(numRows, function(err, rows) { + should.not.exist(err); + if(rows.length > 0) { + flag = 1; + accessCount++; + return fetchRowFromRS(rs, cb); + } else { + flag = 3; + return fetchRowFromRS(rs, cb); + } + }); + } + else if(flag === 3) { // console.log("resultSet is empty!"); - rs.close(function(err) { - should.not.exist(err); + rs.close(function(err) { + should.not.exist(err); // console.log("Total access count is " + accessCount); - accessCount.should.be.exactly((100/(numRows + 1)) * 2); - cb(); - }); - } - } - }); - }); + accessCount.should.be.exactly((100/(numRows + 1)) * 2); + cb(); + }); + } + } + }); + }); - describe('55.4 release connection before close resultSet', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.4 release connection before close resultSet', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - beforeEach(function(done) { - oracledb.getConnection( - { - user: dbConfig.user, - password: dbConfig.password, - connectString: dbConfig.connectString - }, + beforeEach(function(done) { + oracledb.getConnection( + { + user: dbConfig.user, + password: dbConfig.password, + connectString: dbConfig.connectString + }, function(err, conn) { should.not.exist(err); conn2 = conn; done(); } ); - }); + }); - var conn2 = false; - function fetchRowFromRS(rs, cb) { + var conn2 = false; + function fetchRowFromRS(rs, cb) { - rs.getRow(function(err, row) { - if(row) { - return fetchRowFromRS(rs, cb); - } else { - conn2.release(function(err) { - should.not.exist(err); - try { - rs.close(function() {}); - } catch (err) { - should.exist(err); - err.message.should.startWith('NJS-018:'); // invalid result set - cb(); - } - }); - } - }); - } + rs.getRow(function(err, row) { + if(row) { + return fetchRowFromRS(rs, cb); + } else { + conn2.release(function(err) { + should.not.exist(err); + rs.close(function(err) { + should.exist(err); + err.message.should.startWith('NJS-018:'); // invalid result set + cb(); + }); + }); + } + }); + } - it('55.4.1 result set', function(done) { - conn2.should.be.ok(); - conn2.execute( + it('55.4.1 result set', function(done) { + conn2.should.be.ok(); + conn2.execute( "SELECT * FROM nodb_rs2_emp ORDER BY employees_id", [], { resultSet: true }, @@ -318,41 +316,41 @@ fetchRowFromRS(result.resultSet, done); } ); - }); + }); - it('55.4.2 REF Cursor', function(done) { - conn2.should.be.ok(); + it('55.4.2 REF Cursor', function(done) { + conn2.should.be.ok(); - conn2.execute( + conn2.execute( "BEGIN nodb_rs2_get_emp(:in, :out); END;", - { - in: 200, - out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }, + { + in: 200, + out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, function(err, result) { should.not.exist(err); fetchRowFromRS(result.outBinds.out, done); } ); - }); - }); + }); + }); - describe('55.5 the content of resultSet should be consistent', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.5 the content of resultSet should be consistent', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - it('55.5.1 (1) get RS (2) modify data in that table and commit (3) check RS', function(done) { - connection.should.be.ok(); - var rowsCount = 0; - var rs = false; - async.series([ - function(callback) { - connection.execute( + it('55.5.1 (1) get RS (2) modify data in that table and commit (3) check RS', function(done) { + connection.should.be.ok(); + var rowsCount = 0; + var rs = false; + async.series([ + function(callback) { + connection.execute( "SELECT * FROM nodb_rs2_emp ORDER BY employees_id", [], { resultSet: true }, @@ -362,9 +360,9 @@ callback(); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "TRUNCATE TABLE nodb_rs2_emp", [], { autoCommit: true }, @@ -373,64 +371,64 @@ callback(); } ); - }, - function(callback) { - fetchRowFromRS(rs, callback); - } - ], done); + }, + function(callback) { + fetchRowFromRS(rs, callback); + } + ], done); - function fetchRowFromRS(rset, cb) { - rset.getRow(function(err, row) { - should.not.exist(err); - if(row) { - rowsCount++; - return fetchRowFromRS(rset, cb); - } else { - rset.close(function(err) { - should.not.exist(err); - rowsCount.should.eql(rowsAmount); - cb(); - }); - } - }); - } + function fetchRowFromRS(rset, cb) { + rset.getRow(function(err, row) { + should.not.exist(err); + if(row) { + rowsCount++; + return fetchRowFromRS(rset, cb); + } else { + rset.close(function(err) { + should.not.exist(err); + rowsCount.should.eql(rowsAmount); + cb(); + }); + } + }); + } - }); + }); - }); + }); - describe('55.6 access resultSet simultaneously', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.6 access resultSet simultaneously', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - function fetchRowsFromRS(resultset, callback) { + function fetchRowsFromRS(resultset, callback) { - var numRows = 10; // number of rows to return from each call to getRows() - resultset.getRows(numRows, function(err, rows) { - if(err) { - return callback(err); - } else { - if(rows.length > 0) { - return fetchRowsFromRS(resultset, callback); - } else { - return callback(); - } - } - }); + var numRows = 10; // number of rows to return from each call to getRows() + resultset.getRows(numRows, function(err, rows) { + if(err) { + return callback(err); + } else { + if(rows.length > 0) { + return fetchRowsFromRS(resultset, callback); + } else { + return callback(); + } + } + }); - } + } - it('55.6.1 concurrent operations on resultSet are not allowed', function(done) { + it('55.6.1 concurrent operations on resultSet are not allowed', function(done) { - var rset; - async.series([ - function(cb) { - connection.execute( + var rset; + async.series([ + function(cb) { + connection.execute( "SELECT * FROM nodb_rs2_emp ORDER BY employees_id", [], { resultSet: true }, @@ -440,16 +438,16 @@ cb(); } ); - }, - function(cb) { - async.parallel([ - function(callback) { - fetchRowsFromRS(rset, callback); - }, - function(callback) { - fetchRowsFromRS(rset, callback); - } - ], + }, + function(cb) { + async.parallel([ + function(callback) { + fetchRowsFromRS(rset, callback); + }, + function(callback) { + fetchRowsFromRS(rset, callback); + } + ], function(err) { should.exist(err); (err.message).should.startWith('NJS-017:'); @@ -457,45 +455,45 @@ cb(); }); - }, - function(cb) { + }, + function(cb) { - rset.close(function() { - return cb(); - }); + rset.close(function() { + return cb(); + }); - } - ], done); + } + ], done); - }); + }); - it('55.6.2 concurrent operation on REF Cursor are not allowed', function(done) { + it('55.6.2 concurrent operation on REF Cursor are not allowed', function(done) { - var rcur; - async.series([ - function(cb) { - connection.execute( + var rcur; + async.series([ + function(cb) { + connection.execute( "BEGIN nodb_rs2_get_emp(:in, :out); END;", - { - in: 0, - out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }, + { + in: 0, + out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, function(err, result) { should.not.exist(err); rcur = result.outBinds.out; return cb(); } ); - }, - function(cb) { - async.parallel([ - function(callback) { - fetchRowsFromRS(rcur, callback); - }, - function(callback) { - fetchRowsFromRS(rcur, callback); - } - ], + }, + function(cb) { + async.parallel([ + function(callback) { + fetchRowsFromRS(rcur, callback); + }, + function(callback) { + fetchRowsFromRS(rcur, callback); + } + ], function(err) { should.exist(err); (err.message).should.startWith('NJS-017:'); @@ -503,64 +501,64 @@ cb(); }); - }, - function(cb) { + }, + function(cb) { - rcur.close(function() { - return cb(); - }); + rcur.close(function() { + return cb(); + }); - } - ], done); + } + ], done); - }); + }); - }); + }); - describe('55.7 getting multiple resultSets', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.7 getting multiple resultSets', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - var numRows = 10; // number of rows to return from each call to getRows() + var numRows = 10; // number of rows to return from each call to getRows() - function fetchRowFromRS(rs, cb) { - rs.getRow(function(err, row) { - should.not.exist(err); - if(row) { - return fetchRowFromRS(rs, cb); - } else { - rs.close(function(err) { - should.not.exist(err); - cb(); - }); - } - }); - } + function fetchRowFromRS(rs, cb) { + rs.getRow(function(err, row) { + should.not.exist(err); + if(row) { + return fetchRowFromRS(rs, cb); + } else { + rs.close(function(err) { + should.not.exist(err); + cb(); + }); + } + }); + } - function fetchRowsFromRS(rs, cb) { - rs.getRows(numRows, function(err, rows) { - should.not.exist(err); - if(rows.length > 0) { - return fetchRowsFromRS(rs, cb); - } else { - rs.close(function(err) { - should.not.exist(err); - cb(); - }); - } - }); - } + function fetchRowsFromRS(rs, cb) { + rs.getRows(numRows, function(err, rows) { + should.not.exist(err); + if(rows.length > 0) { + return fetchRowsFromRS(rs, cb); + } else { + rs.close(function(err) { + should.not.exist(err); + cb(); + }); + } + }); + } - it('55.7.1 can access multiple resultSet on one connection', function(done) { - connection.should.be.ok(); - async.parallel([ - function(callback) { - connection.execute( + it('55.7.1 can access multiple resultSet on one connection', function(done) { + connection.should.be.ok(); + async.parallel([ + function(callback) { + connection.execute( "SELECT * FROM nodb_rs2_emp ORDER BY employees_id", [], { resultSet: true }, @@ -569,9 +567,9 @@ fetchRowFromRS(result.resultSet, callback); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "SELECT * FROM nodb_rs2_emp ORDER BY employees_id", [], { resultSet: true }, @@ -580,62 +578,62 @@ fetchRowsFromRS(result.resultSet, callback); } ); - } - ], function(err) { - should.not.exist(err); - done(); - }); - }); + } + ], function(err) { + should.not.exist(err); + done(); + }); + }); - it('55.7.2 can access multiple REF Cursor', function(done) { - connection.should.be.ok(); + it('55.7.2 can access multiple REF Cursor', function(done) { + connection.should.be.ok(); - async.parallel([ - function(callback) { - connection.execute( + async.parallel([ + function(callback) { + connection.execute( "BEGIN nodb_rs2_get_emp(:in, :out); END;", - { - in: 200, - out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }, + { + in: 200, + out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, function(err, result) { should.not.exist(err); fetchRowFromRS(result.outBinds.out, callback); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "BEGIN nodb_rs2_get_emp(:in, :out); END;", - { - in: 100, - out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } - }, + { + in: 100, + out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, function(err, result) { should.not.exist(err); fetchRowsFromRS(result.outBinds.out, callback); } ); - } - ], function(err) { - should.not.exist(err); - done(); - }); - }); - }); + } + ], function(err) { + should.not.exist(err); + done(); + }); + }); + }); - describe('55.8 Negative - resultSet is only for query statement', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.8 Negative - resultSet is only for query statement', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - it('55.8.1 resultSet cannot be returned for non-query statements', function(done) { - connection.should.be.ok(); - connection.execute( + it('55.8.1 resultSet cannot be returned for non-query statements', function(done) { + connection.should.be.ok(); + connection.execute( "UPDATE nodb_rs2_emp SET employees_name = 'Alan' WHERE employees_id = 100", [], { resultSet: true }, @@ -647,20 +645,20 @@ } ); - }); - }); + }); + }); - describe('55.9 test querying a PL/SQL function', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.9 test querying a PL/SQL function', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - it('55.9.1 ', function(done) { - var proc = + it('55.9.1 ', function(done) { + var proc = "CREATE OR REPLACE FUNCTION nodb_rs2_testfunc RETURN VARCHAR2 \ IS \ emp_name VARCHAR2(20); \ @@ -669,18 +667,18 @@ RETURN emp_name; \ END; "; - async.series([ - function(callback) { - connection.execute( + async.series([ + function(callback) { + connection.execute( proc, function(err) { should.not.exist(err); callback(); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "SELECT nodb_rs2_testfunc FROM dual", [], { resultSet: true }, @@ -690,49 +688,49 @@ fetchRowFromRS(result.resultSet, callback); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "DROP FUNCTION nodb_rs2_testfunc", function(err) { should.not.exist(err); callback(); } ); - } - ], done); + } + ], done); - function fetchRowFromRS(rs, cb) { - rs.getRow(function(err, row) { - should.not.exist(err); - if(row) { - row[0].should.eql('Clark Kent'); - return fetchRowFromRS(rs, cb); - } else { - rs.close(function(err) { - should.not.exist(err); - cb(); - }); - } - }); - } - }); - }); + function fetchRowFromRS(rs, cb) { + rs.getRow(function(err, row) { + should.not.exist(err); + if(row) { + row[0].should.eql('Clark Kent'); + return fetchRowFromRS(rs, cb); + } else { + rs.close(function(err) { + should.not.exist(err); + cb(); + }); + } + }); + } + }); + }); - describe('55.10 calls getRows() once and then close RS before getting more rows', function() { - before(function(done){ - setUp(connection, tableName, done); - }); + describe('55.10 calls getRows() once and then close RS before getting more rows', function() { + before(function(done){ + setUp(connection, tableName, done); + }); - after(function(done) { - clearUp(connection, tableName, done); - }); + after(function(done) { + clearUp(connection, tableName, done); + }); - it('55.10.1 ', function(done) { - connection.should.be.ok(); - var numRows = 10; + it('55.10.1 ', function(done) { + connection.should.be.ok(); + var numRows = 10; - connection.execute( + connection.execute( "SELECT * FROM nodb_rs2_emp ORDER BY employees_id", [], { resultSet: true }, @@ -744,25 +742,26 @@ should.not.exist(err); result.resultSet.close(function(err) { should.not.exist(err); - try { - result.resultSet.getRows(numRows, function() {}); - } catch (err) { - should.exist(err); - err.message.should.startWith('NJS-018:'); - // invalid result set - done(); - } + fetchRowsFromRS(result.resultSet, numRows, done); }); } ); } ); + + function fetchRowsFromRS(rs, numRows, done) { + rs.getRows(numRows, function(err) { + should.exist(err); + err.message.should.startWith('NJS-018:'); // invalid result set + done(); + }); + } }); }); - describe('55.11 result set with unsupported data types', function() { - it('55.11.1 INTERVAL YEAR TO MONTH data type', function(done) { - connection.execute( + describe('55.11 result set with unsupported data types', function() { + it('55.11.1 INTERVAL YEAR TO MONTH data type', function(done) { + connection.execute( "SELECT dummy, to_yminterval('1-3') FROM dual", [], { resultSet: true }, @@ -774,22 +773,22 @@ done(); } ); - }); + }); - }); // 55.11 + }); // 55.11 - describe('55.12 bind a cursor BIND_INOUT', function() { + describe('55.12 bind a cursor BIND_INOUT', function() { - before('prepare table nodb_rs2_emp', function(done) { - setUp(connection, tableName, done); - }); + before('prepare table nodb_rs2_emp', function(done) { + setUp(connection, tableName, done); + }); - after('drop table', function(done) { - clearUp(connection, tableName, done); - }); + after('drop table', function(done) { + clearUp(connection, tableName, done); + }); - it('55.12.1 has not supported binding a cursor with BIND_INOUT', function(done) { - var proc = + it('55.12.1 has not supported binding a cursor with BIND_INOUT', function(done) { + var proc = "CREATE OR REPLACE PROCEDURE nodb_rs2_get_emp_inout (p_in IN NUMBER, p_out IN OUT SYS_REFCURSOR) \ AS \ BEGIN \ @@ -798,23 +797,23 @@ WHERE employees_id > p_in; \ END; "; - async.series([ - function(callback) { - connection.execute( + async.series([ + function(callback) { + connection.execute( proc, function(err) { should.not.exist(err); callback(); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "BEGIN nodb_rs2_get_emp_inout(:in, :out); END;", - { - in: 200, - out: { type: oracledb.CURSOR, dir: oracledb.BIND_INOUT } - }, + { + in: 200, + out: { type: oracledb.CURSOR, dir: oracledb.BIND_INOUT } + }, function(err) { should.exist(err); (err.message).should.startWith('NJS-007:'); @@ -822,114 +821,114 @@ callback(); } ); - }, - function(callback) { - connection.execute( + }, + function(callback) { + connection.execute( "DROP PROCEDURE nodb_rs2_get_emp_inout", function(err) { should.not.exist(err); callback(); } ); - } - ], done); - }); + } + ], done); + }); - }); // 55.12 + }); // 55.12 - describe('55.13 Invalid Ref Cursor', function() { - var proc = + describe('55.13 Invalid Ref Cursor', function() { + var proc = "CREATE OR REPLACE PROCEDURE get_invalid_refcur ( p OUT SYS_REFCURSOR) " + " AS " + " BEGIN " + " NULL; " + " END;"; - before(function(done){ - async.series([ - function(callback) { - setUp(connection, tableName, callback); - }, - function(callback) { - connection.execute( + before(function(done){ + async.series([ + function(callback) { + setUp(connection, tableName, callback); + }, + function(callback) { + connection.execute( proc, function(err) { should.not.exist(err); callback(); } ); - } - ], done); - }); + } + ], done); + }); - after(function(done) { - async.series([ - function(callback) { - connection.execute( + after(function(done) { + async.series([ + function(callback) { + connection.execute( "DROP PROCEDURE get_invalid_refcur", function(err) { should.not.exist(err); callback(); } ); - }, - function(callback) { - clearUp(connection, tableName, callback); - } - ], done); - }); + }, + function(callback) { + clearUp(connection, tableName, callback); + } + ], done); + }); - it('55.13.1 ', function (done ) { - connection.should.be.ok(); + it('55.13.1 ', function (done ) { + connection.should.be.ok(); - connection.execute ( + connection.execute ( "BEGIN get_invalid_refcur ( :p ); END; ", - { - p : { type : oracledb.CURSOR, dir : oracledb.BIND_OUT } - }, + { + p : { type : oracledb.CURSOR, dir : oracledb.BIND_OUT } + }, function ( err ) { should.exist ( err ); done(); } ); - }); // 55.13.1 - }); // 55.13 + }); // 55.13.1 + }); // 55.13 - }); +}); /********************* Helper functions *************************/ - function setUp(connection, tableName, done) +function setUp(connection, tableName, done) { - async.series([ - function(callback) { - createTable(connection, tableName, callback); - }, - function(callback) { - insertData(connection, tableName, callback); - }, - function(callback) { - createProc1(connection, tableName, callback); - } - ], done); - } + async.series([ + function(callback) { + createTable(connection, tableName, callback); + }, + function(callback) { + insertData(connection, tableName, callback); + }, + function(callback) { + createProc1(connection, tableName, callback); + } + ], done); +} - function clearUp(connection, tableName, done) +function clearUp(connection, tableName, done) { - async.series([ - function(callback) { - dropProc1(connection, callback); - }, - function(callback) { - dropTable(connection, tableName, callback); - } - ], done); - } + async.series([ + function(callback) { + dropProc1(connection, callback); + }, + function(callback) { + dropTable(connection, tableName, callback); + } + ], done); +} - function createTable(connection, tableName, done) +function createTable(connection, tableName, done) { - var sqlCreate = + var sqlCreate = "BEGIN " + " DECLARE " + " e_table_missing EXCEPTION; " + @@ -948,29 +947,29 @@ " '); " + "END; "; - connection.execute( + connection.execute( sqlCreate, function(err) { should.not.exist(err); done(); } ); - } +} - function dropTable(connection, tableName, done) +function dropTable(connection, tableName, done) { - connection.execute( + connection.execute( 'DROP TABLE ' + tableName + ' PURGE', function(err) { should.not.exist(err); done(); } ); - } +} - function insertData(connection, tableName, done) +function insertData(connection, tableName, done) { - var sqlInsert = + var sqlInsert = "DECLARE " + " x NUMBER := 0; " + " n VARCHAR2(20); " + @@ -982,7 +981,7 @@ " END LOOP; " + "END; "; - connection.execute( + connection.execute( sqlInsert, [], { autoCommit: true }, @@ -991,11 +990,11 @@ done(); } ); - } +} - function createProc1(connection, tableName, done) +function createProc1(connection, tableName, done) { - var sqlProc = + var sqlProc = "CREATE OR REPLACE PROCEDURE nodb_rs2_get_emp (p_in IN NUMBER, p_out OUT SYS_REFCURSOR) " + " AS " + " BEGIN " + @@ -1003,7 +1002,7 @@ " SELECT * FROM " + tableName + " WHERE employees_id > p_in; " + " END; "; - connection.execute( + connection.execute( sqlProc, [], { autoCommit: true }, @@ -1012,15 +1011,15 @@ done(); } ); - } +} - function dropProc1(connection, done) +function dropProc1(connection, done) { - connection.execute( + connection.execute( 'DROP PROCEDURE nodb_rs2_get_emp', function(err) { should.not.exist(err); done(); } ); - } +} diff --git a/test/resultSetClose.js b/test/resultSetClose.js index 6d4f7ff8..2e3377df 100644 --- a/test/resultSetClose.js +++ b/test/resultSetClose.js @@ -119,32 +119,40 @@ describe('53. resultSetClose.js', function() { ); }); // 53.1 - it('53.2 can not call close() again', function() { - should.throws( - function() { - resultSet.close(function() {}); - }, - /NJS-018: invalid ResultSet/ - ); + it('53.2 can not call close() again', function(done) { + resultSet.close(function(err) { + should.exist(err); + should.strictEqual( + err.message, + 'NJS-018: invalid ResultSet' + ); + done(); + }); }); // 53.2 - it('53.3 can not call getRow()', function() { - should.throws( - function() { - resultSet.getRow(function() {}); - }, - /NJS-018: invalid ResultSet/ - ); + it('53.3 can not call getRow()', function(done) { + resultSet.getRow(function(err, row) { + should.exist(err); + should.not.exist(row); + should.strictEqual( + err.message, + 'NJS-018: invalid ResultSet' + ); + done(); + }); }); // 53.3 - it('53.4 can not call getRows()', function() { - should.throws( - function() { - var numRows = 3; - resultSet.getRows(numRows, function() {}); - }, - /NJS-018: invalid ResultSet/ - ); + it('53.4 can not call getRows()', function(done) { + var numRows = 3; + resultSet.getRows(numRows, function(err, rows) { + should.exist(err); + should.not.exist(rows); + should.strictEqual( + err.message, + 'NJS-018: invalid ResultSet' + ); + done(); + }); }); // 53.4 it('53.5 can not call toQueryStream()', function() { diff --git a/test/rowidDMLBindAsString.js b/test/rowidDMLBindAsString.js index 4d88af06..86bca297 100644 --- a/test/rowidDMLBindAsString.js +++ b/test/rowidDMLBindAsString.js @@ -569,44 +569,44 @@ describe('107. rowidDMLBindAsString.js', function() { async.series([ function(cb) { connection.execute( - "insert into " + tableName + " T (ID) values (" + insertID + ")", - function(err, result) { - should.not.exist(err); - (result.rowsAffected).should.be.exactly(1); - cb(); - } - ); + "insert into " + tableName + " T (ID) values (" + insertID + ")", + function(err, result) { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + cb(); + } + ); }, function(cb) { connection.execute( - "UPDATE " + tableName + " T SET content = T.ROWID where ID = " + insertID, - function(err, result) { - should.not.exist(err); - (result.rowsAffected).should.be.exactly(1); - cb(); - } - ); + "UPDATE " + tableName + " T SET content = T.ROWID where ID = " + insertID, + function(err, result) { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + cb(); + } + ); }, function(cb) { connection.execute( - "select content from " + tableName + " where ID = " + insertID, - function(err, result) { - should.not.exist(err); - var resultVal = result.rows[0][0]; - connection.execute( - "select * from " + tableName + " where ROWID = CHARTOROWID(:c)", - { c: { val: resultVal, dir : oracledb.BIND_IN, type : oracledb.STRING } }, - function(err_1, result_1) { - should.not.exist(err_1); - var resultVal_1 = result_1.rows[0][0]; - var resultVal_2 = result_1.rows[0][1]; - should.strictEqual(resultVal_1, insertID); - should.strictEqual(resultVal_2, resultVal); - cb(); - } - ); - } - ); + "select content from " + tableName + " where ID = " + insertID, + function(err, result) { + should.not.exist(err); + var resultVal = result.rows[0][0]; + connection.execute( + "select * from " + tableName + " where ROWID = CHARTOROWID(:c)", + { c: { val: resultVal, dir : oracledb.BIND_IN, type : oracledb.STRING } }, + function(err_1, result_1) { + should.not.exist(err_1); + var resultVal_1 = result_1.rows[0][0]; + var resultVal_2 = result_1.rows[0][1]; + should.strictEqual(resultVal_1, insertID); + should.strictEqual(resultVal_2, resultVal); + cb(); + } + ); + } + ); } ], callback); }; diff --git a/test/rowidProcedureBindAsString_bindinout.js b/test/rowidProcedureBindAsString_bindinout.js index c89c2e10..77f52327 100644 --- a/test/rowidProcedureBindAsString_bindinout.js +++ b/test/rowidProcedureBindAsString_bindinout.js @@ -409,15 +409,15 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() { c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 } }; connection.execute( - proc_execute, - bindVar_out, - function(err, result) { - should.not.exist(err); - var resultVal = result.outBinds.c; - should.strictEqual(resultVal, expected); - callback(); - } - ); + proc_execute, + bindVar_out, + function(err, result) { + should.not.exist(err); + var resultVal = result.outBinds.c; + should.strictEqual(resultVal, expected); + callback(); + } + ); }; var procedureBindInout_update = function(proc_execute, content_1, content_2, expected, callback) { diff --git a/test/rowidProcedureBindAsString_bindout.js b/test/rowidProcedureBindAsString_bindout.js index 743c9bff..e4919f74 100644 --- a/test/rowidProcedureBindAsString_bindout.js +++ b/test/rowidProcedureBindAsString_bindout.js @@ -417,15 +417,15 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() { o: { type: oracledb.STRING, dir: oracledb.BIND_OUT } }; connection.execute( - proc_execute, - bindVar_out, - function(err, result) { - should.not.exist(err); - var resultVal = result.outBinds.o; - should.strictEqual(resultVal, expected); - callback(); - } - ); + proc_execute, + bindVar_out, + function(err, result) { + should.not.exist(err); + var resultVal = result.outBinds.o; + should.strictEqual(resultVal, expected); + callback(); + } + ); }; var procedureBindOut_update = function(proc_execute, content_1, content_2, expected, callback) { diff --git a/test/urowidDMLBindAsString_indexed.js b/test/urowidDMLBindAsString_indexed.js index e97220c6..5f0d939a 100644 --- a/test/urowidDMLBindAsString_indexed.js +++ b/test/urowidDMLBindAsString_indexed.js @@ -142,10 +142,10 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { testBigUROWID(strLength, rowidLenExpected, done); }); - it.skip('115.1.3 get error when urowid length > 4000', function(done) { - var strLength = 3000; - var rowidLenExpected = 4000; - testBigUROWID(strLength, rowidLenExpected, done); + it('115.1.3 works with maxSize < 200', function(done) { + var strLength = 300; + var rowidLenExpected = 200; + testBigUROWID_maxSize(strLength, rowidLenExpected, done); }); }); @@ -170,11 +170,11 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { testBigUROWID_update(rowid_org, strLength, rowidLenExpected, done); }); - it.skip('115.2.4 update with urowid length > 4000', function(done) { - var strLength = 3000; - var rowidLenExpected = 4000; + it('115.2.4 works with maxSize < 200', function(done) { + var strLength = 300; + var rowidLenExpected = 200; var rowid_org = "00000DD5.0000.0001"; - testBigUROWID_update(rowid_org, strLength, rowidLenExpected, done); + testBigUROWID_update_maxSize(rowid_org, strLength, rowidLenExpected, done); }); }); @@ -193,12 +193,6 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { testBigUROWID_returning(strLength, rowidLenExpected, done); }); - it.skip('115.3.3 urowid length > 4000', function(done) { - var strLength = 3000; - var rowidLenExpected = 4000; - testBigUROWID_returning(strLength, rowidLenExpected, done); - }); - }); describe('115.4 WHERE', function() { @@ -215,12 +209,6 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { testBigUROWID_where(strLength, rowidLenExpected, done); }); - it.skip('115.4.3 urowid length > 4000', function(done) { - var strLength = 3000; - var rowidLenExpected = 4000; - testBigUROWID_where(strLength, rowidLenExpected, done); - }); - }); describe('115.5 queryStream() and oracledb.maxRows = actual rows', function() { @@ -239,13 +227,6 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done); }); - it.skip('115.5.3 urowid length > 4000', function(done) { - var strLength = 3000; - var rowidLenExpected = 4000; - var maxRows = 2; - testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done); - }); - }); describe('115.6 queryStream() and oracledb.maxRows > actual rows', function() { @@ -264,13 +245,6 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done); }); - it.skip('115.6.3 urowid length > 4000', function(done) { - var strLength = 3000; - var rowidLenExpected = 4000; - var maxRows = 10; - testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done); - }); - }); describe('115.7 queryStream() and oracledb.maxRows < actual rows', function() { @@ -289,13 +263,6 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done); }); - it.skip('115.7.3 urowid length > 4000', function(done) { - var strLength = 3000; - var rowidLenExpected = 4000; - var maxRows = 1; - testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done); - }); - }); @@ -384,6 +351,91 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { ], callback); }; + var testBigUROWID_maxSize = function(strLength, rowidLenExpected, callback) { + var str = random.getRandomLengthString(strLength); + var urowid, urowidLen; + async.series([ + function(cb) { + var sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')"; + sql.executeInsert(connection, sql_insert, {}, {}, cb); + }, + function(cb) { + connection.execute( + "select ROWID from " + tableName_indexed + " where c1 = " + insertID, + function(err, result) { + should.not.exist(err); + urowid = result.rows[0][0]; + urowidLen = urowid.length; + urowidLen.should.be.above(rowidLenExpected); + cb(); + } + ); + }, + function(cb) { + var bindVar = { + i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER }, + c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 100 } + }; + connection.execute( + "insert into " + tableName_normal + " (ID, content) values (:i, :c)", + bindVar, + function(err, result) { + if(urowidLen > 4000) { + should.exist(err); + should.strictEqual(err.message, "ORA-01704: string literal too long"); + } else { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + } + cb(); + } + ); + }, + function(cb) { + connection.execute( + "select * from " + tableName_normal + " where ID = " + insertID, + function(err, result) { + if(urowidLen < 4000) { + should.not.exist(err); + var resultVal = result.rows[0][1]; + should.strictEqual(resultVal, urowid); + } + cb(); + } + ); + }, + function(cb) { + insertID++; + connection.execute( + "insert into " + tableName_normal + " (ID, content) values (" + insertID + ", '" + urowid + "')", + function(err, result) { + if(urowidLen > 4000) { + should.exist(err); + should.strictEqual(err.message, "ORA-01704: string literal too long"); + } else { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + } + cb(); + } + ); + }, + function(cb) { + connection.execute( + "select * from " + tableName_normal + " where ID = " + insertID, + function(err, result) { + if(urowidLen < 4000) { + should.not.exist(err); + var resultVal = result.rows[0][1]; + should.strictEqual(resultVal, urowid); + } + cb(); + } + ); + } + ], callback); + }; + var testBigUROWID_update = function(rowid_org, strLength, rowidLenExpected, callback) { var str = random.getRandomLengthString(strLength); var urowid, urowidLen; @@ -486,6 +538,96 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { ], callback); }; + var testBigUROWID_update_maxSize = function(rowid_org, strLength, rowidLenExpected, callback) { + var str = random.getRandomLengthString(strLength); + var urowid, urowidLen; + var id_1 = insertID++; + var id_2 = insertID++; + async.series([ + function(cb) { + var sql_insert = "insert into " + tableName_normal + " (ID, content) values (:i, :c)"; + var bindVar = { + i: { val : id_1, dir : oracledb.BIND_IN, type : oracledb.NUMBER }, + c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING } + }; + sql.executeInsert(connection, sql_insert, bindVar, {}, cb); + }, + function(cb) { + var sql_insert = "insert into " + tableName_normal + " (ID, content) values (:i, :c)"; + var bindVar = { + i: { val : id_2, dir : oracledb.BIND_IN, type : oracledb.NUMBER }, + c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING } + }; + sql.executeInsert(connection, sql_insert, bindVar, {}, cb); + }, + function(cb) { + var sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')"; + sql.executeInsert(connection, sql_insert, {}, {}, cb); + }, + function(cb) { + connection.execute( + "select ROWID from " + tableName_indexed + " where c1 = " + insertID, + function(err, result) { + should.not.exist(err); + urowid = result.rows[0][0]; + urowidLen = urowid.length; + urowidLen.should.be.above(rowidLenExpected); + cb(); + } + ); + }, + function(cb) { + var bindVar = { + c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING }, + i: { val : id_1, dir : oracledb.BIND_IN, type : oracledb.NUMBER, maxSize: 100 } + }; + connection.execute( + "update " + tableName_normal + " set content = :c where ID = :i", + bindVar, + function(err, result) { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + cb(); + } + ); + }, + function(cb) { + connection.execute( + "select * from " + tableName_normal + " where ID = " + id_1, + function(err, result) { + if(urowidLen < 4000) { + should.not.exist(err); + var resultVal = result.rows[0][1]; + should.strictEqual(resultVal, urowid); + } + cb(); + } + ); + }, + function(cb) { + connection.execute( + "update " + tableName_normal + " set content = '" + urowid + "' where ID = " + id_2, + function(err, result) { + should.not.exist(err); + (result.rowsAffected).should.be.exactly(1); + cb(); + } + ); + }, + function(cb) { + connection.execute( + "select * from " + tableName_normal + " where ID = " + id_2, + function(err, result) { + should.not.exist(err); + var resultVal = result.rows[0][1]; + should.strictEqual(resultVal, urowid); + cb(); + } + ); + } + ], callback); + }; + var testBigUROWID_returning = function(strLength, rowidLenExpected, callback) { var str = random.getRandomLengthString(strLength); var urowid, urowidLen; @@ -516,16 +658,27 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { "insert into " + tableName_normal + " (ID, content) values (:i, :c) returning content into :o", bindVar, function(err, result) { - if(urowidLen > 4000) { - should.exist(err); - should.strictEqual(err.message, "ORA-01704: string literal too long"); - } else { - should.not.exist(err); - var resultVal; - if (typeof (result.outBinds.o) === 'undefined') resultVal = result.outBinds[0][0]; - else resultVal = result.outBinds.o[0]; - should.strictEqual(resultVal, urowid); - } + should.not.exist(err); + var resultVal; + if (typeof (result.outBinds.o) === 'undefined') resultVal = result.outBinds[0][0]; + else resultVal = result.outBinds.o[0]; + should.strictEqual(resultVal, urowid); + cb(); + } + ); + }, + function(cb) { + var bindVar = { + i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER }, + c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING }, + o: { dir : oracledb.BIND_OUT, type : oracledb.STRING, maxSize: 100 } + }; + connection.execute( + "insert into " + tableName_normal + " (ID, content) values (:i, :c) returning content into :o", + bindVar, + function(err) { + should.exist(err); + should.strictEqual(err.message, "NJS-016: buffer is too small for OUT binds"); cb(); } ); @@ -567,6 +720,21 @@ describe('115. urowidDMLBindAsString_indexed.js', function() { cb(); } ); + }, + function(cb) { + var bindVar = { + c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 100 } + }; + connection.execute( + "select * from " + tableName_indexed + " where ROWID = :c", + bindVar, + function(err, result) { + should.not.exist(err); + should.strictEqual(result.rows[0][0], insertID); + should.strictEqual(result.rows[0][1], str); + cb(); + } + ); } ], callback); }; diff --git a/test/urowidProcedureBindAsString_bindinout.js b/test/urowidProcedureBindAsString_bindinout.js index cb55a4f9..747abb2d 100644 --- a/test/urowidProcedureBindAsString_bindinout.js +++ b/test/urowidProcedureBindAsString_bindinout.js @@ -409,15 +409,15 @@ describe('120. urowidProcedureBindAsString_bindinout.js', function() { c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 } }; connection.execute( - proc_execute, - bindVar_out, - function(err, result) { - should.not.exist(err); - var resultVal = result.outBinds.c; - should.strictEqual(resultVal, expected); - callback(); - } - ); + proc_execute, + bindVar_out, + function(err, result) { + should.not.exist(err); + var resultVal = result.outBinds.c; + should.strictEqual(resultVal, expected); + callback(); + } + ); }; var procedureBindInout_update = function(proc_execute, content_1, content_2, expected, callback) { diff --git a/test/urowidProcedureBindAsString_bindout.js b/test/urowidProcedureBindAsString_bindout.js index 524a5a51..1fa3dde5 100644 --- a/test/urowidProcedureBindAsString_bindout.js +++ b/test/urowidProcedureBindAsString_bindout.js @@ -417,15 +417,15 @@ describe('119. urowidProcedureBindAsString_bindout.js', function() { o: { type: oracledb.STRING, dir: oracledb.BIND_OUT } }; connection.execute( - proc_execute, - bindVar_out, - function(err, result) { - should.not.exist(err); - var resultVal = result.outBinds.o; - should.strictEqual(resultVal, expected); - callback(); - } - ); + proc_execute, + bindVar_out, + function(err, result) { + should.not.exist(err); + var resultVal = result.outBinds.o; + should.strictEqual(resultVal, expected); + callback(); + } + ); }; var procedureBindOut_update = function(proc_execute, content_1, content_2, expected, callback) { diff --git a/test/writableProperties.js b/test/writableProperties.js index 59b34622..e0480fdd 100644 --- a/test/writableProperties.js +++ b/test/writableProperties.js @@ -155,7 +155,7 @@ describe('66. writableProperties.js', function() { }); }); } - ); + ); }); }); @@ -211,7 +211,7 @@ describe('66. writableProperties.js', function() { }); } - ); + ); }); }); // 66.4