Sync tests and fix missed merges
This commit is contained in:
parent
ae0037409f
commit
db600cb016
|
@ -75,16 +75,15 @@ vi <some-directory>/node-oracledb/test/dbconfig.js
|
|||
module.exports = {
|
||||
user : process.env.NODE_ORACLEDB_USER || "hr",
|
||||
password : process.env.NODE_ORACLEDB_PASSWORD || "welcome",
|
||||
connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost/orcl",
|
||||
externalAuth : process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false
|
||||
connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost/orcl"
|
||||
};
|
||||
```
|
||||
|
||||
To use external authentication, set the `externalAuth` property to
|
||||
`true`. Also make sure Oracle Database and the authentication service
|
||||
have been appropriately configured. See
|
||||
To enable external authentication tests, please make sure Oracle Database
|
||||
and the authentication service have been appropriately configured. See
|
||||
[Documentation for External Authentication](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#extauth)
|
||||
for more details.
|
||||
for more details. And then, set the environment variable `NODE_ORACLEDB_EXTERNALAUTH`
|
||||
to be `true`.
|
||||
|
||||
Note: the test suite requires a schema with these privileges:
|
||||
|
||||
|
@ -117,10 +116,10 @@ This calls the `test` script defined in `oracledb/package.json`.
|
|||
|
||||
```
|
||||
cd <some-directory>/node_oracledb
|
||||
npm run-script testWindows
|
||||
npm run testwindows
|
||||
```
|
||||
|
||||
This calls the `testWindows` script defined in `oracledb/package.json`.
|
||||
This calls the `testwindows` script defined in `oracledb/package.json`.
|
||||
|
||||
See [npm scripts](https://docs.npmjs.com/misc/scripts) for more information
|
||||
about how npm handles the "scripts" field of `package.json`.
|
||||
|
@ -135,6 +134,7 @@ cd <some-directory>/node_oracledb
|
|||
See [mochajs.org](http://mochajs.org/) for more information on running tests with mocha.
|
||||
|
||||
## 3. Add Tests
|
||||
|
||||
See [CONTRIBUTING](https://github.com/oracle/node-oracledb/blob/master/CONTRIBUTING.md)
|
||||
for general information on contribution requirements.
|
||||
|
||||
|
@ -145,6 +145,82 @@ assigned a number. The following number ranges have been chosen:
|
|||
- 21 - 50 are reserved for data type supporting tests
|
||||
- 51 onwards are for other tests
|
||||
|
||||
## 4. Test Index
|
||||
In order to include your tests in the suite, add each new test file
|
||||
name to [`test/opts/mocha.opts`](https://github.com/oracle/node-oracledb/blob/master/test/opts/mocha.opts).
|
||||
|
||||
See [`test/list.txt`](https://github.com/oracle/node-oracledb/blob/master/test/list.txt) for the list of existing tests.
|
||||
Please also add a description of each individual test to the Test
|
||||
List.
|
||||
|
||||
## 4. Test List
|
||||
|
||||
See [`test/list.txt`](https://github.com/oracle/node-oracledb/blob/master/test/list.txt)
|
||||
for the list of existing tests.
|
||||
|
||||
## 5. Tests Compatibility
|
||||
|
||||
- We conduct base testing with Instant Client 11.2.0.4 and 12.1.0.2 on Linux X64
|
||||
and Windows 7.
|
||||
|
||||
- Users of 11.2.0.1 and 11.2.0.2 clients may see failures with poolTimeout.js
|
||||
and dataTypeDouble.js.
|
||||
|
||||
- Slow networks may cause some tests to timeout.
|
||||
|
||||
## 6. Troubleshooting
|
||||
|
||||
You may encounter some troubles when running the test suite. These troubles
|
||||
might be caused by the concurrency issue of Mocha framework, network latencies,
|
||||
or database server issues. This section gives some issues that we ever saw
|
||||
and our solutions.
|
||||
|
||||
### 6.1 ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired
|
||||
|
||||
This error occurs when Node.js programs try to change database objects which
|
||||
hold locks. The workaround would be:
|
||||
|
||||
(1) Use unique DB object names for each test to avoid interference between
|
||||
test files.
|
||||
(2) Try not to use 'beforeEach' blocks for object operations to avoid
|
||||
the interference between cases.
|
||||
|
||||
### 6.2 ORA-00018: maximum number of sessions exceeded
|
||||
|
||||
This error occurs when the test suite takes up more sessions than the
|
||||
configured limit. You can alter the session limit on the database server side.
|
||||
If you do not have access to change the database session setting, you could
|
||||
use the below script to deliberately add an interval between tests.
|
||||
|
||||
```Bash
|
||||
arr=$(ls test/*js)
|
||||
for case in ${arr[@]}
|
||||
do
|
||||
var="$NODE_PATH/../node_modules/.bin/mocha --timeout 10000 $case"
|
||||
eval $var
|
||||
sleep 1
|
||||
done
|
||||
```
|
||||
|
||||
### 6.3 ORA-28865: SSL connection closed
|
||||
|
||||
You may encounter this error when the test suite sends more connection
|
||||
requests per second than the database is configured to handle.
|
||||
|
||||
There are two solutions:
|
||||
|
||||
- Solution 1: Change database `RATE_LIMIT` configuration. This parameter
|
||||
defines the connection count allowed per second. See [RATE_LIMIT](https://docs.oracle.com/database/122/NETRF/Oracle-Net-Listener-parameters-in-listener-ora-file.htm#NETRF426)
|
||||
for more information.
|
||||
|
||||
- Solution 2: Set the `RETRY_COUNT` and `RETRY_DELAY` parameters in
|
||||
connectString.
|
||||
|
||||
For example, below is the connectString which could be defined in
|
||||
`tnsnames.ora` file.
|
||||
|
||||
```
|
||||
dbaccess = (description=(RETRY_COUNT=20)(RETRY_DELAY=3)
|
||||
(address=(protocol=tcps)(port=1521)(host=<db-host>))
|
||||
(connect_data=(service_name=<service-name>))
|
||||
(security=(my_wallet_directory=<wallet-location>)(ssl_server_cert_dn=<ssl-server-cert-dn>))
|
||||
)
|
||||
```
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 51. accessTerminatedPoolAttributes.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing driver's behaviour when access attributes of terminated pool.
|
||||
*
|
||||
* 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 dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('51. accessTerminatedPoolAttributes.js', function(){
|
||||
|
||||
it('can not access attributes of terminated pool', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
poolMin : 2,
|
||||
poolMax : 10
|
||||
},
|
||||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
if(dbConfig.externalAuth){
|
||||
pool.connectionsOpen.should.be.exactly(0);
|
||||
} else {
|
||||
pool.connectionsOpen.should.be.exactly(pool.poolMin);
|
||||
}
|
||||
//(pool.connectionsOpen).should.eql(2);
|
||||
(pool.connectionsInUse).should.eql(0);
|
||||
|
||||
pool.getConnection( function(err, connection){
|
||||
(pool.connectionsInUse).should.eql(1);
|
||||
|
||||
connection.release( function(err){
|
||||
should.not.exist(err);
|
||||
(pool.connectionsInUse).should.eql(0);
|
||||
|
||||
pool.terminate( function(err){
|
||||
should.not.exist(err);
|
||||
try{
|
||||
(pool.connectionsOpen).should.eql(2);
|
||||
}
|
||||
catch(err){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-002:');
|
||||
// NJS-002: invalid pool
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
})
|
||||
})
|
|
@ -47,16 +47,16 @@ describe('7. autoCommit.js', function() {
|
|||
var script =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_departments'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_commit_dept purge'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_departments ( \
|
||||
CREATE TABLE nodb_commit_dept ( \
|
||||
department_id NUMBER, \
|
||||
department_name VARCHAR2(20) \
|
||||
) \
|
||||
|
@ -67,7 +67,6 @@ describe('7. autoCommit.js', function() {
|
|||
function(callback) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -99,13 +98,13 @@ describe('7. autoCommit.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
after('drop table, release connection, terminate pool', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_departments",
|
||||
"DROP TABLE nodb_commit_dept purge",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -125,19 +124,19 @@ describe('7. autoCommit.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
afterEach('truncate table, reset the oracledb properties', function(done) {
|
||||
oracledb.autoCommit = false; /* Restore to default value */
|
||||
|
||||
connection.execute(
|
||||
"TRUNCATE TABLE nodb_departments",
|
||||
"TRUNCATE TABLE nodb_commit_dept",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('7.1 autoCommit takes effect when setting oracledb.autoCommit before connecting', function(done) {
|
||||
var conn1 = null;
|
||||
|
@ -157,7 +156,7 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"INSERT INTO nodb_departments VALUES (82, 'Security')",
|
||||
"INSERT INTO nodb_commit_dept VALUES (82, 'Security')",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -175,19 +174,19 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Security'",
|
||||
"SELECT department_id FROM nodb_commit_dept WHERE department_name = 'Security'",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(82).and.be.a.Number;
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(82).and.be.a.Number();
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"UPDATE nodb_departments SET department_id = 101 WHERE department_name = 'Security'",
|
||||
"UPDATE nodb_commit_dept SET department_id = 101 WHERE department_name = 'Security'",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -196,12 +195,12 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Security'",
|
||||
"SELECT department_id FROM nodb_commit_dept WHERE department_name = 'Security'",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(101).and.be.a.Number;
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(101).and.be.a.Number();
|
||||
callback();
|
||||
}
|
||||
);
|
||||
|
@ -219,7 +218,7 @@ describe('7. autoCommit.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('7.2 autoCommit takes effect when setting oracledb.autoCommit after connecting', function(done) {
|
||||
var conn1 = null;
|
||||
|
@ -238,7 +237,7 @@ describe('7. autoCommit.js', function() {
|
|||
function(callback) {
|
||||
oracledb.autoCommit = true; // change autoCommit after connection
|
||||
conn1.execute(
|
||||
"INSERT INTO nodb_departments VALUES (82, 'Security')",
|
||||
"INSERT INTO nodb_commit_dept VALUES (82, 'Security')",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -256,19 +255,19 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Security'",
|
||||
"SELECT department_id FROM nodb_commit_dept WHERE department_name = 'Security'",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(82).and.be.a.Number;
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(82).and.be.a.Number();
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"UPDATE nodb_departments SET department_id = 101 WHERE department_name = 'Security'",
|
||||
"UPDATE nodb_commit_dept SET department_id = 101 WHERE department_name = 'Security'",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -277,12 +276,12 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Security'",
|
||||
"SELECT department_id FROM nodb_commit_dept WHERE department_name = 'Security'",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(101).and.be.a.Number;
|
||||
result.rows[0].DEPARTMENT_ID.should.eql(101).and.be.a.Number();
|
||||
callback();
|
||||
}
|
||||
);
|
||||
|
@ -300,7 +299,7 @@ describe('7. autoCommit.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('7.3 autoCommit setting does not affect previous SQL result', function(done) {
|
||||
var conn1 = null;
|
||||
|
@ -318,7 +317,7 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"INSERT INTO nodb_departments VALUES (82, 'Security')",
|
||||
"INSERT INTO nodb_commit_dept VALUES (82, 'Security')",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -337,7 +336,7 @@ describe('7. autoCommit.js', function() {
|
|||
function(callback) {
|
||||
oracledb.autoCommit = true; // change autoCommit after connection
|
||||
conn2.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Security'",
|
||||
"SELECT department_id FROM nodb_commit_dept WHERE department_name = 'Security'",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
|
@ -349,7 +348,7 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"INSERT INTO nodb_departments VALUES (99, 'Marketing')",
|
||||
"INSERT INTO nodb_commit_dept VALUES (99, 'Marketing')",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -358,7 +357,7 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT COUNT(*) as amount FROM nodb_departments",
|
||||
"SELECT COUNT(*) as amount FROM nodb_commit_dept",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
|
@ -370,7 +369,7 @@ describe('7. autoCommit.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"SELECT COUNT(*) as amount FROM nodb_departments",
|
||||
"SELECT COUNT(*) as amount FROM nodb_commit_dept",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
|
@ -393,6 +392,6 @@ describe('7. autoCommit.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -54,12 +54,12 @@ describe('63. autoCommit4nestedExecutes.js', function() {
|
|||
var sqlCreateTab =
|
||||
" BEGIN "
|
||||
+ " DECLARE "
|
||||
+ " e_table_exists EXCEPTION; "
|
||||
+ " PRAGMA EXCEPTION_INIT(e_table_exists, -00942); "
|
||||
+ " e_table_missing EXCEPTION; "
|
||||
+ " PRAGMA EXCEPTION_INIT(e_table_missing, -00942); "
|
||||
+ " BEGIN "
|
||||
+ " EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); "
|
||||
+ " EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE'); "
|
||||
+ " EXCEPTION "
|
||||
+ " WHEN e_table_exists "
|
||||
+ " WHEN e_table_missing "
|
||||
+ " THEN NULL; "
|
||||
+ " END; "
|
||||
+ " EXECUTE IMMEDIATE (' "
|
||||
|
@ -109,7 +109,7 @@ describe('63. autoCommit4nestedExecutes.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
after('drop table and procedure', function(done) {
|
||||
async.series([
|
||||
|
@ -124,7 +124,7 @@ describe('63. autoCommit4nestedExecutes.js', function() {
|
|||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName,
|
||||
"DROP TABLE " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
|
@ -132,37 +132,17 @@ describe('63. autoCommit4nestedExecutes.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
it('63.1 nested execute() functions', function(done) {
|
||||
|
||||
var pool = null,
|
||||
conn = null;
|
||||
conn = null;
|
||||
// sql will be the same for both execute calls
|
||||
var procSql = "BEGIN " + procName + "(p_iname=>:p_iname, p_short_name=>:p_short_name, "
|
||||
+ " p_comments=>:p_comments, p_new_id=>:p_new_id, p_status=>:p_status, "
|
||||
+ " p_description=>:p_description); END;";
|
||||
|
||||
// Two execute() uses the same bindVar which conflicts occur
|
||||
var bindVar =
|
||||
{
|
||||
p_iname: "Test iname",
|
||||
p_short_name: "TST",
|
||||
p_comments: "Test comments",
|
||||
p_new_id: {
|
||||
type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT
|
||||
},
|
||||
p_status: {
|
||||
type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT
|
||||
},
|
||||
p_description: {
|
||||
type: oracledb.STRING,
|
||||
dir: oracledb.BIND_OUT
|
||||
}
|
||||
};
|
||||
|
||||
async.series([
|
||||
function getPool(cb) {
|
||||
oracledb.createPool(
|
||||
|
@ -202,7 +182,7 @@ describe('63. autoCommit4nestedExecutes.js', function() {
|
|||
}
|
||||
},
|
||||
{ autoCommit: false },
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
|
@ -232,7 +212,8 @@ describe('63. autoCommit4nestedExecutes.js', function() {
|
|||
function(err, result) {
|
||||
should.exist(err);
|
||||
// ORA-01036: illegal variable name/number
|
||||
(err.message).should.startWith('ORA-01036');
|
||||
(err.message).should.startWith('ORA-01036:');
|
||||
should.not.exist(result);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
|
@ -262,6 +243,6 @@ describe('63. autoCommit4nestedExecutes.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -46,50 +46,65 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
var script =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_departments'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_commit4_dept PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_departments ( \
|
||||
CREATE TABLE nodb_commit4_dept ( \
|
||||
department_id NUMBER, \
|
||||
department_name VARCHAR2(20) \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_commit4_dept \
|
||||
(department_id, department_name) VALUES \
|
||||
(40,''Human Resources'') \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_commit4_dept \
|
||||
(department_id, department_name) VALUES \
|
||||
(20, ''Marketing'') \
|
||||
'); \
|
||||
END; ";
|
||||
|
||||
before(function(done){
|
||||
|
||||
async.parallel([
|
||||
function(callback){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
callback();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
anotherConnection = conn;
|
||||
callback();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
anotherConnection = conn;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
async.parallel([
|
||||
|
@ -106,7 +121,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
beforeEach(function(done){
|
||||
connection.execute(script, function(err){
|
||||
|
@ -118,26 +133,26 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
afterEach(function(done){
|
||||
connection.execute(
|
||||
'DROP TABLE nodb_departments',
|
||||
'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){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
oracledb.autoCommit = false;
|
||||
|
||||
async.series([
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_departments VALUES (180, 'Construction')",
|
||||
"INSERT INTO nodb_commit4_dept VALUES (180, 'Construction')",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -146,7 +161,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"UPDATE nodb_departments SET department_id = 99 WHERE department_name = 'Marketing'",
|
||||
"UPDATE nodb_commit4_dept SET department_id = 99 WHERE department_name = 'Marketing'",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -155,7 +170,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_commit4_dept ORDER BY department_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows).should.containEql([180, 'Construction']);
|
||||
|
@ -165,7 +180,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
anotherConnection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_commit4_dept ORDER BY department_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows).should.not.containEql([180, 'Construction']);
|
||||
|
@ -175,7 +190,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Marketing'",
|
||||
"SELECT department_id FROM nodb_commit4_dept WHERE department_name = 'Marketing'",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.eql(99);
|
||||
|
@ -185,7 +200,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
anotherConnection.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Marketing'",
|
||||
"SELECT department_id FROM nodb_commit4_dept WHERE department_name = 'Marketing'",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.eql(20);
|
||||
|
@ -194,16 +209,16 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('8.2 can use explicit commit() to keep data consistent', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
oracledb.autoCommit = false;
|
||||
|
||||
async.series([
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_departments VALUES (180, 'Construction')",
|
||||
"INSERT INTO nodb_commit4_dept VALUES (180, 'Construction')",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -212,7 +227,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"UPDATE nodb_departments SET department_id = 99 WHERE department_name = 'Marketing'",
|
||||
"UPDATE nodb_commit4_dept SET department_id = 99 WHERE department_name = 'Marketing'",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -227,7 +242,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_commit4_dept ORDER BY department_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows).should.containEql([180, 'Construction']);
|
||||
|
@ -237,7 +252,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
anotherConnection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_commit4_dept ORDER BY department_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows).should.containEql([180, 'Construction']);
|
||||
|
@ -247,7 +262,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Marketing'",
|
||||
"SELECT department_id FROM nodb_commit4_dept WHERE department_name = 'Marketing'",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.eql(99);
|
||||
|
@ -257,7 +272,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
anotherConnection.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Marketing'",
|
||||
"SELECT department_id FROM nodb_commit4_dept WHERE department_name = 'Marketing'",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.eql(99);
|
||||
|
@ -266,16 +281,16 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('8.3 can also use the autoCommit for SELECTs feature', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
oracledb.autoCommit = false;
|
||||
|
||||
async.series([
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_departments VALUES (180, 'Construction')",
|
||||
"INSERT INTO nodb_commit4_dept VALUES (180, 'Construction')",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -284,7 +299,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"UPDATE nodb_departments SET department_id = 99 WHERE department_name = 'Marketing'",
|
||||
"UPDATE nodb_commit4_dept SET department_id = 99 WHERE department_name = 'Marketing'",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -299,7 +314,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_commit4_dept ORDER BY department_id",
|
||||
{},
|
||||
{autoCommit: true},
|
||||
function(err, result){
|
||||
|
@ -311,7 +326,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
anotherConnection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_commit4_dept ORDER BY department_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows).should.containEql([180, 'Construction']);
|
||||
|
@ -321,7 +336,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Marketing'",
|
||||
"SELECT department_id FROM nodb_commit4_dept WHERE department_name = 'Marketing'",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.eql(99);
|
||||
|
@ -331,7 +346,7 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
anotherConnection.execute(
|
||||
"SELECT department_id FROM nodb_departments WHERE department_name = 'Marketing'",
|
||||
"SELECT department_id FROM nodb_commit4_dept WHERE department_name = 'Marketing'",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.eql(99);
|
||||
|
@ -340,5 +355,5 @@ describe('8. autoCommitForSelect.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
563
test/binding.js
563
test/binding.js
|
@ -52,24 +52,24 @@ describe('4. binding.js', function() {
|
|||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.release( function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('4.1.1 VARCHAR2 binding, Object & Array formats', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_testproc (p_out OUT VARCHAR2) \
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_bindproc1 (p_out OUT VARCHAR2) \
|
||||
AS \
|
||||
BEGIN \
|
||||
p_out := 'abcdef'; \
|
||||
END;";
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
|
@ -80,7 +80,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:o); END;",
|
||||
"BEGIN nodb_bindproc1(:o); END;",
|
||||
{
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
|
@ -94,7 +94,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:o); END;",
|
||||
"BEGIN nodb_bindproc1(:o); END;",
|
||||
[
|
||||
{ type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
|
@ -108,7 +108,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_testproc",
|
||||
"DROP PROCEDURE nodb_bindproc1",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -116,17 +116,17 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.1.2 NUMBER binding, Object & Array formats', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_testproc (p_out OUT NUMBER) \
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_bindproc2 (p_out OUT NUMBER) \
|
||||
AS \
|
||||
BEGIN \
|
||||
p_out := 10010; \
|
||||
END;";
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
|
@ -137,7 +137,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:o); END;",
|
||||
"BEGIN nodb_bindproc2(:o); END;",
|
||||
{
|
||||
o: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
|
@ -151,7 +151,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:o); END;",
|
||||
"BEGIN nodb_bindproc2(:o); END;",
|
||||
[
|
||||
{ type: oracledb.NUMBER, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
|
@ -165,7 +165,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_testproc",
|
||||
"DROP PROCEDURE nodb_bindproc2",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -173,18 +173,18 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
}); // 4.1.2
|
||||
|
||||
it('4.1.3 Multiple binding values, Object & Array formats', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_testproc (p_in IN VARCHAR2, p_inout IN OUT VARCHAR2, p_out OUT NUMBER) \
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_bindproc3 (p_in IN VARCHAR2, p_inout IN OUT VARCHAR2, p_out OUT NUMBER) \
|
||||
AS \
|
||||
BEGIN \
|
||||
p_inout := p_in || ' ' || p_inout; \
|
||||
p_out := 101; \
|
||||
END; ";
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
|
@ -195,7 +195,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:i, :io, :o); END;",
|
||||
"BEGIN nodb_bindproc3(:i, :io, :o); END;",
|
||||
{
|
||||
i: 'Alan', // bind type is determined from the data type
|
||||
io: { val: 'Turing', dir : oracledb.BIND_INOUT },
|
||||
|
@ -211,7 +211,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:i, :io, :o); END;",
|
||||
"BEGIN nodb_bindproc3(:i, :io, :o); END;",
|
||||
[
|
||||
'Alan', // bind type is determined from the data type
|
||||
{ val: 'Turing', dir : oracledb.BIND_INOUT },
|
||||
|
@ -227,7 +227,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_testproc",
|
||||
"DROP PROCEDURE nodb_bindproc3",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -235,18 +235,18 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.1.4 Multiple binding values, Change binding order', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_testproc (p_inout IN OUT VARCHAR2, p_out OUT NUMBER, p_in IN VARCHAR2) \
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_bindproc4 (p_inout IN OUT VARCHAR2, p_out OUT NUMBER, p_in IN VARCHAR2) \
|
||||
AS \
|
||||
BEGIN \
|
||||
p_inout := p_in || ' ' || p_inout; \
|
||||
p_out := 101; \
|
||||
END; ";
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
|
@ -257,7 +257,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:io, :o, :i); END;",
|
||||
"BEGIN nodb_bindproc4(:io, :o, :i); END;",
|
||||
{
|
||||
i: 'Alan', // bind type is determined from the data type
|
||||
io: { val: 'Turing', dir : oracledb.BIND_INOUT },
|
||||
|
@ -273,7 +273,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:io, :o, :i); END;",
|
||||
"BEGIN nodb_bindproc4(:io, :o, :i); END;",
|
||||
[
|
||||
{ val: 'Turing', dir : oracledb.BIND_INOUT },
|
||||
{ type: oracledb.NUMBER, dir : oracledb.BIND_OUT },
|
||||
|
@ -289,7 +289,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_testproc",
|
||||
"DROP PROCEDURE nodb_bindproc4",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -297,10 +297,10 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.1.5 default bind type - STRING', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
var sql = "begin :n := 1001; end;";
|
||||
var bindVar = { n : { dir: oracledb.BIND_OUT } };
|
||||
var options = { };
|
||||
|
@ -317,31 +317,31 @@ describe('4. binding.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('4.2 mixing named with positional binding', function() {
|
||||
var connection = null;
|
||||
var createTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_binding'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_binding1 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_binding ( \
|
||||
CREATE TABLE nodb_binding1 ( \
|
||||
id NUMBER(4), \
|
||||
name VARCHAR2(32) \
|
||||
) \
|
||||
'); \
|
||||
END; ";
|
||||
var insert = 'insert into nodb_binding (id, name) values (:0, :1) returning id into :2';
|
||||
var insert = 'insert into nodb_binding1 (id, name) values (:0, :1) returning id into :2';
|
||||
var param1 = [ 1, 'changjie', { type: oracledb.NUMBER, dir: oracledb.BIND_OUT } ];
|
||||
var param2 = [ 2, 'changjie', { ignored_name: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT } } ];
|
||||
var options = { autoCommit: true, outFormat: oracledb.OBJECT };
|
||||
|
@ -358,12 +358,12 @@ describe('4. binding.js', function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_binding",
|
||||
"DROP TABLE nodb_binding1 PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
connection.release(function(err) {
|
||||
|
@ -372,7 +372,7 @@ describe('4. binding.js', function() {
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.2.1 array binding is ok', function(done) {
|
||||
connection.execute(
|
||||
|
@ -385,7 +385,7 @@ describe('4. binding.js', function() {
|
|||
result.outBinds[0].should.eql([1]);
|
||||
// console.log(result);
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_binding ORDER BY id",
|
||||
"SELECT * FROM nodb_binding1 ORDER BY id",
|
||||
[],
|
||||
options,
|
||||
function(err, result) {
|
||||
|
@ -398,7 +398,7 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.2.2 array binding with mixing JSON should throw an error', function(done) {
|
||||
connection.execute(
|
||||
|
@ -409,8 +409,11 @@ describe('4. binding.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-044');
|
||||
// NJS-044: named JSON object is not expected in this context
|
||||
|
||||
should.not.exist(result);
|
||||
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_binding ORDER BY id",
|
||||
"SELECT * FROM nodb_binding1 ORDER BY id",
|
||||
[],
|
||||
options,
|
||||
function(err, result) {
|
||||
|
@ -421,25 +424,25 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('4.3 insert with DATE column and DML returning', function(done) {
|
||||
describe('4.3 insert with DATE column and DML returning', function() {
|
||||
var connection = null;
|
||||
var createTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_binding'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_binding2 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_binding ( \
|
||||
CREATE TABLE nodb_binding2 ( \
|
||||
num NUMBER(4), \
|
||||
str VARCHAR2(32), \
|
||||
dt DATE \
|
||||
|
@ -459,12 +462,12 @@ describe('4. binding.js', function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
afterEach(function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_binding",
|
||||
"DROP TABLE nodb_binding2 PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
connection.release(function(err) {
|
||||
|
@ -473,10 +476,10 @@ describe('4. binding.js', function() {
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
var insert1 = 'insert into nodb_binding (num, str, dt) values (:0, :1, :2)';
|
||||
var insert2 = 'insert into nodb_binding (num, str, dt) values (:0, :1, :2) returning num into :3';
|
||||
var insert1 = 'insert into nodb_binding2 (num, str, dt) values (:0, :1, :2)';
|
||||
var insert2 = 'insert into nodb_binding2 (num, str, dt) values (:0, :1, :2) returning num into :3';
|
||||
var param1 = { 0: 123, 1: 'str', 2: new Date() };
|
||||
var param2 = { 0: 123, 1: 'str', 2: new Date(), 3: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT } };
|
||||
var param3 = [ 123, 'str', new Date() ];
|
||||
|
@ -493,10 +496,10 @@ describe('4. binding.js', function() {
|
|||
should.not.exist(err);
|
||||
result.rowsAffected.should.be.exactly(1);
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_binding ORDER BY num",
|
||||
"SELECT * FROM nodb_binding2 ORDER BY num",
|
||||
[],
|
||||
options,
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
done();
|
||||
|
@ -504,7 +507,7 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.3.2 passes in object syntax with returning into', function(done) {
|
||||
connection.execute(
|
||||
|
@ -517,10 +520,10 @@ describe('4. binding.js', function() {
|
|||
//console.log(result);
|
||||
result.outBinds.should.eql({ '3': [123] });
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_binding ORDER BY num",
|
||||
"SELECT * FROM nodb_binding2 ORDER BY num",
|
||||
[],
|
||||
options,
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
done();
|
||||
|
@ -528,7 +531,7 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.3.3 passes in array syntax without returning into', function(done) {
|
||||
connection.execute(
|
||||
|
@ -540,10 +543,10 @@ describe('4. binding.js', function() {
|
|||
result.rowsAffected.should.be.exactly(1);
|
||||
// console.log(result);
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_binding ORDER BY num",
|
||||
"SELECT * FROM nodb_binding2 ORDER BY num",
|
||||
[],
|
||||
options,
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
done();
|
||||
|
@ -551,7 +554,7 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it ('4.3.4 should pass but fail in array syntax with returning into', function(done) {
|
||||
connection.execute(
|
||||
|
@ -564,10 +567,10 @@ describe('4. binding.js', function() {
|
|||
// console.log(result);
|
||||
result.outBinds[0].should.eql([123]);
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_binding ORDER BY num",
|
||||
"SELECT * FROM nodb_binding2 ORDER BY num",
|
||||
[],
|
||||
options,
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
done();
|
||||
|
@ -575,9 +578,9 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('4.4 test maxSize option', function() {
|
||||
var connection = null;
|
||||
|
@ -588,24 +591,24 @@ describe('4. binding.js', function() {
|
|||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.release( function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('4.4.1 outBind & maxSize restriction', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_testproc (p_out OUT VARCHAR2) \
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_bindproc4 (p_out OUT VARCHAR2) \
|
||||
AS \
|
||||
BEGIN \
|
||||
p_out := 'ABCDEF GHIJK LMNOP QRSTU'; \
|
||||
END;";
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
|
@ -616,7 +619,7 @@ describe('4. binding.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:o); END;",
|
||||
"BEGIN nodb_bindproc4(:o); END;",
|
||||
{
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize:2 }
|
||||
},
|
||||
|
@ -625,13 +628,14 @@ describe('4. binding.js', function() {
|
|||
// console.log(err.message);
|
||||
err.message.should.startWith('ORA-06502:'); // ORA-06502: PL/SQL: numeric or value error: character string buffer too small
|
||||
// console.log(result);
|
||||
should.not.exist(result);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
/*function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:o); END;",
|
||||
"BEGIN nodb_bindproc4(:o); END;",
|
||||
[
|
||||
{ type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize:22 }
|
||||
],
|
||||
|
@ -639,6 +643,7 @@ describe('4. binding.js', function() {
|
|||
should.exist(err);
|
||||
// console.log(err.message);
|
||||
err.message.should.startWith('ORA-06502:');
|
||||
should.not.exist(result);
|
||||
// console.log(result);
|
||||
callback();
|
||||
}
|
||||
|
@ -646,7 +651,7 @@ describe('4. binding.js', function() {
|
|||
},*/
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_testproc",
|
||||
"DROP PROCEDURE nodb_bindproc4",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -654,7 +659,7 @@ describe('4. binding.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.4.2 default value is 200', function(done) {
|
||||
connection.execute(
|
||||
|
@ -666,7 +671,7 @@ describe('4. binding.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('4.4.3 Negative - bind out data exceeds default length', function(done) {
|
||||
connection.execute(
|
||||
|
@ -677,22 +682,24 @@ describe('4. binding.js', function() {
|
|||
// 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();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it.skip('4.4.4 maximum value is 32767', function(done) {
|
||||
it('4.4.4 maximum value of maxSize option is 32767', function(done) {
|
||||
connection.execute(
|
||||
"BEGIN :o := lpad('A',32767,'x'); END;",
|
||||
{ o: { type: oracledb.STRING, dir : oracledb.BIND_OUT, maxSize:50000 } },
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.outBinds.o.length, 32767);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
}) // 4.4
|
||||
});
|
||||
}); // 4.4
|
||||
|
||||
describe('4.5 The default direction for binding is BIND_IN', function() {
|
||||
var connection = null;
|
||||
|
@ -704,13 +711,13 @@ describe('4. binding.js', function() {
|
|||
connection = conn;
|
||||
assist.createTable(connection, tableName, done);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName,
|
||||
"DROP TABLE " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -724,26 +731,43 @@ describe('4. binding.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('4.5.1 ',function(done) {
|
||||
it('4.5.1 DML default bind',function(done) {
|
||||
connection.execute(
|
||||
"insert into nodb_raw (num) values (:id)",
|
||||
{ id: { val: 1, type: oracledb.NUMBER } },
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
}) // 4.5
|
||||
});
|
||||
|
||||
|
||||
it('4.5.2 negative - DML invalid bind direction',function(done) {
|
||||
connection.execute(
|
||||
"insert into nodb_raw (num) values (:id)",
|
||||
{ id: { val: 1, type: oracledb.NUMBER, dir : 0 } },
|
||||
function(err, result ) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith ( 'NJS-013' );
|
||||
should.not.exist ( result );
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
||||
}); // 4.5
|
||||
|
||||
describe('4.6 PL/SQL block with empty outBinds', function() {
|
||||
|
||||
it('4.6.1 ', function(done) {
|
||||
|
||||
var sql = "begin execute immediate 'drop table does_not_exist'; "
|
||||
var sql = "begin execute immediate 'drop table does_not_exist purge'; "
|
||||
+ "exception when others then "
|
||||
+ "if sqlcode <> -942 then "
|
||||
+ "raise; "
|
||||
|
@ -775,6 +799,357 @@ 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 ];
|
||||
|
||||
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 ();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
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 } ];
|
||||
|
||||
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 ();
|
||||
} );
|
||||
});
|
||||
});
|
||||
|
||||
it ( '4.7.3 Valid test case 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 = [ {val : 1}, 456 ];
|
||||
|
||||
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 ();
|
||||
} );
|
||||
});
|
||||
});
|
||||
|
||||
it ( '4.7.4 Valid Test case when both values are passed as JSON',
|
||||
function (done ) {
|
||||
var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
|
||||
var binds = [ {val : 1}, {val : 456 } ];
|
||||
|
||||
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 ();
|
||||
} );
|
||||
});
|
||||
});
|
||||
|
||||
it ( '4.7.5 Invalid Test case when value is passed as named JSON',
|
||||
function (done ) {
|
||||
var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
|
||||
var binds = [ {val : 1}, { c: {val : 456 } } ];
|
||||
|
||||
oracledb.getConnection (
|
||||
dbConfig,
|
||||
function (err, connection ){
|
||||
should.not.exist ( err ) ;
|
||||
connection.execute (
|
||||
sql,
|
||||
binds,
|
||||
function ( err, result ) {
|
||||
should.exist ( err );
|
||||
(err.message).should.startWith ( 'NJS-044:');
|
||||
should.not.exist(result);
|
||||
done ();
|
||||
} );
|
||||
});
|
||||
});
|
||||
|
||||
it ( '4.7.6 Invalid Test case when other-value is passed as named JSON',
|
||||
function (done ) {
|
||||
var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
|
||||
var binds = [ { b: {val : 1} }, {val : 456 } ];
|
||||
|
||||
oracledb.getConnection (
|
||||
dbConfig,
|
||||
function (err, connection ){
|
||||
should.not.exist ( err ) ;
|
||||
connection.execute (
|
||||
sql,
|
||||
binds,
|
||||
function ( err, result ) {
|
||||
should.exist ( err );
|
||||
(err.message).should.startWith ( 'NJS-044:');
|
||||
should.not.exist(result);
|
||||
done ();
|
||||
} );
|
||||
});
|
||||
});
|
||||
|
||||
it ( '4.7.7 Invalid Test case when all values is passed as named JSON',
|
||||
function (done ) {
|
||||
var sql = "SELECT SYSDATE FROM DUAL WHERE :b = 1 and :c = 456 ";
|
||||
var binds = [ { b: {val : 1} }, { c: {val : 456 } } ];
|
||||
|
||||
oracledb.getConnection (
|
||||
dbConfig,
|
||||
function (err, connection ){
|
||||
should.not.exist ( err ) ;
|
||||
connection.execute (
|
||||
sql,
|
||||
binds,
|
||||
function ( err, result ) {
|
||||
should.exist ( err );
|
||||
(err.message).should.startWith ( 'NJS-044:');
|
||||
should.not.exist(result);
|
||||
done ();
|
||||
} );
|
||||
});
|
||||
}); // 4.7.7
|
||||
}); // 4.7
|
||||
|
||||
describe('4.8 bind DATE', function() {
|
||||
|
||||
var connection = null;
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"alter session set time_zone='UTC'",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
],done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}); // after
|
||||
|
||||
it('4.8.1 binding out in Object & Array formats', function(done) {
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_binddate1 ( \n" +
|
||||
" p_out1 OUT DATE, \n" +
|
||||
" p_out2 OUT DATE \n" +
|
||||
") \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" p_out1 := SYSDATE + 10; \n" +
|
||||
" p_out2 := TO_DATE('2016-08-05', 'YYYY-MM-DD'); \n" +
|
||||
"END;";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_binddate1(:o1, :o2); END;",
|
||||
{
|
||||
o1: { type: oracledb.DATE, dir: oracledb.BIND_OUT },
|
||||
o2: { type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
(result.outBinds.o1).should.be.a.Date();
|
||||
|
||||
var vdate = new Date( "2016-08-05T00:00:00.000Z" );
|
||||
(result.outBinds.o2).should.eql(vdate);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_binddate1(:o1, :o2); END;",
|
||||
[
|
||||
{ type: oracledb.DATE, dir: oracledb.BIND_OUT },
|
||||
{ type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.outBinds[0]).should.be.a.Date();
|
||||
|
||||
var vdate = new Date( "2016-08-05T00:00:00.000Z" );
|
||||
(result.outBinds[1]).should.eql(vdate);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_binddate1",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
|
||||
}); // 4.8.1
|
||||
|
||||
it('4.8.2 BIND_IN', function(done) {
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_binddate2 ( \n" +
|
||||
" p_in IN DATE, \n" +
|
||||
" p_out OUT DATE \n" +
|
||||
") \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" p_out := p_in; \n" +
|
||||
"END;";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var vdate = new Date( Date.UTC( 2016, 7, 5 ) );
|
||||
connection.execute(
|
||||
"BEGIN nodb_binddate2(:i, :o); END;",
|
||||
{
|
||||
i: { type: oracledb.DATE, dir: oracledb.BIND_IN, val: vdate },
|
||||
o: { type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var vdate = new Date( "2016-08-05T00:00:00.000Z" );
|
||||
(result.outBinds.o).should.eql(vdate);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_binddate2",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
|
||||
}); // 4.8.2
|
||||
|
||||
it('4.8.3 BIND_INOUT', function(done) {
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE nodb_binddate3 ( \n" +
|
||||
" p_inout IN OUT DATE \n" +
|
||||
") \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" p_inout := p_inout; \n" +
|
||||
"END;";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var vdate = new Date( Date.UTC( 2016, 7, 5 ) );
|
||||
connection.execute(
|
||||
"BEGIN nodb_binddate3(:io); END;",
|
||||
{
|
||||
io: { val: vdate, dir : oracledb.BIND_INOUT, type: oracledb.DATE }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var vdate = new Date( "2016-08-05T00:00:00.000Z" );
|
||||
(result.outBinds.io).should.eql(vdate);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_binddate3",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
|
||||
}); // 4.8.3
|
||||
|
||||
}); // 4.8
|
||||
});
|
||||
|
|
|
@ -43,17 +43,23 @@ var assist = require('./dataTypeAssist.js');
|
|||
|
||||
describe('61. checkClassesTypes.js', function() {
|
||||
|
||||
var credentials = {
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
};
|
||||
|
||||
it('61.1 Oracledb class', function() {
|
||||
var type = Object.prototype.toString.call(oracledb);
|
||||
type.should.eql('[object Oracledb]');
|
||||
})
|
||||
});
|
||||
|
||||
it('61.2 Connection class', function(done) {
|
||||
async.waterfall(
|
||||
[
|
||||
function(callback)
|
||||
{
|
||||
oracledb.getConnection(dbConfig, callback);
|
||||
oracledb.getConnection(credentials, callback);
|
||||
},
|
||||
function(connection, callback)
|
||||
{
|
||||
|
@ -72,7 +78,7 @@ describe('61. checkClassesTypes.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('61.3 Lob Class', function(done) {
|
||||
var connection = null;
|
||||
|
@ -80,7 +86,7 @@ describe('61. checkClassesTypes.js', function() {
|
|||
|
||||
async.series([
|
||||
function getConn(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
|
@ -105,7 +111,7 @@ describe('61. checkClassesTypes.js', function() {
|
|||
var clobStream = fs.createReadStream(clobFileName);
|
||||
|
||||
clobStream.on('error', function(err) {
|
||||
should.not.exist();
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
|
@ -141,7 +147,7 @@ describe('61. checkClassesTypes.js', function() {
|
|||
},
|
||||
function dropTab(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + clobTableName,
|
||||
"DROP TABLE " + clobTableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -155,13 +161,13 @@ describe('61. checkClassesTypes.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
}) // 61.3
|
||||
}); // 61.3
|
||||
|
||||
it('61.4 Pool Class', function(done) {
|
||||
async.waterfall(
|
||||
[
|
||||
function(callback) {
|
||||
oracledb.createPool(dbConfig, callback);
|
||||
oracledb.createPool(credentials, callback);
|
||||
},
|
||||
function(pool, callback) {
|
||||
var type = Object.prototype.toString.call(pool);
|
||||
|
@ -178,13 +184,13 @@ describe('61. checkClassesTypes.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 61.4
|
||||
}); // 61.4
|
||||
|
||||
it('61.5 ResultSet Class', function(done) {
|
||||
async.waterfall(
|
||||
[
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, callback);
|
||||
oracledb.getConnection(credentials, callback);
|
||||
},
|
||||
function(connection, callback) {
|
||||
connection.execute(
|
||||
|
@ -211,6 +217,6 @@ describe('61. checkClassesTypes.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 61.5
|
||||
}); // 61.5
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -54,7 +54,11 @@ describe('60. clobPlsqlString.js', function() {
|
|||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
|
@ -66,13 +70,13 @@ describe('60. clobPlsqlString.js', function() {
|
|||
assist.createTable(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
after('release connection', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_myclobs",
|
||||
"DROP TABLE nodb_myclobs purge",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -86,7 +90,7 @@ describe('60. clobPlsqlString.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
describe('60.1 BIND OUT as STRING', function() {
|
||||
before('insert data', function(done) {
|
||||
|
@ -97,7 +101,7 @@ describe('60. clobPlsqlString.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
it('60.1.1 PL/SQL OUT CLOB parameters can also be bound as STRING', function(done) {
|
||||
connection.execute(
|
||||
|
@ -113,7 +117,7 @@ describe('60. clobPlsqlString.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 60.1.1
|
||||
}); // 60.1.1
|
||||
|
||||
it('60.1.2 The returned length is limited to the maximum size', function(done) {
|
||||
connection.execute(
|
||||
|
@ -125,11 +129,12 @@ describe('60. clobPlsqlString.js', function() {
|
|||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-06502'); // PL/SQL: numeric or value error
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 60.1.2
|
||||
}) // 60.1
|
||||
}); // 60.1.2
|
||||
}); // 60.1
|
||||
|
||||
describe('60.2 BIND OUT as CLOB', function() {
|
||||
var dataLength = 1000000;
|
||||
|
@ -201,7 +206,7 @@ describe('60. clobPlsqlString.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
}) // 60.2
|
||||
});
|
||||
}); // 60.2
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -42,35 +42,42 @@ describe('9. columnMetadata.js', function(){
|
|||
|
||||
var connection = null;
|
||||
before('get a connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
after('release the connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('9.1 tests with the same table', function() {
|
||||
|
||||
beforeEach('create the table', function(done) {
|
||||
before('create the table', function(done) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942);\n " +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_departments'); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_cmd PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_departments ( \n" +
|
||||
" CREATE TABLE nodb_cmd ( \n" +
|
||||
" department_id NUMBER, \n" +
|
||||
" department_name VARCHAR2(20), \n" +
|
||||
" manager_id NUMBER, \n" +
|
||||
|
@ -78,15 +85,15 @@ describe('9. columnMetadata.js', function(){
|
|||
" ) \n" +
|
||||
" '); \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" INSERT INTO nodb_departments VALUES \n" +
|
||||
" INSERT INTO nodb_cmd VALUES \n" +
|
||||
" (40,''Human Resources'', 203, 2400) \n" +
|
||||
" '); \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" INSERT INTO nodb_departments VALUES \n" +
|
||||
" INSERT INTO nodb_cmd VALUES \n" +
|
||||
" (50,''Shipping'', 121, 1500) \n" +
|
||||
" '); \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" INSERT INTO nodb_departments VALUES \n" +
|
||||
" INSERT INTO nodb_cmd VALUES \n" +
|
||||
" (90, ''Executive'', 100, 1700) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
@ -98,22 +105,22 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // beforeEach
|
||||
}); // before
|
||||
|
||||
afterEach(function(done) {
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_departments",
|
||||
"DROP TABLE nodb_cmd PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // afterEach
|
||||
}); // after
|
||||
|
||||
it('9.1.1 shows metaData correctly when retrieving 1 column from a 4-column table', function(done){
|
||||
|
||||
connection.execute(
|
||||
"SELECT location_id FROM nodb_departments WHERE department_id = :did",
|
||||
"SELECT location_id FROM nodb_cmd WHERE department_id = :did",
|
||||
[50],
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -122,12 +129,12 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 9.1.1
|
||||
}); // 9.1.1
|
||||
|
||||
it('9.1.2 shows metaData when retrieving 2 columns. MetaData is correct in content and sequence', function(done){
|
||||
|
||||
connection.execute(
|
||||
"SELECT department_id, department_name FROM nodb_departments WHERE location_id = :lid",
|
||||
"SELECT department_id, department_name FROM nodb_cmd WHERE location_id = :lid",
|
||||
[1700],
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -137,12 +144,12 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('9.1.3 shows metaData correctly when retrieve 3 columns', function(done){
|
||||
|
||||
connection.execute(
|
||||
"SELECT department_id, department_name, manager_id FROM nodb_departments WHERE location_id = :lid",
|
||||
"SELECT department_id, department_name, manager_id FROM nodb_cmd WHERE location_id = :lid",
|
||||
[2400],
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -153,12 +160,12 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('9.1.4 shows metaData correctly when retrieving all columns with [SELECT * FROM table] statement', function(done){
|
||||
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_cmd ORDER BY department_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
result.rows.length.should.be.exactly(3);
|
||||
|
@ -170,26 +177,26 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 9.1.4
|
||||
}); // 9.1.4
|
||||
|
||||
it('9.1.5 works for SELECT count(*)', function(done){
|
||||
|
||||
connection.execute(
|
||||
"SELECT count(*) FROM nodb_departments",
|
||||
"SELECT count(*) FROM nodb_cmd",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
result.rows[0][0].should.be.exactly(3);
|
||||
result.metaData.should.be.ok;
|
||||
result.metaData.should.be.ok();
|
||||
result.metaData[0].name.should.eql('COUNT(*)');
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 9.1.5
|
||||
}); // 9.1.5
|
||||
|
||||
it('9.1.6 works when a query returns no rows', function(done){
|
||||
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments WHERE department_id = :did",
|
||||
"SELECT * FROM nodb_cmd WHERE department_id = :did",
|
||||
[100],
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -201,23 +208,23 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 9.1.6
|
||||
}); // 9.1.6
|
||||
|
||||
it('9.1.7 only works for SELECT statement, does not work for INSERT', function(done){
|
||||
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_departments VALUES (99, 'FACILITY', 456, 1700)",
|
||||
"INSERT INTO nodb_cmd VALUES (99, 'FACILITY', 456, 1700)",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
should.not.exist(result.metaData);
|
||||
|
||||
connection.execute(
|
||||
'SELECT * FROM nodb_departments WHERE department_id = :1',
|
||||
'SELECT * FROM nodb_cmd WHERE department_id = :1',
|
||||
[99],
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
result.metaData.should.be.ok;
|
||||
result.metaData.should.be.ok();
|
||||
result.metaData.length.should.be.exactly(4);
|
||||
result.metaData[0].name.should.eql('DEPARTMENT_ID');
|
||||
result.metaData[1].name.should.eql('DEPARTMENT_NAME');
|
||||
|
@ -229,12 +236,12 @@ describe('9. columnMetadata.js', function(){
|
|||
);
|
||||
}
|
||||
);
|
||||
}) // 9.1.7
|
||||
}); // 9.1.7
|
||||
|
||||
it('9.1.8 only works for SELECT statement, does not work for UPDATE', function(done){
|
||||
|
||||
connection.execute(
|
||||
"UPDATE nodb_departments SET department_name = 'Finance' WHERE department_id = :did",
|
||||
"UPDATE nodb_cmd SET department_name = 'Finance' WHERE department_id = :did",
|
||||
{ did: 40 },
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -242,11 +249,11 @@ describe('9. columnMetadata.js', function(){
|
|||
should.not.exist(result.metaData);
|
||||
|
||||
connection.execute(
|
||||
"SELECT department_name FROM nodb_departments WHERE department_id = :1",
|
||||
"SELECT department_name FROM nodb_cmd WHERE department_id = :1",
|
||||
[40],
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
result.metaData.should.be.ok;
|
||||
result.metaData.should.be.ok();
|
||||
result.metaData[0].name.should.eql('DEPARTMENT_NAME');
|
||||
result.rows[0][0].should.eql('Finance');
|
||||
done();
|
||||
|
@ -254,12 +261,12 @@ describe('9. columnMetadata.js', function(){
|
|||
);
|
||||
}
|
||||
);
|
||||
}) // 9.1.8
|
||||
}); // 9.1.8
|
||||
|
||||
it('9.1.9 works with a SQL WITH statement', function(done){
|
||||
|
||||
var sqlWith = "WITH nodb_dep AS " +
|
||||
"(SELECT * FROM nodb_departments WHERE location_id < 2000) " +
|
||||
"(SELECT * FROM nodb_cmd WHERE location_id < 2000) " +
|
||||
"SELECT * FROM nodb_dep WHERE department_id > 50 ORDER BY department_id";
|
||||
|
||||
connection.execute(
|
||||
|
@ -274,11 +281,11 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 9.1.9
|
||||
}); // 9.1.9
|
||||
|
||||
it('9.1.10 displays metaData correctly with result set', function(done) {
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments ORDER BY department_id",
|
||||
"SELECT * FROM nodb_cmd ORDER BY department_id",
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
|
@ -290,9 +297,9 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
}) // 9.1
|
||||
}); // 9.1
|
||||
|
||||
describe('9.2 case sensitive', function() {
|
||||
it('9.2.1 works for tables whose column names were created case sensitively', function(done){
|
||||
|
@ -302,12 +309,12 @@ describe('9. columnMetadata.js', function(){
|
|||
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942);\n " +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_casesensitive'); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_casesensitive PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
|
@ -340,7 +347,7 @@ describe('9. columnMetadata.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_casesensitive",
|
||||
"DROP TABLE nodb_casesensitive PURGE",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -348,8 +355,8 @@ describe('9. columnMetadata.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // 9.2.1
|
||||
}) // 9.2
|
||||
}); // 9.2.1
|
||||
}); // 9.2
|
||||
|
||||
describe('9.3 Large number of columns', function() {
|
||||
|
||||
|
@ -367,14 +374,30 @@ describe('9. columnMetadata.js', function(){
|
|||
}
|
||||
|
||||
var table_name = "nodb_large_columns";
|
||||
var sqlCreate = "CREATE TABLE " + table_name + " ( " + columns_string + " )";
|
||||
var sqlSelect = "SELECT * FROM " + table_name;
|
||||
var sqlDrop = "DROP TABLE " + table_name;
|
||||
var sqlDrop = "DROP TABLE " + table_name + " PURGE";
|
||||
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_large_columns PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_large_columns ( \n" +
|
||||
columns_string +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
sqlCreate,
|
||||
proc,
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -403,10 +426,10 @@ describe('9. columnMetadata.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
}) // 9.3
|
||||
});
|
||||
}); // 9.3
|
||||
|
||||
describe('9.4 single character column', function(done) {
|
||||
describe('9.4 single character column', function() {
|
||||
|
||||
it('9.4.1 works with column names consisting of single characters', function(done){
|
||||
|
||||
|
@ -414,12 +437,12 @@ describe('9. columnMetadata.js', function(){
|
|||
var sqlCreate =
|
||||
"BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
|
@ -430,7 +453,7 @@ describe('9. columnMetadata.js', function(){
|
|||
" '); \n" +
|
||||
"END; \n";
|
||||
var sqlSelect = "SELECT * FROM " + tableName;
|
||||
var sqlDrop = "DROP TABLE " + tableName;
|
||||
var sqlDrop = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
|
@ -463,14 +486,14 @@ describe('9. columnMetadata.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
}) // 9.4
|
||||
});
|
||||
}); // 9.4
|
||||
|
||||
describe('9.5 duplicate column alias', function() {
|
||||
|
||||
it('9.5.1 works when using duplicate column alias', function(done) {
|
||||
connection.execute(
|
||||
"SELECT 1 a, 'abc' a from dual",
|
||||
"SELECT 1 a, 'abc' a FROM dual",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.metaData[0].name.should.eql('A');
|
||||
|
@ -478,7 +501,7 @@ describe('9. columnMetadata.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('52. connClose.js', function() {
|
|||
function() {
|
||||
connection.stmtCacheSize = 10;
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
/NJS-014: stmtCacheSize is a read-only property/
|
||||
);
|
||||
done();
|
||||
});
|
||||
|
@ -175,18 +175,14 @@ describe('52. connClose.js', function() {
|
|||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
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();
|
||||
}
|
||||
should.throws(
|
||||
function() {
|
||||
var sql = "select sysdate from dual";
|
||||
connection.execute(sql, function() {});
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -243,7 +239,7 @@ describe('52. connClose.js', function() {
|
|||
mdata = resultSet.metaData;
|
||||
should.not.exist(mdata);
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
/NJS-018: invalid ResultSet/
|
||||
);
|
||||
callback();
|
||||
},
|
||||
|
|
|
@ -40,52 +40,61 @@ var dbConfig = require('./dbconfig.js');
|
|||
|
||||
describe('1. connection.js', function(){
|
||||
|
||||
var credentials = {
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
};
|
||||
|
||||
describe('1.1 can run SQL query with different output formats', function(){
|
||||
|
||||
var connection = null;
|
||||
var script =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_departments'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_conn_dept1 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_departments ( \
|
||||
CREATE TABLE nodb_conn_dept1 ( \
|
||||
department_id NUMBER, \
|
||||
department_name VARCHAR2(20) \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_conn_dept1 \
|
||||
(department_id, department_name) VALUES \
|
||||
(40,''Human Resources'') \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_conn_dept1 \
|
||||
(department_id, department_name) VALUES \
|
||||
(20, ''Marketing'') \
|
||||
'); \
|
||||
END; ";
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
connection.execute(script, function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
oracledb.getConnection(
|
||||
credentials,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
connection.execute(script, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.execute(
|
||||
'DROP TABLE nodb_departments',
|
||||
'DROP TABLE nodb_conn_dept1 PURGE',
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err) {
|
||||
|
@ -94,27 +103,27 @@ describe('1. connection.js', function(){
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
var query = "SELECT department_id, department_name " +
|
||||
"FROM nodb_departments " +
|
||||
"FROM nodb_conn_dept1 " +
|
||||
"WHERE department_id = :id";
|
||||
|
||||
it('1.1.1 ARRAY format by default', function(done) {
|
||||
var defaultFormat = oracledb.outFormat;
|
||||
defaultFormat.should.be.exactly(oracledb.ARRAY);
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(query, [40], function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows).should.eql([[ 40, 'Human Resources' ]]);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('1.1.2 ARRAY format explicitly', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
query, {id: 20}, {outFormat: oracledb.ARRAY},
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -122,10 +131,10 @@ describe('1. connection.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.1.3 OBJECT format', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
query, {id: 20}, {outFormat: oracledb.OBJECT},
|
||||
function(err, result){
|
||||
|
@ -134,37 +143,38 @@ describe('1. connection.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.1.4 Negative test - invalid outFormat value', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
query, {id: 20}, {outFormat:0 },
|
||||
function(err, result){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-004:');
|
||||
// NJS-004: invalid value for property outFormat
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('1.2 limits the number of rows fetched', function(){
|
||||
var connection = false;
|
||||
var createTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_conn_emp2 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_employees ( \
|
||||
CREATE TABLE nodb_conn_emp2 ( \
|
||||
employee_id NUMBER, \
|
||||
employee_name VARCHAR2(20) \
|
||||
) \
|
||||
|
@ -179,29 +189,33 @@ describe('1. connection.js', function(){
|
|||
FOR i IN 1..107 LOOP \
|
||||
x := x + 1; \
|
||||
n := 'staff ' || x; \
|
||||
INSERT INTO nodb_employees VALUES (x, n); \
|
||||
INSERT INTO nodb_conn_emp2 VALUES (x, n); \
|
||||
END LOOP; \
|
||||
END; ";
|
||||
var rowsAmount = 107;
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
connection.execute(createTable, function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.execute(insertRows, function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
before(function(done) {
|
||||
|
||||
})
|
||||
oracledb.getConnection(
|
||||
credentials,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
connection.execute(createTable, function(err) {
|
||||
should.not.exist(err);
|
||||
connection.execute(insertRows, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
}); // before
|
||||
|
||||
after(function(done){
|
||||
connection.execute(
|
||||
'DROP TABLE nodb_employees',
|
||||
'DROP TABLE nodb_conn_emp2 PURGE',
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err) {
|
||||
|
@ -210,15 +224,15 @@ describe('1. connection.js', function(){
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.2.1 by default, the number is 100', function(done){
|
||||
var defaultLimit = oracledb.maxRows;
|
||||
defaultLimit.should.be.exactly(100);
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employee_id",
|
||||
"SELECT * FROM nodb_conn_emp2 ORDER BY employee_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
|
@ -227,12 +241,12 @@ describe('1. connection.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.2.2 can also specify for each execution', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employee_id",
|
||||
"SELECT * FROM nodb_conn_emp2 ORDER BY employee_id",
|
||||
{}, { maxRows: 25 },
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -242,38 +256,40 @@ describe('1. connection.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.2.3 can not set maxRows to be 0', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employee_id",
|
||||
"SELECT * FROM nodb_conn_emp2 ORDER BY employee_id",
|
||||
{}, { maxRows: 0 },
|
||||
function(err, result){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-026:');
|
||||
// NJS-026: maxRows must be greater than zero
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.2.4 cannot set maxRows to be a negative number', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employee_id",
|
||||
"SELECT * FROM nodb_conn_emp2 ORDER BY employee_id",
|
||||
{}, {maxRows: -5},
|
||||
function(err, result){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.2.5 sets maxRows to be very large value', function(done) {
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employee_id",
|
||||
"SELECT * FROM nodb_conn_emp2 ORDER BY employee_id",
|
||||
{},
|
||||
{maxRows: 500000},
|
||||
function(err, result){
|
||||
|
@ -282,14 +298,14 @@ describe('1. connection.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.2.6 shows 12c new way to limit the number of records fetched by queries', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var myoffset = 2; // number of rows to skip
|
||||
var mymaxnumrows = 6; // number of rows to fetch
|
||||
var sql = "SELECT employee_id, employee_name FROM nodb_employees ORDER BY employee_id";
|
||||
var sql = "SELECT employee_id, employee_name FROM nodb_conn_emp2 ORDER BY employee_id";
|
||||
|
||||
if (connection.oracleServerVersion >= 1201000000) {
|
||||
// 12c row-limiting syntax
|
||||
|
@ -311,8 +327,8 @@ describe('1. connection.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('1.3 can call PL/SQL procedures', function(){
|
||||
var connection = false;
|
||||
|
@ -324,20 +340,20 @@ describe('1. connection.js', function(){
|
|||
+ "END; ";
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
connection.execute(proc, function(err, result) {
|
||||
connection.execute(proc, function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_bindingtest",
|
||||
function(err, result){
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release(function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
|
@ -345,7 +361,7 @@ describe('1. connection.js', function(){
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.3.1 bind parameters in various ways', function(done){
|
||||
var bindValues = {
|
||||
|
@ -353,7 +369,7 @@ describe('1. connection.js', function(){
|
|||
io: { val: 'Turing', type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"BEGIN nodb_bindingtest(:i, :io, :o); END;",
|
||||
bindValues,
|
||||
|
@ -364,39 +380,39 @@ describe('1. connection.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('1.4 statementCacheSize controls statement caching', function() {
|
||||
var makeTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_conn_emp4 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_employees ( \
|
||||
CREATE TABLE nodb_conn_emp4 ( \
|
||||
id NUMBER, \
|
||||
name VARCHAR2(4000) \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_conn_emp4 \
|
||||
VALUES \
|
||||
(1001,''Chris Jones'') \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_conn_emp4 \
|
||||
VALUES \
|
||||
(1002,''Tom Kyte'') \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_conn_emp4 \
|
||||
VALUES \
|
||||
(2001, ''Karen Morton'') \
|
||||
'); \
|
||||
|
@ -406,7 +422,7 @@ describe('1. connection.js', function(){
|
|||
var defaultStmtCache = oracledb.stmtCacheSize; // 30
|
||||
|
||||
beforeEach('get connection and prepare table', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
conn.execute(
|
||||
|
@ -417,12 +433,12 @@ describe('1. connection.js', function(){
|
|||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
afterEach('drop table and release connection', function(done) {
|
||||
oracledb.stmtCacheSize = defaultStmtCache;
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_employees",
|
||||
"DROP TABLE nodb_conn_emp4 PURGE",
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err){
|
||||
|
@ -431,16 +447,16 @@ describe('1. connection.js', function(){
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.4.1 stmtCacheSize = 0, which disable statement caching', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
oracledb.stmtCacheSize = 0;
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp4 VALUES (:num, :str)",
|
||||
{ num: 1003, str: 'Robyn Sands' },
|
||||
{ autoCommit: true },
|
||||
function(err) {
|
||||
|
@ -451,7 +467,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp4 VALUES (:num, :str)",
|
||||
{ num: 1004, str: 'Bryant Lin' },
|
||||
{ autoCommit: true },
|
||||
function(err) {
|
||||
|
@ -462,7 +478,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp4 VALUES (:num, :str)",
|
||||
{ num: 1005, str: 'Patrick Engebresson' },
|
||||
{ autoCommit: true },
|
||||
function(err) {
|
||||
|
@ -472,16 +488,16 @@ describe('1. connection.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('1.4.2 works well when statement cache enabled (stmtCacheSize > 0) ', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
oracledb.stmtCacheSize = 100;
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp4 VALUES (:num, :str)",
|
||||
{ num: 1003, str: 'Robyn Sands' },
|
||||
{ autoCommit: true },
|
||||
function(err) {
|
||||
|
@ -492,7 +508,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp4 VALUES (:num, :str)",
|
||||
{ num: 1004, str: 'Bryant Lin' },
|
||||
{ autoCommit: true },
|
||||
function(err) {
|
||||
|
@ -503,7 +519,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp4 VALUES (:num, :str)",
|
||||
{ num: 1005, str: 'Patrick Engebresson' },
|
||||
{ autoCommit: true },
|
||||
function(err) {
|
||||
|
@ -513,35 +529,35 @@ describe('1. connection.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('1.5 Testing commit() & rollback() functions', function() {
|
||||
var makeTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_conn_emp5 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_employees ( \
|
||||
CREATE TABLE nodb_conn_emp5 ( \
|
||||
id NUMBER, \
|
||||
name VARCHAR2(4000) \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_conn_emp5 \
|
||||
VALUES \
|
||||
(1001,''Tom Kyte'') \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_conn_emp5 \
|
||||
VALUES \
|
||||
(1002, ''Karen Morton'') \
|
||||
'); \
|
||||
|
@ -552,21 +568,21 @@ describe('1. connection.js', function(){
|
|||
beforeEach('get 2 connections and create the table', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
conn1 = conn;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
conn2 = conn;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
conn1.should.be.ok;
|
||||
conn1.should.be.ok();
|
||||
conn1.execute(
|
||||
makeTable,
|
||||
[],
|
||||
|
@ -578,15 +594,15 @@ describe('1. connection.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
afterEach('drop table and release connections', function(done) {
|
||||
conn1.should.be.ok;
|
||||
conn2.should.be.ok;
|
||||
conn1.should.be.ok();
|
||||
conn2.should.be.ok();
|
||||
async.series([
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"DROP TABLE nodb_employees",
|
||||
"DROP TABLE nodb_conn_emp5 PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -606,14 +622,14 @@ describe('1. connection.js', function(){
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
it('1.5.1 commit() function works well', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp5 VALUES (:num, :str)",
|
||||
{ num: 1003, str: 'Patrick Engebresson' },
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
|
@ -623,7 +639,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"SELECT COUNT(*) FROM nodb_employees",
|
||||
"SELECT COUNT(*) FROM nodb_conn_emp5",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0][0].should.be.exactly(2);
|
||||
|
@ -633,7 +649,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT COUNT(*) FROM nodb_employees",
|
||||
"SELECT COUNT(*) FROM nodb_conn_emp5",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0][0].should.be.exactly(3);
|
||||
|
@ -649,7 +665,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"SELECT COUNT(*) FROM nodb_employees",
|
||||
"SELECT COUNT(*) FROM nodb_conn_emp5",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0][0].should.be.exactly(3);
|
||||
|
@ -659,13 +675,13 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
], done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('1.5.2 rollback() function works well', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"INSERT INTO nodb_employees VALUES (:num, :str)",
|
||||
"INSERT INTO nodb_conn_emp5 VALUES (:num, :str)",
|
||||
{ num: 1003, str: 'Patrick Engebresson' },
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
|
@ -675,7 +691,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
conn1.execute(
|
||||
"SELECT COUNT(*) FROM nodb_employees",
|
||||
"SELECT COUNT(*) FROM nodb_conn_emp5",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0][0].should.be.exactly(2);
|
||||
|
@ -685,7 +701,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT COUNT(*) FROM nodb_employees",
|
||||
"SELECT COUNT(*) FROM nodb_conn_emp5",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0][0].should.be.exactly(3);
|
||||
|
@ -701,7 +717,7 @@ describe('1. connection.js', function(){
|
|||
},
|
||||
function(callback) {
|
||||
conn2.execute(
|
||||
"SELECT COUNT(*) FROM nodb_employees",
|
||||
"SELECT COUNT(*) FROM nodb_conn_emp5",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.rows[0][0].should.be.exactly(2);
|
||||
|
@ -710,14 +726,14 @@ describe('1. connection.js', function(){
|
|||
);
|
||||
},
|
||||
], done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('1.6 Testing parameter assertions', function() {
|
||||
var conn1;
|
||||
|
||||
beforeEach('get connection ready', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
conn1 = conn;
|
||||
done();
|
||||
|
@ -889,7 +905,7 @@ describe('1. connection.js', function(){
|
|||
|
||||
describe('1.7 Close method', function() {
|
||||
it('1.7.1 close can be used as an alternative to release', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.close(function(err) {
|
||||
|
@ -898,6 +914,28 @@ describe('1. connection.js', function(){
|
|||
});
|
||||
});
|
||||
});
|
||||
}); // 1.7
|
||||
|
||||
describe('1.8 invalid credentials', function() {
|
||||
|
||||
it('1.8.1 cannot get connections with invalid credentials', function(done) {
|
||||
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: 'notexist',
|
||||
password: 'nopass',
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, connection) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-01017:');
|
||||
should.not.exist(connection);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. */
|
||||
/* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -190,7 +190,7 @@ assist.data = {
|
|||
new Date('2015-07-23 22:00:00'),
|
||||
new Date('2015-07-23 23:00:00'),
|
||||
new Date('2015-07-24 00:00:00'),
|
||||
new Date(2003, 09, 23, 11, 50, 30, 123)
|
||||
new Date(2003, 9, 23, 11, 50, 30, 123)
|
||||
]
|
||||
};
|
||||
|
||||
|
@ -497,20 +497,20 @@ assist.content =
|
|||
|
||||
|
||||
var StringBuffer = function() {
|
||||
this.buffer = [];
|
||||
this.index = 0;
|
||||
this.buffer = [];
|
||||
this.index = 0;
|
||||
};
|
||||
|
||||
StringBuffer.prototype = {
|
||||
append: function(s) {
|
||||
this.buffer[this.index] = s;
|
||||
this.index += 1;
|
||||
return this;
|
||||
},
|
||||
append: function(s) {
|
||||
this.buffer[this.index] = s;
|
||||
this.index += 1;
|
||||
return this;
|
||||
},
|
||||
|
||||
toString: function() {
|
||||
return this.buffer.join("");
|
||||
}
|
||||
toString: function() {
|
||||
return this.buffer.join("");
|
||||
}
|
||||
};
|
||||
|
||||
assist.createCharString = function(size) {
|
||||
|
@ -528,7 +528,7 @@ assist.createCharString = function(size) {
|
|||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
};
|
||||
|
||||
assist.createBuffer = function(size) {
|
||||
var array = [];
|
||||
|
@ -537,7 +537,22 @@ assist.createBuffer = function(size) {
|
|||
array.push(b);
|
||||
}
|
||||
return new Buffer(array);
|
||||
}
|
||||
};
|
||||
|
||||
assist.compare2Buffers = function(originalBuf, compareBuf) {
|
||||
var node01113plus = true; // assume node runtime version is higher than 0.11.13
|
||||
var nodeVer = process.versions["node"].split(".");
|
||||
if(nodeVer[0] === "0" && nodeVer[1] === "11" && nodeVer[2] < "13") {
|
||||
node01113plus = false;
|
||||
} else if(nodeVer[0] === "0" && nodeVer[1] < "11"){
|
||||
node01113plus = false;
|
||||
}
|
||||
if(node01113plus === true) {
|
||||
return originalBuf.equals(compareBuf);
|
||||
} else {
|
||||
return (originalBuf.toString('utf8') === compareBuf.toString('utf8'));
|
||||
}
|
||||
};
|
||||
|
||||
assist.setUp = function(connection, tableName, array, done)
|
||||
{
|
||||
|
@ -549,7 +564,7 @@ assist.setUp = function(connection, tableName, array, done)
|
|||
assist.insertDataArray(connection, tableName, array, callback);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
};
|
||||
|
||||
assist.setUp4sql = function(connection, tableName, array, done)
|
||||
{
|
||||
|
@ -561,7 +576,7 @@ assist.setUp4sql = function(connection, tableName, array, done)
|
|||
assist.insertData4sql(connection, tableName, array, callback);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
};
|
||||
|
||||
assist.createTable = function(connection, tableName, done)
|
||||
{
|
||||
|
@ -573,7 +588,7 @@ assist.createTable = function(connection, tableName, done)
|
|||
done();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
assist.insertDataArray = function(connection, tableName, array, done)
|
||||
{
|
||||
|
@ -591,7 +606,7 @@ assist.insertDataArray = function(connection, tableName, array, done)
|
|||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
assist.insertData4sql = function(connection, tableName, array, done)
|
||||
{
|
||||
|
@ -610,19 +625,19 @@ assist.insertData4sql = function(connection, tableName, array, done)
|
|||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
assist.sqlCreateTable = function(tableName)
|
||||
{
|
||||
var createTab =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" e_table_missing EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE'); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" WHEN e_table_missing " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
|
@ -635,13 +650,13 @@ assist.sqlCreateTable = function(tableName)
|
|||
"END; ";
|
||||
|
||||
return createTab;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/************************* Functions for Verifiction *********************************/
|
||||
|
||||
assist.dataTypeSupport = function(connection, tableName, array, done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName + " ORDER BY num",
|
||||
[],
|
||||
|
@ -664,7 +679,7 @@ assist.dataTypeSupport = function(connection, tableName, array, done) {
|
|||
done();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
assist.verifyResultSet = function(connection, tableName, array, done)
|
||||
{
|
||||
|
@ -679,7 +694,7 @@ assist.verifyResultSet = function(connection, tableName, array, done)
|
|||
fetchRowsFromRS(result.resultSet, array, done);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
assist.verifyRefCursor = function(connection, tableName, array, done)
|
||||
{
|
||||
|
@ -723,7 +738,7 @@ assist.verifyRefCursor = function(connection, tableName, array, done)
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
};
|
||||
|
||||
var numRows = 3; // number of rows to return from each call to getRows()
|
||||
function fetchRowsFromRS(rs, array, cb)
|
||||
|
@ -758,9 +773,10 @@ assist.selectOriginalData = function(connection, tableName, array, done)
|
|||
connection.execute(
|
||||
"SELECT * FROM " + tableName + " WHERE num = :no",
|
||||
{ no: array.indexOf(element) },
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.rows);
|
||||
|
||||
cb();
|
||||
}
|
||||
);
|
||||
|
@ -768,14 +784,14 @@ assist.selectOriginalData = function(connection, tableName, array, done)
|
|||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/* Null value verfication */
|
||||
assist.verifyNullValues = function(connection, tableName, done)
|
||||
{
|
||||
var sqlInsert = "INSERT INTO " + tableName + " VALUES(:no, :bindValue)";
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
async.series([
|
||||
function createTable(callback) {
|
||||
var sqlCreate = assist.sqlCreateTable(tableName);
|
||||
|
@ -856,7 +872,7 @@ assist.verifyNullValues = function(connection, tableName, done)
|
|||
},
|
||||
function dropTable(callback) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -879,6 +895,24 @@ assist.verifyNullValues = function(connection, tableName, done)
|
|||
);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
assist.compareNodejsVersion = function(nowVersion, comparedVersion) {
|
||||
// return true if nowVersion > or = comparedVersion;
|
||||
// else return false;
|
||||
var now = nowVersion.split(".");
|
||||
var compare = comparedVersion.split(".");
|
||||
if(now[0] > compare[0]) {
|
||||
return true;
|
||||
} else if(now[0] === compare[0] && now[1] > compare[1]) {
|
||||
return true;
|
||||
} else if(now[0] === compare[0] && now[1] === compare[1] && now[2] > compare[2]) {
|
||||
return true;
|
||||
} else if (now[0] === compare[0] && now[1] === compare[1] && now[2] === compare[2]){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = assist;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
|
@ -45,19 +44,26 @@ describe('31. dataTypeBinaryDouble.js', function() {
|
|||
var tableName = "nodb_double";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('31.1 testing BINARY_DOUBLE data', function() {
|
||||
|
||||
|
@ -65,36 +71,74 @@ describe('31. dataTypeBinaryDouble.js', function() {
|
|||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('31.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('31.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('31.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('31.2 stores null value correctly', function() {
|
||||
it('31.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
describe('31.3 testing floating-point numbers which can be precisely represent', function() {
|
||||
var nums =
|
||||
[
|
||||
0.0000000000000000000123,
|
||||
98.7654321
|
||||
];
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, nums, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('31.3.1 testing floating-point numbers', function(done) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
for(var i = 0; i < nums.length; i++) {
|
||||
result.rows[i].CONTENT.should.be.exactly(nums[ result.rows[i].NUM ]);
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}); // 31.3
|
||||
});
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
|
@ -45,19 +44,26 @@ describe('30. dataTypeBinaryFloat.js', function() {
|
|||
var tableName = "nodb_binary_float";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('30.1 testing BINARY_FLOAT data', function() {
|
||||
|
||||
|
@ -65,60 +71,60 @@ describe('30. dataTypeBinaryFloat.js', function() {
|
|||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('30.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('30.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('30.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
}) // 30.1
|
||||
}); // 30.1
|
||||
|
||||
describe('30.2 stores null value correctly', function() {
|
||||
it('30.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('30.3 testing floating-point numbers which cannot be precisely represent', function() {
|
||||
var nums =
|
||||
[
|
||||
2345.67,
|
||||
9876.54321,
|
||||
0.01234,
|
||||
0.00000123
|
||||
];
|
||||
[
|
||||
2345.67,
|
||||
9876.54321,
|
||||
0.01234,
|
||||
0.00000123
|
||||
];
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, nums, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('30.3.1 rounding numbers', function(done) {
|
||||
connection.execute(
|
||||
|
@ -130,17 +136,17 @@ describe('30. dataTypeBinaryFloat.js', function() {
|
|||
|
||||
for(var i = 0; i < nums.length; i++) {
|
||||
result.rows[i].CONTENT.should.not.be.exactly(nums[ result.rows[i].NUM ]);
|
||||
approxeq(result.rows[i].CONTENT, nums[ result.rows[i].NUM ]).should.be.ok;
|
||||
approxeq(result.rows[i].CONTENT, nums[ result.rows[i].NUM ]).should.be.ok();
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
function approxeq(v1, v2)
|
||||
{
|
||||
var precision = 0.001;
|
||||
return Math.abs(v1 - v2) < precision;
|
||||
}
|
||||
}) // 30.3
|
||||
})
|
||||
}); // 30.3
|
||||
});
|
||||
|
|
|
@ -48,50 +48,62 @@ var assist = require('./dataTypeAssist.js');
|
|||
var inFileName = './test/fuzzydinosaur.jpg'; // contains the image to be inserted
|
||||
var outFileName = './test/blobstreamout.jpg';
|
||||
|
||||
describe('41. dataTypeBlob', function() {
|
||||
this.timeout(10000);
|
||||
describe('41. dataTypeBlob.js', function() {
|
||||
this.timeout(20000);
|
||||
|
||||
var connection = null;
|
||||
var nodever6 = false;
|
||||
|
||||
var tableName = "nodb_myblobs";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
if ( process.versions["node"].substring (0, 1) >= "6" )
|
||||
nodever6 = true;
|
||||
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('41.1 testing BLOB data type', function() {
|
||||
before('create table', function(done) {
|
||||
assist.createTable(connection, tableName, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('41.1.1 stores BLOB value correctly', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
async.series([
|
||||
function blobinsert1(callback) {
|
||||
|
||||
var lobFinishEventFired = false;
|
||||
setTimeout( function() {
|
||||
lobFinishEventFired.should.equal(true, "lob does not call 'finish' event!")
|
||||
lobFinishEventFired.should.equal(true, "lob does not call 'finish' event!");
|
||||
callback();
|
||||
}, 2000);
|
||||
|
||||
|
@ -186,7 +198,7 @@ describe('41. dataTypeBlob', function() {
|
|||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var blob = Buffer(0);
|
||||
var blob = nodever6 ? Buffer.alloc(0) : new Buffer(0);
|
||||
var blobLength = 0;
|
||||
var lob = result.rows[0][0];
|
||||
|
||||
|
@ -224,13 +236,13 @@ describe('41. dataTypeBlob', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
}) // 41.1.1
|
||||
}) //41.1
|
||||
}); // 41.1.1
|
||||
}); //41.1
|
||||
|
||||
describe('41.2 stores null value correctly', function() {
|
||||
it('41.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -46,61 +46,68 @@ describe('22. dataTypeChar.js', function(){
|
|||
|
||||
var strLen = [100, 1000, 2000]; // char string length
|
||||
var strs =
|
||||
[
|
||||
assist.createCharString(strLen[0]),
|
||||
assist.createCharString(strLen[1]),
|
||||
assist.createCharString(strLen[2]),
|
||||
];
|
||||
[
|
||||
assist.createCharString(strLen[0]),
|
||||
assist.createCharString(strLen[1]),
|
||||
assist.createCharString(strLen[2]),
|
||||
];
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('22.1 testing CHAR data in various lengths', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('22.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('22.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('22.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, strs, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('22.2 stores null value correctly', function() {
|
||||
it('22.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('22.3 PL/SQL binding scalar', function() {
|
||||
|
||||
|
@ -113,7 +120,7 @@ describe('22. dataTypeChar.js', function(){
|
|||
"BEGIN\n" +
|
||||
" RETURN 'Hello ' || stringValue || ' world!';\n" +
|
||||
"END testchar;";
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
|
@ -130,7 +137,7 @@ describe('22. dataTypeChar.js', function(){
|
|||
connection.execute(
|
||||
"BEGIN :result := testchar(:stringValue); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
callback();
|
||||
|
@ -147,7 +154,7 @@ describe('22. dataTypeChar.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // 22.3.1
|
||||
}); // 22.3.1
|
||||
|
||||
it('22.3.2 bind scalar values INOUT', function(done) {
|
||||
async.series([
|
||||
|
@ -175,6 +182,8 @@ describe('22. dataTypeChar.js', function(){
|
|||
should.exist(err);
|
||||
// Error: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
|
||||
// For SQL*PLUS driver, the behavior is the same
|
||||
|
||||
should.not.exist(result);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
|
@ -189,7 +198,7 @@ describe('22. dataTypeChar.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // 22.3.2
|
||||
}); // 22.3.2
|
||||
|
||||
it('22.3.3 bind scalar values OUT', function(done) {
|
||||
async.series([
|
||||
|
@ -232,8 +241,8 @@ describe('22. dataTypeChar.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // 22.3.3
|
||||
}) // 22.3
|
||||
}); // 22.3.3
|
||||
}); // 22.3
|
||||
|
||||
describe('22.4 PL/SQL binding indexed tables', function() {
|
||||
|
||||
|
@ -246,7 +255,7 @@ describe('22. dataTypeChar.js', function(){
|
|||
" TYPE stringsType IS TABLE OF CHAR(30) INDEX BY BINARY_INTEGER;\n" +
|
||||
" FUNCTION test(strings IN stringsType) RETURN CHAR;\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
|
@ -303,6 +312,6 @@ describe('22. dataTypeChar.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -50,44 +50,50 @@ var inFileName = './test/clobexample.txt'; // the file with text to be inserted
|
|||
var outFileName = './test/clobstreamout.txt';
|
||||
|
||||
describe('40. dataTypeClob.js', function() {
|
||||
|
||||
this.timeout(15000);
|
||||
this.timeout(10000);
|
||||
|
||||
var connection = null;
|
||||
var tableName = "nodb_myclobs";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('40.1 testing CLOB data type', function() {
|
||||
before('create table', function(done) {
|
||||
assist.createTable(connection, tableName, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('40.1.1 stores CLOB value correctly', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
async.series([
|
||||
function clobinsert1(callback) {
|
||||
|
||||
|
@ -240,7 +246,7 @@ describe('40. dataTypeClob.js', function() {
|
|||
|
||||
lob.on('data', function(chunk) {
|
||||
lobDataEventFired = true;
|
||||
clob += chunk;
|
||||
clob = clob + chunk;
|
||||
});
|
||||
|
||||
lob.on('end', function() {
|
||||
|
@ -261,14 +267,14 @@ describe('40. dataTypeClob.js', function() {
|
|||
}
|
||||
], done); // async
|
||||
|
||||
}) // 40.1.1
|
||||
}); // 40.1.1
|
||||
|
||||
}) // 40.1
|
||||
}); // 40.1
|
||||
|
||||
describe('40.2 stores null value correctly', function() {
|
||||
it('40.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -45,36 +45,43 @@ describe('32. dataTypeDate.js', function() {
|
|||
var tableName = "nodb_date";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('32.1 Testing JavaScript Date data', function() {
|
||||
var dates = assist.data.dates;
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('32.1.1 works well with SELECT query', function(done) {
|
||||
var arrayLength = dates.length;
|
||||
|
@ -84,44 +91,44 @@ describe('32. dataTypeDate.js', function() {
|
|||
}
|
||||
|
||||
assist.dataTypeSupport(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('32.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('32.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
}) // 32.1 suite
|
||||
}); // 32.1 suite
|
||||
|
||||
describe('32.2 stores null value correctly', function() {
|
||||
it('32.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('32.3 insert SQL Date data', function(done) {
|
||||
describe('32.3 insert SQL Date data', function() {
|
||||
var dates = assist.DATE_STRINGS;
|
||||
|
||||
before(function(done) {
|
||||
assist.setUp4sql(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('32.3.1 SELECT query - original data', function(done) {
|
||||
assist.selectOriginalData(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('32.3.2 SELECT query - formatted data for comparison', function(done) {
|
||||
async.forEach(dates, function(date, cb) {
|
||||
|
@ -138,11 +145,11 @@ describe('32. dataTypeDate.js', function() {
|
|||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
}) // end of 32.3 suite
|
||||
}); // end of 32.3 suite
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -45,52 +45,59 @@ describe('28. dataTypeFloat.js', function() {
|
|||
var numbers = assist.data.numbers;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('28.1 testing FLOAT data type', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('28.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('28.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('28.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, numbers, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('28.2 stores null value correctly', function() {
|
||||
it('28.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -45,53 +45,60 @@ describe('29. dataTypeFloat2.js', function() {
|
|||
var numbers = assist.data.numbers;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('29.1 testing FLOAT(p) data type', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('29.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('29.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('29.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, numbers, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('29.2 stores null value correctly', function() {
|
||||
it('29.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -49,53 +49,60 @@ describe('23. dataTypeNchar.js', function(){
|
|||
strs[i] = assist.createCharString(strLen[i]);
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('23.1 testing NCHAR data in various lengths', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('23.1.1 SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('23.1.2 resultSet stores NCHAR data correctly', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('23.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, strs, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('23.2 stores null value correctly', function() {
|
||||
it('23.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -45,54 +45,61 @@ describe('26. dataTypeNumber.js', function() {
|
|||
var numbers = assist.data.numbers;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('26.1 testing NUMBER data', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('26.1.1 SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('26.1.2 resultSet stores NUMBER data correctly', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('26.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('26.2 stores null value correctly', function() {
|
||||
it('26.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
|
@ -46,38 +45,45 @@ describe('27. dataTypeNumber2.js', function() {
|
|||
var numbers = assist.data.numbers;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('27.1 testing NUMBER(p, s) data', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, numbers, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('27.1.1 SELECT query', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
[],
|
||||
|
@ -94,10 +100,10 @@ describe('27. dataTypeNumber2.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
}) // 27.1.1
|
||||
}); // 27.1.1
|
||||
|
||||
it('27.1.2 resultSet stores NUMBER(p, s) data correctly', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
var numRows = 3; // number of rows to return from each call to getRows()
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
|
@ -118,7 +124,7 @@ describe('27. dataTypeNumber2.js', function() {
|
|||
for(var i = 0; i < rows.length; i++) {
|
||||
if(Math.abs( numbers[rows[i].NUM] ) == 0.00000123)
|
||||
rows[i].CONTENT.should.be.exactly(0);
|
||||
else
|
||||
else
|
||||
rows[i].CONTENT.should.be.exactly(numbers[rows[i].NUM]);
|
||||
}
|
||||
return fetchRowsFromRS(rs);
|
||||
|
@ -134,14 +140,14 @@ describe('27. dataTypeNumber2.js', function() {
|
|||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}) // 27.1
|
||||
}); // 27.1
|
||||
|
||||
describe('27.2 stores null value correctly', function() {
|
||||
it('27.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -49,53 +49,60 @@ describe('25. dataTypeNvarchar2.js', function() {
|
|||
strs[i] = assist.createCharString(strLen[i]);
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('25.1 testing NVARCHAR2 data in various lengths', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('25.1.1 SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('25.1.2 resultSet stores NVARCHAR2 data correctly', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('25.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, strs, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('25.2 stores null value correctly', function() {
|
||||
it('25.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -38,11 +38,14 @@ var should = require('should');
|
|||
var async = require('async');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var random = require('./random.js');
|
||||
|
||||
describe('42. dataTypeRaw.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var tableName = "nodb_raw";
|
||||
var node6plus = false; // assume node runtime version is lower than 6
|
||||
var insertID = 1;
|
||||
|
||||
var bufLen = [10 ,100, 1000, 2000]; // buffer length
|
||||
var bufs = [];
|
||||
|
@ -50,47 +53,57 @@ describe('42. dataTypeRaw.js', function() {
|
|||
bufs[i] = assist.createBuffer(bufLen[i]);
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
if (process.versions["node"].substring (0, 1) >= "6") {
|
||||
node6plus = true;
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('42.1 testing RAW data in various lengths', function() {
|
||||
|
||||
before('create table, insert data', function(done) {
|
||||
assist.setUp(connection, tableName, bufs, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.1.1 SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, bufs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.1.2 resultSet stores RAW data correctly', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, bufs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, bufs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.1.4 result set getRow() function works well with RAW', function(done) {
|
||||
|
||||
|
@ -119,44 +132,45 @@ describe('42. dataTypeRaw.js', function() {
|
|||
}
|
||||
});
|
||||
}
|
||||
}) // 42.1.4
|
||||
}); // 42.1.4
|
||||
|
||||
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);
|
||||
should.exist(err);
|
||||
// NJS-011: encountered bind value and type mismatch
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
done();
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('42.2 stores null value correctly', function() {
|
||||
it('42.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('42.3 DML Returning - Currently not support RAW', function() {
|
||||
|
||||
before('create table', function(done) {
|
||||
assist.createTable(connection, tableName, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.3.1 INSERT statement with Object binding', function(done) {
|
||||
var seq = 1;
|
||||
|
@ -176,10 +190,11 @@ describe('42. dataTypeRaw.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
// NJS-028: raw database type is not supported with DML Returning statements
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 42.3.1
|
||||
}); // 42.3.1
|
||||
|
||||
it('42.3.2 INSERT statement with ARRAY binding', function(done) {
|
||||
var seq = 2;
|
||||
|
@ -198,10 +213,11 @@ describe('42. dataTypeRaw.js', function() {
|
|||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 42.3.2
|
||||
}); // 42.3.2
|
||||
|
||||
it('42.3.3 INSERT statement with exact maxSize restriction', function(done) {
|
||||
var seq = 3;
|
||||
|
@ -220,10 +236,11 @@ describe('42. dataTypeRaw.js', function() {
|
|||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.3.4 UPDATE statement', function(done) {
|
||||
var seq = 2;
|
||||
|
@ -242,10 +259,11 @@ describe('42. dataTypeRaw.js', function() {
|
|||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 42.3.4
|
||||
}); // 42.3.4
|
||||
|
||||
it('42.3.6 DELETE statement with single row matching', function(done) {
|
||||
var seq = 1;
|
||||
|
@ -261,10 +279,11 @@ describe('42. dataTypeRaw.js', function() {
|
|||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.3.7 DELETE statement with multiple rows matching', function(done) {
|
||||
var seq = 1;
|
||||
|
@ -280,12 +299,13 @@ describe('42. dataTypeRaw.js', function() {
|
|||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
}) // 42.3
|
||||
}); // 42.3
|
||||
|
||||
describe('42.4 in PL/SQL, the maximum size is 32767', function() {
|
||||
|
||||
|
@ -304,7 +324,7 @@ describe('42. dataTypeRaw.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
|
@ -314,7 +334,7 @@ describe('42. dataTypeRaw.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.4.1 when data length is less than maxSize', function(done) {
|
||||
var size = 5;
|
||||
|
@ -334,7 +354,7 @@ describe('42. dataTypeRaw.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.4.2 when data length is 32767', function(done) {
|
||||
var size = 32767;
|
||||
|
@ -354,7 +374,7 @@ describe('42. dataTypeRaw.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.4.3 when data length greater than maxSize', function(done) {
|
||||
var size = 32800;
|
||||
|
@ -364,16 +384,16 @@ describe('42. dataTypeRaw.js', function() {
|
|||
"BEGIN nodb_testraw(:i, :o); END;",
|
||||
{
|
||||
i: { type: oracledb.BUFFER, dir: oracledb.BIND_IN, val: buf },
|
||||
o: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: 32767}
|
||||
o: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: size }
|
||||
},
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// ORA-01460: unimplemented or unreasonable conversion requested
|
||||
(err.message).should.startWith('ORA-01460');
|
||||
// ORA-06502: PL/SQL: numeric or value error\nORA-06512: at line 1
|
||||
(err.message).should.startWith('ORA-06502:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('42.4.4 when maxSize is greater than 32767', function(done) {
|
||||
var size = 32800;
|
||||
|
@ -385,14 +405,230 @@ describe('42. dataTypeRaw.js', function() {
|
|||
i: { type: oracledb.BUFFER, dir: oracledb.BIND_IN, val: buf },
|
||||
o: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: 40000}
|
||||
},
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
// ORA-01460: unimplemented or unreasonable conversion requested
|
||||
(err.message).should.startWith('ORA-01460');
|
||||
// ORA-06502: PL/SQL: numeric or value error\nORA-06512: at line 1
|
||||
(err.message).should.startWith('ORA-06502:');
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
}) // 42.4
|
||||
});
|
||||
}); // 42.4
|
||||
|
||||
})
|
||||
describe('45.5 INSERT and SELECT', function() {
|
||||
before(function(done) {
|
||||
assist.createTable(connection, tableName, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
it('45.5.1 works with data size 100', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr);
|
||||
test1(insertedBuf, done);
|
||||
});
|
||||
|
||||
it('45.5.2 works with data size 2000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(2000);
|
||||
var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr);
|
||||
test1(insertedBuf, done);
|
||||
});
|
||||
|
||||
it('45.5.3 works with default type/dir', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(2000);
|
||||
var insertedBuf = node6plus ? new Buffer(insertedStr) : Buffer.from(insertedStr);
|
||||
test1_default(insertedBuf, done);
|
||||
});
|
||||
|
||||
}); // 45.5
|
||||
|
||||
describe('45.6 UPDATE', function() {
|
||||
before(function(done) {
|
||||
assist.createTable(connection, tableName, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
it('45.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);
|
||||
test2(insertedBuf, updateBuf, done);
|
||||
});
|
||||
|
||||
it('45.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);
|
||||
test2(insertedBuf, updateBuf, done);
|
||||
});
|
||||
|
||||
it('45.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);
|
||||
test2_default(insertedBuf, updateBuf, done);
|
||||
});
|
||||
|
||||
}); // 45.6
|
||||
|
||||
var test1 = function(content, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
insert(content, cb);
|
||||
},
|
||||
function(cb) {
|
||||
fetch(content, cb);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var test1_default = function(content, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
insert_default(content, cb);
|
||||
},
|
||||
function(cb) {
|
||||
fetch(content, cb);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var test2 = function(insertedStr, updateStr, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
insert(insertedStr, cb);
|
||||
},
|
||||
function(cb) {
|
||||
update(updateStr, cb);
|
||||
},
|
||||
function(cb) {
|
||||
fetch(updateStr, cb);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var test2_default = function(insertedStr, updateStr, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
insert(insertedStr, cb);
|
||||
},
|
||||
function(cb) {
|
||||
update_default(updateStr, cb);
|
||||
},
|
||||
function(cb) {
|
||||
fetch(updateStr, cb);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var insert = function(content, callback) {
|
||||
var sql = "insert into " + tableName + " (num, 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 }
|
||||
};
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var insert_default = function(content, callback) {
|
||||
var sql = "insert into " + tableName + " (num, content) values (:i, :c)";
|
||||
var bindVar = {
|
||||
i: insertID,
|
||||
c: content
|
||||
};
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var update = function(content, callback) {
|
||||
var sql = "update " + tableName + " set content = :c where num = :i";
|
||||
var bindVar = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: content, dir: oracledb.BIND_IN, type: oracledb.BUFFER }
|
||||
};
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var update_default = function(content, callback) {
|
||||
var sql = "update " + tableName + " set content = :c where num = :i";
|
||||
var bindVar = {
|
||||
i: insertID,
|
||||
c: content
|
||||
};
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var fetch = function(expected, callback) {
|
||||
var sql = "select content from " + tableName + " where num = " + insertID;
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
assist.compare2Buffers(result.rows[0][0], expected);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -39,10 +39,12 @@ var async = require('async');
|
|||
var assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe.skip('39. dataTypeRowid.js', function() {
|
||||
describe('39. dataTypeRowid.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var tableName = "nodb_rowid";
|
||||
var array = assist.data.numbersForBinaryFloat;
|
||||
var numRows = array.length; // number of rows to return from each call to getRows()
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
|
@ -50,14 +52,14 @@ describe.skip('39. dataTypeRowid.js', function() {
|
|||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('39.1 testing ROWID data type', function() {
|
||||
before(function(done) {
|
||||
|
@ -66,45 +68,215 @@ describe.skip('39. dataTypeRowid.js', function() {
|
|||
assist.createTable(connection, tableName, callback);
|
||||
},
|
||||
function insertOneRow(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO " + tableName + "(num) VALUES(1)",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
connection.execute(
|
||||
"UPDATE " + tableName + " T SET content = T.ROWID",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('39.1.1 query rowid [*** NEW FUNCTIONALITY ***]', function(done) {
|
||||
it('39.1.1 query rowid', function(done) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
for(var i = 0; i < array.length; i++) {
|
||||
var resultVal = result.rows[i][1];
|
||||
should.strictEqual(typeof resultVal, "string");
|
||||
resultVal.should.not.be.null;
|
||||
should.exist(resultVal);
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
it('39.1.2 works well with result set', function(done) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
[],
|
||||
{ resultSet: true, outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.resultSet.metaData[0]).name.should.eql('NUM');
|
||||
(result.resultSet.metaData[1]).name.should.eql('CONTENT');
|
||||
fetchRowsFromRS(result.resultSet, done);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('39.1.3 ROWID couldn\'t update', function(done) {
|
||||
connection.execute(
|
||||
"update " + tableName + " set ROWID = CHARTOROWID('AAAspiAABAAAZnJAAE') where num = 1",
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "ORA-01747: invalid user.table.column, table.column, or column specification");
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('39.1.4 can get data object number correctly', function(done) {
|
||||
connection.execute(
|
||||
"select dbms_rowid.rowid_object(ROWID) AS C from " + tableName + " WHERE ROWNUM <=1",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][0];
|
||||
should.strictEqual(typeof resultVal, "number");
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('39.1.5 can get datafile number correctly', function(done) {
|
||||
connection.execute(
|
||||
"select dbms_rowid.rowid_relative_fno(ROWID) AS C from " + tableName + " WHERE ROWNUM <=1",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][0];
|
||||
should.strictEqual(typeof resultVal, "number");
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('39.1.6 can get data block number correctly', function(done) {
|
||||
connection.execute(
|
||||
"select dbms_rowid.ROWID_BLOCK_NUMBER(ROWID) AS C from " + tableName + " WHERE ROWNUM <=1",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][0];
|
||||
should.strictEqual(typeof resultVal, "number");
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('39.1.7 can get row number correctly', function(done) {
|
||||
connection.execute(
|
||||
"select dbms_rowid.rowid_row_number(ROWID) AS C from " + tableName + " WHERE ROWNUM <=1",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][0];
|
||||
should.strictEqual(typeof resultVal, "number");
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('39.1.8 works well with REF Cursor', function(done) {
|
||||
verifyRefCursor(connection, tableName, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('39.2 stores null value correctly', function() {
|
||||
it('39.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
});
|
||||
});
|
||||
|
||||
var insertData = function(connection, tableName, callback) {
|
||||
|
||||
async.forEach(array, function(element, cb) {
|
||||
var sql = "INSERT INTO " + tableName + "(num) VALUES(" + element + ")";
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var updateDate = function(connection, tableName, callback) {
|
||||
async.forEach(array, function(element, cb) {
|
||||
var sql = "UPDATE " + tableName + " T SET content = T.ROWID where num = " + element;
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var verifyRefCursor = function(connection, tableName, done) {
|
||||
var createProc =
|
||||
"CREATE OR REPLACE PROCEDURE testproc (p_out OUT SYS_REFCURSOR) " +
|
||||
"AS " +
|
||||
"BEGIN " +
|
||||
" OPEN p_out FOR " +
|
||||
" SELECT * FROM " + tableName + "; " +
|
||||
"END; ";
|
||||
async.series([
|
||||
function createProcedure(callback) {
|
||||
connection.execute(
|
||||
createProc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function verify(callback) {
|
||||
connection.execute(
|
||||
"BEGIN testproc(:o); END;",
|
||||
[
|
||||
{ type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fetchRowsFromRS(result.outBinds[0], callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function dropProcedure(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE testproc",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
};
|
||||
var fetchRowsFromRS = function(rs, cb) {
|
||||
rs.getRows(numRows, function(err, rows) {
|
||||
if(rows.length > 0) {
|
||||
for(var i = 0; i < rows.length; i++) {
|
||||
var resultVal = rows[i].CONTENT;
|
||||
resultVal.should.not.be.null;
|
||||
should.exist(resultVal);
|
||||
}
|
||||
return fetchRowsFromRS(rs, cb);
|
||||
} else {
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -45,77 +45,84 @@ describe('33. dataTypeTimestamp1.js', function() {
|
|||
var tableName = "nodb_timestamp1";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('33.1 Testing JavaScript Date with database TIMESTAMP', function() {
|
||||
var dates = assist.data.dates;
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('33.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('33.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('33.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
}) // end of 33.1 suite
|
||||
}); // end of 33.1 suite
|
||||
|
||||
describe('33.2 stores null value correctly', function() {
|
||||
it('33.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('33.3 testing TIMESTAMP without TIME ZONE', function() {
|
||||
var timestamps = assist.TIMESTAMP_STRINGS;
|
||||
|
||||
before(function(done) {
|
||||
assist.setUp4sql(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
it('32.3.1 SELECT query - original data', function(done) {
|
||||
assist.selectOriginalData(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('33.3.2 SELECT query - formatted data for comparison', function(done) {
|
||||
async.forEach(timestamps, function(timestamp, cb) {
|
||||
|
@ -132,10 +139,10 @@ describe('33. dataTypeTimestamp1.js', function() {
|
|||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('33.3.3 returns scalar types from PL/SQL block', function(done) {
|
||||
var sql = "BEGIN SELECT systimestamp into :bv from dual; END;";
|
||||
|
@ -153,8 +160,8 @@ describe('33. dataTypeTimestamp1.js', function() {
|
|||
}
|
||||
);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
}) // end of 33.3 suite
|
||||
}); // end of 33.3 suite
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -45,77 +45,84 @@ describe('34. dataTypeTimestamp2.js', function() {
|
|||
var tableName = "nodb_timestamp2";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('34.1 Testing JavaScript Date with database TIMESTAMP(p)', function() {
|
||||
var dates = assist.data.dates;
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('34.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('34.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('34.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
}) // end of 34.1 suite
|
||||
}); // end of 34.1 suite
|
||||
|
||||
describe('34.2 sotres null value correctly', function() {
|
||||
it('34.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('34.3 testing database TIMESTAMP(p)', function(done) {
|
||||
describe('34.3 testing database TIMESTAMP(p)', function() {
|
||||
var timestamps = assist.TIMESTAMP_STRINGS;
|
||||
|
||||
before(function(done) {
|
||||
assist.setUp4sql(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
it('34.3.1 SELECT query - original data', function(done) {
|
||||
assist.selectOriginalData(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('34.3.2 SELECT query - formatted data for comparison', function(done) {
|
||||
async.forEach(timestamps, function(timestamp, cb) {
|
||||
|
@ -132,10 +139,10 @@ describe('34. dataTypeTimestamp2.js', function() {
|
|||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
}) // end of 34.3 suite
|
||||
})
|
||||
}); // end of 34.3 suite
|
||||
});
|
||||
|
|
|
@ -39,92 +39,124 @@
|
|||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe.skip('35. dataTypeTimestamp3.js', function() {
|
||||
describe('35. dataTypeTimestamp3.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var tableName = "nodb_datatype_timestamp";
|
||||
var sqlCreate =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
" CREATE TABLE " + tableName +" ( " +
|
||||
" num NUMBER, " +
|
||||
" content TIMESTAMP WITH TIME ZONE " +
|
||||
" )" +
|
||||
" '); " +
|
||||
"END; ";
|
||||
var sqlDrop = "DROP table " + tableName;
|
||||
before( function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
var tableName = "nodb_timestamp3";
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('35.1 Testing JavaScript Date with database TIMESTAMP WITH TIME ZONE', function() {
|
||||
var dates = assist.data.dates;
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
sqlCreate,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
|
||||
after( function(done){
|
||||
connection.execute(
|
||||
sqlDrop,
|
||||
function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
it('35.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
it('supports TIMESTAMP WITH TIME ZONE data type [*** NEW FUNCTIONALITY ***]', function(done) {
|
||||
connection.should.be.ok;
|
||||
it('35.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
var timestamps = [
|
||||
new Date(-100000000),
|
||||
new Date(0),
|
||||
new Date(10000000000),
|
||||
new Date(100000000000)
|
||||
];
|
||||
it('35.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
var sqlInsert = "INSERT INTO " + tableName + " VALUES(:no, :bindValue)";
|
||||
}); // end of 35.1 suite
|
||||
|
||||
async.forEach(timestamps, function(timestamp, callback) {
|
||||
describe('35.2 stores null value correctly', function() {
|
||||
it('35.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('35.3 testing TIMESTAMP WITH TIME ZONE', function() {
|
||||
var timestamps = assist.TIMESTAMP_TZ_STRINGS_1;
|
||||
|
||||
before(function(done) {
|
||||
assist.setUp4sql(connection, tableName, timestamps, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
sqlInsert,
|
||||
{ no: timestamps.indexOf(timestamp), bindValue: timestamp },
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
}); // after
|
||||
|
||||
it('32.3.1 SELECT query - original data', function(done) {
|
||||
assist.selectOriginalData(connection, tableName, timestamps, done);
|
||||
});
|
||||
|
||||
it('35.3.2 SELECT query - formatted data for comparison', function(done) {
|
||||
async.forEach(timestamps, function(timestamp, cb) {
|
||||
var bv = timestamps.indexOf(timestamp);
|
||||
connection.execute(
|
||||
"SELECT num, TO_CHAR(content, 'DD-MM-YYYY HH24:MI:SS.FF TZH:TZM') AS TS_DATA FROM " + tableName + " WHERE num = :no",
|
||||
{ no: bv },
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rows[0].TS_DATA).should.equal(assist.content.timestamps3[bv]);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('35.3.3 returns scalar types from PL/SQL block', function(done) {
|
||||
var sql = "BEGIN SELECT systimestamp into :bv from dual; END;";
|
||||
var binds = { bv: { dir: oracledb.BIND_OUT, type: oracledb.STRING } };
|
||||
var options = { outFormat: oracledb.OBJECT };
|
||||
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
sql,
|
||||
binds,
|
||||
options,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.outBinds.bv).should.be.a.String();
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -39,94 +39,124 @@
|
|||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('36. dataTypeTimestamp4.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var tableName = "nodb_datatype_timestamp";
|
||||
var sqlCreate =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
" CREATE TABLE " + tableName +" ( " +
|
||||
" num NUMBER, " +
|
||||
" content TIMESTAMP(2) WITH TIME ZONE " +
|
||||
" )" +
|
||||
" '); " +
|
||||
"END; ";
|
||||
var sqlDrop = "DROP table " + tableName;
|
||||
before( function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
var tableName = "nodb_timestamp4";
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('36.1 Testing JavaScript Date with database TIMESTAMP (4) WITH TIME ZONE', function() {
|
||||
var dates = assist.data.dates;
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
sqlCreate,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
|
||||
after( function(done){
|
||||
connection.execute(
|
||||
sqlDrop,
|
||||
function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
it('36.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
it('supports TIMESTAMP WITH TIME ZONE data type', function(done) {
|
||||
connection.should.be.ok;
|
||||
it('36.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
var timestamps = [
|
||||
new Date(-100000000),
|
||||
new Date(0),
|
||||
new Date(10000000000),
|
||||
new Date(100000000000)
|
||||
];
|
||||
it('36.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, dates, done);
|
||||
});
|
||||
|
||||
var sqlInsert = "INSERT INTO " + tableName + " VALUES(:no, :bindValue)";
|
||||
}); // end of 36.1 suite
|
||||
|
||||
async.forEach(timestamps, function(timestamp, callback) {
|
||||
describe('36.2 stores null value correctly', function() {
|
||||
it('36.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('36.3 testing TIMESTAMP (4) WITH TIME ZONE', function() {
|
||||
var timestamps = assist.TIMESTAMP_TZ_STRINGS_1;
|
||||
|
||||
before(function(done) {
|
||||
assist.setUp4sql(connection, tableName, timestamps, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
sqlInsert,
|
||||
{ no: timestamps.indexOf(timestamp), bindValue: timestamp },
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
done();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
}); // after
|
||||
|
||||
it('32.3.1 SELECT query - original data', function(done) {
|
||||
assist.selectOriginalData(connection, tableName, timestamps, done);
|
||||
});
|
||||
|
||||
it('36.3.2 SELECT query - formatted data for comparison', function(done) {
|
||||
async.forEach(timestamps, function(timestamp, cb) {
|
||||
var bv = timestamps.indexOf(timestamp);
|
||||
connection.execute(
|
||||
"SELECT num, TO_CHAR(content, 'DD-MM-YYYY HH24:MI:SS.FF TZH:TZM') AS TS_DATA FROM " + tableName + " WHERE num = :no",
|
||||
{ no: bv },
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rows[0].TS_DATA).should.equal(assist.content.timestamps4[bv]);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('36.3.3 returns scalar types from PL/SQL block', function(done) {
|
||||
var sql = "BEGIN SELECT systimestamp into :bv from dual; END;";
|
||||
var binds = { bv: { dir: oracledb.BIND_OUT, type: oracledb.STRING } };
|
||||
var options = { outFormat: oracledb.OBJECT };
|
||||
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
sql,
|
||||
binds,
|
||||
options,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
for(var j = 0; j < timestamps.length; j++)
|
||||
result.rows[j].CONTENT.toUTCString().should.eql(timestamps[result.rows[j].NUM].toUTCString());
|
||||
(result.outBinds.bv).should.be.a.String();
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -45,77 +45,84 @@ describe('37. dataTypeTimestamp5.js', function() {
|
|||
var tableName = "nodb_timestamp5";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('37.1 Testing JavaScript Date with database TIMESTAMP WITH LOCAL TIME ZONE', function() {
|
||||
var dates = assist.data.dates;
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('37.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('37.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('37.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
}) // end of 37.1 suite
|
||||
}); // end of 37.1 suite
|
||||
|
||||
describe('37.2 stores null value correctly', function() {
|
||||
it('37.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('37.3 testing TIMESTAMP WITH LOCAL TIME ZONE', function() {
|
||||
var timestamps = assist.TIMESTAMP_TZ_STRINGS;
|
||||
var timestamps = assist.TIMESTAMP_TZ_STRINGS_2;
|
||||
|
||||
before(function(done) {
|
||||
assist.setUp4sql(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
it('37.3.1 SELECT query - original data', function(done) {
|
||||
assist.selectOriginalData(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('37.3.2 SELECT query - formatted data for comparison', function(done) {
|
||||
var sql = "SELECT num, TO_CHAR(content AT TIME ZONE '-8:00', 'DD-MM-YYYY HH24:MI:SS.FF TZR') AS TS_DATA FROM "
|
||||
|
@ -137,10 +144,10 @@ describe('37. dataTypeTimestamp5.js', function() {
|
|||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
}) // end of 37.3 suite
|
||||
});
|
||||
}); // end of 37.3 suite
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -48,77 +48,84 @@ describe('38. dataTypeTimestamp6.js', function() {
|
|||
var tableName = "nodb_timestamp6";
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('38.1 Testing JavaScript Date with database TIMESTAMP(9) WITH LOCAL TIME ZONE', function() {
|
||||
var dates = assist.data.dates;
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('38.1.1 works well with SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('38.1.2 works well with result set', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('38.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, dates, done);
|
||||
})
|
||||
});
|
||||
|
||||
}) // end of 37.1 suite
|
||||
}); // end of 37.1 suite
|
||||
|
||||
describe('38.2 stores null value correctly', function() {
|
||||
it('38.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('38.3 testing TIMESTAMP WITH LOCAL TIME ZONE', function() {
|
||||
var timestamps = assist.TIMESTAMP_TZ_STRINGS;
|
||||
var timestamps = assist.TIMESTAMP_TZ_STRINGS_2;
|
||||
|
||||
before(function(done) {
|
||||
assist.setUp4sql(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
it('38.3.1 SELECT query - original data', function(done) {
|
||||
assist.selectOriginalData(connection, tableName, timestamps, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('38.3.2 SELECT query - formatted data for comparison', function(done) {
|
||||
var sql = "SELECT num, TO_CHAR(content AT TIME ZONE '-8:00', 'DD-MM-YYYY HH24:MI:SS.FF TZR') AS TS_DATA FROM "
|
||||
|
@ -140,9 +147,9 @@ describe('38. dataTypeTimestamp6.js', function() {
|
|||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
}) // end of 38.3 suite
|
||||
})
|
||||
});
|
||||
}); // end of 38.3 suite
|
||||
});
|
||||
|
|
|
@ -49,53 +49,60 @@ describe('24. dataTypeVarchar2.js', function() {
|
|||
strs[i] = assist.createCharString(strLen[i]);
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('24.1 testing VARCHAR2 data in various lengths', function() {
|
||||
|
||||
before('create table, insert data',function(done) {
|
||||
assist.setUp(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('24.1.1 SELECT query', function(done) {
|
||||
assist.dataTypeSupport(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('24.1.2 resultSet stores VARCHAR2 data correctly', function(done) {
|
||||
assist.verifyResultSet(connection, tableName, strs, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('24.1.3 works well with REF Cursor', function(done) {
|
||||
assist.verifyRefCursor(connection, tableName, strs, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('24.2 stores null value correctly', function() {
|
||||
it('24.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -33,6 +33,5 @@
|
|||
module.exports = {
|
||||
user : process.env.NODE_ORACLEDB_USER || "hr",
|
||||
password : process.env.NODE_ORACLEDB_PASSWORD || "welcome",
|
||||
connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost/orcl",
|
||||
externalAuth : process.env.NODE_ORACLEDB_EXTERNALAUTH ? true : false
|
||||
connectString : process.env.NODE_ORACLEDB_CONNECTIONSTRING || "localhost/orcl"
|
||||
};
|
||||
|
|
|
@ -53,12 +53,12 @@ describe('6. dmlReturning.js', function(){
|
|||
var makeTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_dmlreturn'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_dmlreturn PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
|
@ -83,22 +83,29 @@ describe('6. dmlReturning.js', function(){
|
|||
(2001, ''Karen Morton'') \
|
||||
'); \
|
||||
END; ";
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
conn.execute(
|
||||
makeTable,
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
conn.execute(
|
||||
makeTable,
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
afterEach('drop table and release connection', function(done) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_dmlreturn",
|
||||
"DROP TABLE nodb_dmlreturn PURGE",
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err){
|
||||
|
@ -107,10 +114,10 @@ describe('6. dmlReturning.js', function(){
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.1 INSERT statement with Object binding', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dmlreturn VALUES (1003, 'Robyn Sands') RETURNING id, name INTO :rid, :rname",
|
||||
{
|
||||
|
@ -126,10 +133,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.2 INSERT statement with Array binding', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dmlreturn VALUES (1003, 'Robyn Sands') RETURNING id, name INTO :rid, :rname",
|
||||
[
|
||||
|
@ -145,11 +152,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
// it currently fails on OS X
|
||||
it.skip('6.1.3 INSERT statement with small maxSize restriction', function(done) {
|
||||
connection.should.be.ok;
|
||||
it('6.1.3 INSERT statement with small maxSize restriction', function(done) {
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dmlreturn VALUES (1003, 'Robyn Sands Delaware') RETURNING id, name INTO :rid, :rname",
|
||||
{
|
||||
|
@ -159,16 +165,18 @@ describe('6. dmlReturning.js', function(){
|
|||
{ autoCommit: true },
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
err.message.should.startWith('NJS-016:');
|
||||
// NJS-016: buffer is too small for OUT binds
|
||||
//console.log(result);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
"NJS-016: buffer is too small for OUT binds"
|
||||
);
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.4 UPDATE statement with single row matched', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"UPDATE nodb_dmlreturn SET name = :n WHERE id = :i RETURNING id, name INTO :rid, :rname",
|
||||
{
|
||||
|
@ -187,10 +195,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.5 UPDATE statement with single row matched & Array binding', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"UPDATE nodb_dmlreturn SET name = :n WHERE id = :i RETURNING id, name INTO :rid, :rname",
|
||||
[
|
||||
|
@ -209,10 +217,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.6 UPDATE statements with multiple rows matched', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"UPDATE nodb_dmlreturn SET id = :i RETURNING id, name INTO :rid, :rname",
|
||||
{
|
||||
|
@ -230,10 +238,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.7 UPDATE statements with multiple rows matched & Array binding', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"UPDATE nodb_dmlreturn SET id = :i RETURNING id, name INTO :rid, :rname",
|
||||
[
|
||||
|
@ -251,10 +259,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.8 DELETE statement with Object binding', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"DELETE FROM nodb_dmlreturn WHERE name like '%Chris%' RETURNING id, name INTO :rid, :rname",
|
||||
{
|
||||
|
@ -271,10 +279,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.9 DELETE statement with Array binding', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"DELETE FROM nodb_dmlreturn WHERE name like '%Chris%' RETURNING id, name INTO :rid, :rname",
|
||||
[
|
||||
|
@ -291,7 +299,7 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
// it currently fails with 11.2 database
|
||||
it('6.1.10 Stress test - support 4k varchars', function(done){
|
||||
|
@ -303,7 +311,7 @@ describe('6. dmlReturning.js', function(){
|
|||
buffer.append('A');
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
};
|
||||
|
||||
var StringBuffer = function() {
|
||||
this.buffer = [];
|
||||
|
@ -324,7 +332,7 @@ describe('6. dmlReturning.js', function(){
|
|||
/*** string length **/
|
||||
var size = 4000;
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_dmlreturn VALUES (:i, :n) RETURNING id, name INTO :rid, :rname",
|
||||
{
|
||||
|
@ -342,10 +350,10 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.11 Negative test - wrong SQL got correct error thrown', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
var wrongSQL = "UPDATE nodb_dmlreturn SET doesnotexist = 'X' WHERE id = :id RETURNING name INTO :rn";
|
||||
|
||||
connection.execute(
|
||||
|
@ -362,7 +370,7 @@ describe('6. dmlReturning.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.1.12 Negative test - data type is not supported with DML Returning statments', function(done) {
|
||||
var sql = "UPDATE nodb_dmlreturn SET name = 'Leslie Lin' WHERE id = :id RETURNING name INTO :rn ";
|
||||
|
@ -376,12 +384,14 @@ describe('6. dmlReturning.js', function(){
|
|||
should.exist(err);
|
||||
// NJS-028: raw database type is not supported with DML Returning statements
|
||||
(err.message).should.startWith('NJS-028:');
|
||||
|
||||
should.not.exist(result);
|
||||
done();
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
}) // 6.1
|
||||
}); // 6.1
|
||||
|
||||
describe('6.2 DATE and TIMESTAMP data', function() {
|
||||
|
||||
|
@ -392,23 +402,30 @@ describe('6. dmlReturning.js', function(){
|
|||
beforeEach('get connection, prepare table', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
assist.setUp4sql(connection, tableName, dates, callback);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
afterEach('drop table, release connection', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -422,7 +439,7 @@ describe('6. dmlReturning.js', function(){
|
|||
});
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
function runSQL(sql, bindVar, isSingleMatch, callback)
|
||||
{
|
||||
|
@ -451,14 +468,16 @@ describe('6. dmlReturning.js', function(){
|
|||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.2 INSERT statement with JavaScript date bind in ', function(done) {
|
||||
var sql = "INSERT INTO " + tableName + " VALUES (:no, :c) RETURNING num, content INTO :rnum, :rcontent";
|
||||
var ndate = new Date(2003, 9, 23, 11, 50, 30, 12);
|
||||
|
||||
var bindVar =
|
||||
{
|
||||
no: 51,
|
||||
c: new Date(2003, 09, 23, 11, 50, 30, 123),
|
||||
c: ndate,
|
||||
rnum: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
rcontent: { type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
|
@ -466,7 +485,7 @@ describe('6. dmlReturning.js', function(){
|
|||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.3 INSERT statement with Array binding', function(done) {
|
||||
var sql = "INSERT INTO " + tableName + " VALUES (50, TO_TIMESTAMP_TZ('1999-12-01 11:00:00.123456 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')) RETURNING num, content INTO :rnum, :rcontent";
|
||||
|
@ -479,13 +498,13 @@ describe('6. dmlReturning.js', function(){
|
|||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.4 UPDATE statement with single row matched', function(done) {
|
||||
var sql = "UPDATE " + tableName + " SET content = :c WHERE num = :n RETURNING num, content INTO :rnum, :rcontent";
|
||||
var bindVar =
|
||||
{
|
||||
c: { type: oracledb.DATE, dir: oracledb.BIND_IN, val: new Date(2003, 09, 23, 11, 50, 30, 123) },
|
||||
c: { type: oracledb.DATE, dir: oracledb.BIND_IN, val: new Date(2003, 9, 23, 11, 50, 30, 123) },
|
||||
n: 0,
|
||||
rnum: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
rcontent: { type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
|
@ -494,13 +513,13 @@ describe('6. dmlReturning.js', function(){
|
|||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.5 UPDATE statements with multiple rows matched, ARRAY binding format', function(done) {
|
||||
var sql = "UPDATE " + tableName + " SET content = :c WHERE num < :n RETURNING num, content INTO :rnum, :rcontent";
|
||||
var bindVar =
|
||||
[
|
||||
{ type: oracledb.DATE, dir: oracledb.BIND_IN, val: new Date(2003, 09, 23, 11, 50, 30, 123) },
|
||||
{ type: oracledb.DATE, dir: oracledb.BIND_IN, val: new Date(2003, 9, 23, 11, 50, 30, 123) },
|
||||
100,
|
||||
{ type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
{ type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
|
@ -509,7 +528,7 @@ describe('6. dmlReturning.js', function(){
|
|||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.6 UPDATE statements, multiple rows, TIMESTAMP data', function(done) {
|
||||
var sql = "UPDATE " + tableName + " SET content = TO_TIMESTAMP_TZ('1999-12-01 11:00:00.123456 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM') " +
|
||||
|
@ -519,12 +538,12 @@ describe('6. dmlReturning.js', function(){
|
|||
n: 100,
|
||||
rnum: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
rcontent: { type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
}
|
||||
};
|
||||
var isSingleMatch = false;
|
||||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.7 DELETE statement, single row matched, Object binding format', function(done) {
|
||||
var sql = "DELETE FROM " + tableName + " WHERE num = :n RETURNING num, content INTO :rnum, :rcontent";
|
||||
|
@ -538,7 +557,7 @@ describe('6. dmlReturning.js', function(){
|
|||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.8 DELETE statement, multiple rows matched, Array binding format', function(done) {
|
||||
var sql = "DELETE FROM " + tableName + " WHERE num >= :n RETURNING num, content INTO :rnum, :rcontent";
|
||||
|
@ -551,14 +570,14 @@ describe('6. dmlReturning.js', function(){
|
|||
var isSingleMatch = false;
|
||||
|
||||
runSQL(sql, bindVar, isSingleMatch, done);
|
||||
})
|
||||
});
|
||||
|
||||
it('6.2.9 Negative test - bind value and type mismatch', function(done) {
|
||||
var wrongSQL = "UPDATE " + tableName + " SET content = :c WHERE num = :n RETURNING num, content INTO :rnum, :rcontent";
|
||||
var bindVar =
|
||||
{
|
||||
n: 0,
|
||||
c: { type: oracledb.STRING, dir: oracledb.BIND_IN, val: new Date(2003, 09, 23, 11, 50, 30, 123) },
|
||||
c: { type: oracledb.STRING, dir: oracledb.BIND_IN, val: new Date(2003, 9, 23, 11, 50, 30, 123) },
|
||||
rnum: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
rcontent: { type: oracledb.DATE, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
|
@ -571,11 +590,13 @@ describe('6. dmlReturning.js', function(){
|
|||
// console.log(err.message);
|
||||
// NJS-011: encountered bind value and type mismatch
|
||||
(err.message).should.startWith('NJS-011:');
|
||||
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
}) // 6.2
|
||||
})
|
||||
}); // 6.2
|
||||
});
|
||||
|
|
344
test/examples.js
344
test/examples.js
|
@ -40,18 +40,24 @@ var dbConfig = require('./dbconfig.js');
|
|||
|
||||
describe('3. examples.js', function(){
|
||||
|
||||
var credentials = {
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
};
|
||||
|
||||
describe('3.1 connect.js', function(){
|
||||
it('3.1.1 tests a basic connection to the database', function(done){
|
||||
oracledb.getConnection(dbConfig, function(error, connection){
|
||||
oracledb.getConnection(credentials, function(error, connection){
|
||||
should.not.exist(error);
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.release( function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('3.2 version.js', function(){
|
||||
it('3.2.1 shows the oracledb version attribute', function(){
|
||||
|
@ -62,55 +68,59 @@ describe('3. examples.js', function(){
|
|||
var major = Math.floor(oracledb.version/10000);
|
||||
var minor = Math.floor(oracledb.version/100) % 100;
|
||||
var patch = oracledb.version % 100;
|
||||
|
||||
(major).should.be.a.Number();
|
||||
(minor).should.be.a.Number();
|
||||
(patch).should.be.a.Number();
|
||||
// console.log("Driver version text is " + major + "." + minor + "." + patch);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('3.3 select1.js & select2.js', function(){
|
||||
var connection = false;
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
oracledb.getConnection(credentials, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
if(connection){
|
||||
connection.release( function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('3.3.1. execute a basic query', function(done){
|
||||
var script1 =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_departments'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_eg_dept PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_departments ( \
|
||||
CREATE TABLE nodb_eg_dept ( \
|
||||
department_id NUMBER, \
|
||||
department_name VARCHAR2(20) \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_eg_dept \
|
||||
(department_id, department_name) VALUES \
|
||||
(40,''Human Resources'') \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_eg_dept \
|
||||
(department_id, department_name) VALUES \
|
||||
(180, ''Construction'') \
|
||||
'); \
|
||||
|
@ -126,30 +136,30 @@ describe('3. examples.js', function(){
|
|||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT department_id, department_name "
|
||||
+ "FROM nodb_departments "
|
||||
+ "FROM nodb_eg_dept "
|
||||
+ "WHERE department_id = :did",
|
||||
[180],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rows).should.eql([[ 180, 'Construction' ]]);
|
||||
callback();
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('3.3.2. execute queries to show array and object formats', function(done){
|
||||
var script2 =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_locations'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_locations PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
|
@ -218,28 +228,28 @@ describe('3. examples.js', function(){
|
|||
}
|
||||
], done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
/* Oracle Database 12.1.0.2 has extensive JSON datatype support */
|
||||
describe('3.4 selectjson.js - 12.1.0.2 feature', function(){
|
||||
var connection = false;
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.release( function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('3.4.1 executes a query from a JSON table', function(done){
|
||||
if (connection.oracleServerVersion < 1201000200)
|
||||
|
@ -254,12 +264,12 @@ describe('3. examples.js', function(){
|
|||
var script =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" e_table_missing EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_purchaseorder'); " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_purchaseorder PURGE'); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" WHEN e_table_missing " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
|
@ -269,7 +279,7 @@ describe('3. examples.js', function(){
|
|||
" '); " +
|
||||
"END; ";
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
async.series([
|
||||
function(callback){
|
||||
connection.execute(
|
||||
|
@ -307,7 +317,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_purchaseorder",
|
||||
"DROP TABLE nodb_purchaseorder PURGE",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -318,25 +328,25 @@ describe('3. examples.js', function(){
|
|||
|
||||
} // else
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('3.5 date.js', function(){
|
||||
var connection = false;
|
||||
var script =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" e_table_missing EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_testdate'); " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_eg_testdate PURGE'); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" WHEN e_table_missing " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
" CREATE TABLE nodb_testdate ( " +
|
||||
" CREATE TABLE nodb_eg_testdate ( " +
|
||||
" timestampcol TIMESTAMP, " +
|
||||
" datecol DATE " +
|
||||
" )" +
|
||||
|
@ -346,19 +356,19 @@ describe('3. examples.js', function(){
|
|||
var date = new Date();
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.release( function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('3.5.1 inserts and query DATE and TIMESTAMP columns', function(done){
|
||||
async.series([
|
||||
|
@ -373,7 +383,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){ // insert data
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_testdate (timestampcol, datecol) VALUES (:ts, :td)",
|
||||
"INSERT INTO nodb_eg_testdate (timestampcol, datecol) VALUES (:ts, :td)",
|
||||
{ ts: date, td: date },
|
||||
{ autoCommit: false },
|
||||
function(err){
|
||||
|
@ -384,7 +394,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){ // select data
|
||||
connection.execute(
|
||||
"SELECT timestampcol, datecol FROM nodb_testdate",
|
||||
"SELECT timestampcol, datecol FROM nodb_eg_testdate",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
var ts = result.rows[0][0];
|
||||
|
@ -406,7 +416,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_testdate",
|
||||
"DROP TABLE nodb_eg_testdate PURGE",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -414,9 +424,9 @@ describe('3. examples.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('3.6 rowlimit.js', function(){
|
||||
var connection = false;
|
||||
|
@ -424,16 +434,16 @@ describe('3. examples.js', function(){
|
|||
var createTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_eg_emp6 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_employees ( \
|
||||
CREATE TABLE nodb_eg_emp6 ( \
|
||||
employees_id NUMBER, \
|
||||
employees_name VARCHAR2(20) \
|
||||
) \
|
||||
|
@ -448,12 +458,12 @@ describe('3. examples.js', function(){
|
|||
FOR i IN 1..107 LOOP \
|
||||
x := x + 1; \
|
||||
n := 'staff ' || x; \
|
||||
INSERT INTO nodb_employees VALUES (x, n); \
|
||||
INSERT INTO nodb_eg_emp6 VALUES (x, n); \
|
||||
END LOOP; \
|
||||
END; ";
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
connection.execute(createTable, function(err){
|
||||
|
@ -464,11 +474,11 @@ describe('3. examples.js', function(){
|
|||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.execute(
|
||||
'DROP TABLE nodb_employees',
|
||||
'DROP TABLE nodb_eg_emp6 PURGE',
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err){
|
||||
|
@ -477,15 +487,15 @@ describe('3. examples.js', function(){
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('3.6.1 by default, the number is 100', function(done){
|
||||
var defaultLimit = oracledb.maxRows;
|
||||
defaultLimit.should.be.exactly(100);
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employees_id",
|
||||
"SELECT * FROM nodb_eg_emp6 ORDER BY employees_id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
|
@ -494,12 +504,12 @@ describe('3. examples.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('3.6.2 can also specify for each execution', function(done){
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employees_id",
|
||||
"SELECT * FROM nodb_eg_emp6 ORDER BY employees_id",
|
||||
{}, {maxRows: 25},
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -509,31 +519,31 @@ describe('3. examples.js', function(){
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('3.7 plsql.js', function(){
|
||||
var connection = false;
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.release( function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('3.7.1 can call PL/SQL procedure and binding parameters in various ways', function(done){
|
||||
var proc =
|
||||
"CREATE OR REPLACE PROCEDURE nodb_testproc (p_in IN VARCHAR2, p_inout IN OUT VARCHAR2, p_out OUT NUMBER) \
|
||||
"CREATE OR REPLACE PROCEDURE nodb_eg_proc7 (p_in IN VARCHAR2, p_inout IN OUT VARCHAR2, p_out OUT NUMBER) \
|
||||
AS \
|
||||
BEGIN \
|
||||
p_inout := p_in || p_inout; \
|
||||
|
@ -543,7 +553,7 @@ describe('3. examples.js', function(){
|
|||
i: 'Chris', // bind type is determined from the data type
|
||||
io: { val: 'Jones', dir : oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.NUMBER, dir : oracledb.BIND_OUT }
|
||||
}
|
||||
};
|
||||
|
||||
async.series([
|
||||
function(callback){
|
||||
|
@ -557,7 +567,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"BEGIN nodb_testproc(:i, :io, :o); END;",
|
||||
"BEGIN nodb_eg_proc7(:i, :io, :o); END;",
|
||||
bindVars,
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -569,19 +579,19 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_testproc",
|
||||
function(err, result){
|
||||
"DROP PROCEDURE nodb_eg_proc7",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('3.7.2 can call PL/SQL function', function(done) {
|
||||
var proc =
|
||||
"CREATE OR REPLACE FUNCTION nodb_testfunc (p1_in IN VARCHAR2, p2_in IN VARCHAR2) RETURN VARCHAR2 \
|
||||
"CREATE OR REPLACE FUNCTION nodb_eg_func7 (p1_in IN VARCHAR2, p2_in IN VARCHAR2) RETURN VARCHAR2 \
|
||||
AS \
|
||||
BEGIN \
|
||||
return p1_in || p2_in; \
|
||||
|
@ -604,7 +614,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"BEGIN :ret := nodb_testfunc(:p1, :p2); END;",
|
||||
"BEGIN :ret := nodb_eg_func7(:p1, :p2); END;",
|
||||
bindVars,
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -616,33 +626,33 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"DROP FUNCTION nodb_testfunc",
|
||||
function(err, result){
|
||||
"DROP FUNCTION nodb_eg_func7",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('3.8 insert1.js', function(){
|
||||
var connection = false;
|
||||
var script =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" e_table_missing EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_testinsert'); " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_eg_insert8 PURGE'); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" WHEN e_table_missing " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
" CREATE TABLE nodb_testinsert ( " +
|
||||
" CREATE TABLE nodb_eg_insert8 ( " +
|
||||
" id NUMBER, " +
|
||||
" name VARCHAR2(20) " +
|
||||
" )" +
|
||||
|
@ -650,19 +660,19 @@ describe('3. examples.js', function(){
|
|||
"END; ";
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.release( function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('3.8.1 creates a table and inserts data', function(done){
|
||||
async.series([
|
||||
|
@ -677,7 +687,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_testinsert VALUES (:id, :nm)",
|
||||
"INSERT INTO nodb_eg_insert8 VALUES (:id, :nm)",
|
||||
[1, 'Chris'], // Bind values
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -688,7 +698,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_testinsert VALUES (:id, :nm)",
|
||||
"INSERT INTO nodb_eg_insert8 VALUES (:id, :nm)",
|
||||
[2, 'Alison'], // Bind values
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
|
@ -699,7 +709,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"UPDATE nodb_testinsert SET name = 'Bambi'",
|
||||
"UPDATE nodb_eg_insert8 SET name = 'Bambi'",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(2);
|
||||
|
@ -709,7 +719,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_testinsert",
|
||||
"DROP TABLE nodb_eg_insert8 PURGE",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -717,8 +727,8 @@ describe('3. examples.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('3.9 insert2.js', function(){
|
||||
var conn1 = false;
|
||||
|
@ -726,16 +736,16 @@ describe('3. examples.js', function(){
|
|||
var script =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" e_table_missing EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_testcommit'); " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_eg_commit9 PURGE'); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" WHEN e_table_missing " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
" CREATE TABLE nodb_testcommit ( " +
|
||||
" CREATE TABLE nodb_eg_commit9 ( " +
|
||||
" id NUMBER, " +
|
||||
" name VARCHAR2(20) " +
|
||||
" )" +
|
||||
|
@ -743,16 +753,16 @@ describe('3. examples.js', function(){
|
|||
"END; ";
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
conn1 = conn;
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
conn2 = conn;
|
||||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
conn1.release( function(err){
|
||||
|
@ -762,7 +772,7 @@ describe('3. examples.js', function(){
|
|||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('3.9.1 tests the auto commit behavior', function(done){
|
||||
async.series([
|
||||
|
@ -777,7 +787,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
conn1.execute(
|
||||
"INSERT INTO nodb_testcommit VALUES (:id, :nm)",
|
||||
"INSERT INTO nodb_eg_commit9 VALUES (:id, :nm)",
|
||||
[1, 'Chris'], // Bind values
|
||||
{ autoCommit: true },
|
||||
function(err, result){
|
||||
|
@ -789,7 +799,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
conn1.execute(
|
||||
"INSERT INTO nodb_testcommit VALUES (:id, :nm)",
|
||||
"INSERT INTO nodb_eg_commit9 VALUES (:id, :nm)",
|
||||
[2, 'Alison'], // Bind values
|
||||
// { autoCommit: true },
|
||||
function(err, result){
|
||||
|
@ -801,7 +811,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
conn2.execute(
|
||||
"SELECT * FROM nodb_testcommit ORDER BY id",
|
||||
"SELECT * FROM nodb_eg_commit9 ORDER BY id",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
// This will only show 'Chris' because inserting 'Alison' is not commited by default.
|
||||
|
@ -814,7 +824,7 @@ describe('3. examples.js', function(){
|
|||
},
|
||||
function(callback){
|
||||
conn1.execute(
|
||||
"DROP TABLE nodb_testcommit",
|
||||
"DROP TABLE nodb_eg_commit9 PURGE",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -823,8 +833,8 @@ describe('3. examples.js', function(){
|
|||
}
|
||||
], done);
|
||||
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe('3.10 resultset.js', function() {
|
||||
var connection = false;
|
||||
|
@ -832,16 +842,16 @@ describe('3. examples.js', function(){
|
|||
var createTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_eg_emp10 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_employees ( \
|
||||
CREATE TABLE nodb_eg_emp10 ( \
|
||||
employees_id NUMBER, \
|
||||
employees_name VARCHAR2(20) \
|
||||
) \
|
||||
|
@ -856,12 +866,12 @@ describe('3. examples.js', function(){
|
|||
FOR i IN 1..207 LOOP \
|
||||
x := x + 1; \
|
||||
n := 'staff ' || x; \
|
||||
INSERT INTO nodb_employees VALUES (x, n); \
|
||||
INSERT INTO nodb_eg_emp10 VALUES (x, n); \
|
||||
END LOOP; \
|
||||
END; ";
|
||||
|
||||
before(function(done){
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
oracledb.getConnection(credentials, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
connection.execute(createTable, function(err){
|
||||
|
@ -872,11 +882,11 @@ describe('3. examples.js', function(){
|
|||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.execute(
|
||||
'DROP TABLE nodb_employees',
|
||||
'DROP TABLE nodb_eg_emp10 PURGE',
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err){
|
||||
|
@ -885,14 +895,14 @@ describe('3. examples.js', function(){
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('3.10.1 resultset1.js - getRow() function', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
var rowCount = 1;
|
||||
|
||||
connection.execute(
|
||||
"SELECT employees_name FROM nodb_employees",
|
||||
"SELECT employees_name FROM nodb_eg_emp10",
|
||||
[],
|
||||
{ resultSet: true, prefetchRows: 50 },
|
||||
function(err, result) {
|
||||
|
@ -919,14 +929,14 @@ describe('3. examples.js', function(){
|
|||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('3.10.2 resultset2.js - getRows() function', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
var numRows = 10; // number of rows to return from each call to getRows()
|
||||
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_employees ORDER BY employees_id",
|
||||
"SELECT * FROM nodb_eg_emp10 ORDER BY employees_id",
|
||||
[],
|
||||
{ resultSet: true, prefetchRows: 110 },
|
||||
function(err, result) {
|
||||
|
@ -954,68 +964,68 @@ describe('3. examples.js', function(){
|
|||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('3.11 refcursor.js', function() {
|
||||
var connection = false;
|
||||
var script =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_eg_emp11 PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_employees ( \
|
||||
CREATE TABLE nodb_eg_emp11 ( \
|
||||
name VARCHAR2(40), \
|
||||
salary NUMBER, \
|
||||
hire_date DATE \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_eg_emp11 \
|
||||
(name, salary, hire_date) VALUES \
|
||||
(''Steven'',24000, TO_DATE(''20030617'', ''yyyymmdd'')) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_eg_emp11 \
|
||||
(name, salary, hire_date) VALUES \
|
||||
(''Neena'',17000, TO_DATE(''20050921'', ''yyyymmdd'')) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_eg_emp11 \
|
||||
(name, salary, hire_date) VALUES \
|
||||
(''Lex'',17000, TO_DATE(''20010112'', ''yyyymmdd'')) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_eg_emp11 \
|
||||
(name, salary, hire_date) VALUES \
|
||||
(''Nancy'',12008, TO_DATE(''20020817'', ''yyyymmdd'')) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_eg_emp11 \
|
||||
(name, salary, hire_date) VALUES \
|
||||
(''Karen'',14000, TO_DATE(''20050104'', ''yyyymmdd'')) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_employees \
|
||||
INSERT INTO nodb_eg_emp11 \
|
||||
(name, salary, hire_date) VALUES \
|
||||
(''Peter'',9000, TO_DATE(''20100525'', ''yyyymmdd'')) \
|
||||
'); \
|
||||
END; ";
|
||||
|
||||
var proc =
|
||||
"CREATE OR REPLACE PROCEDURE get_emp_rs (p_sal IN NUMBER, p_recordset OUT SYS_REFCURSOR) \
|
||||
"CREATE OR REPLACE PROCEDURE get_emp_rs11 (p_sal IN NUMBER, p_recordset OUT SYS_REFCURSOR) \
|
||||
AS \
|
||||
BEGIN \
|
||||
OPEN p_recordset FOR \
|
||||
SELECT * FROM nodb_employees\
|
||||
SELECT * FROM nodb_eg_emp11\
|
||||
WHERE salary > p_sal; \
|
||||
END; ";
|
||||
|
||||
|
@ -1023,7 +1033,7 @@ describe('3. examples.js', function(){
|
|||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
credentials,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
|
@ -1050,27 +1060,45 @@ describe('3. examples.js', function(){
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done){
|
||||
connection.execute(
|
||||
'DROP TABLE nodb_employees',
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE get_emp_rs11",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
'DROP TABLE nodb_eg_emp11 PURGE',
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
], done);
|
||||
|
||||
}); // after
|
||||
|
||||
it('3.11.1 REF CURSOR', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
var numRows = 100; // number of rows to return from each call to getRows()
|
||||
|
||||
connection.execute(
|
||||
"BEGIN get_emp_rs(:sal, :cursor); END;",
|
||||
"BEGIN get_emp_rs11(:sal, :cursor); END;",
|
||||
{
|
||||
sal: 12000,
|
||||
cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
|
@ -1103,7 +1131,7 @@ describe('3. examples.js', function(){
|
|||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -45,11 +45,18 @@ describe('17. extendedMetaData.js', function() {
|
|||
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
|
@ -57,7 +64,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_md'); \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_md PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
|
@ -102,7 +109,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_md",
|
||||
"DROP TABLE nodb_md PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
|
@ -436,7 +443,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_metadata'); \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_metadata PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
|
@ -496,7 +503,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_metadata",
|
||||
"DROP TABLE nodb_metadata PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
|
@ -514,10 +521,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'VCH',
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_VARCHAR,
|
||||
byteSize: 4000,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_VARCHAR,
|
||||
byteSize: 4000,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -535,10 +542,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NVCH',
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_VARCHAR,
|
||||
byteSize: 4000,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_VARCHAR,
|
||||
byteSize: 4000,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -556,10 +563,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'CH',
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_CHAR,
|
||||
byteSize: 2000,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_CHAR,
|
||||
byteSize: 2000,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -577,10 +584,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'CH',
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_CHAR,
|
||||
byteSize: 2000,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_CHAR,
|
||||
byteSize: 2000,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -598,11 +605,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NUM1',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 0,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 0,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -620,11 +627,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NUM2',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 9,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 9,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -642,11 +649,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NUM3',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 15,
|
||||
scale: 5,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 15,
|
||||
scale: 5,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -664,11 +671,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NUM4',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 1,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 1,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -686,11 +693,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NUM5',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 7,
|
||||
scale: -2,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 7,
|
||||
scale: -2,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -708,11 +715,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NUM6',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 23,
|
||||
scale: 15,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 23,
|
||||
scale: 15,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -730,11 +737,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'DECI1',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -752,11 +759,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'DECI2',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 8,
|
||||
scale: 18,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 8,
|
||||
scale: 18,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -774,11 +781,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'INTENUM',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -796,11 +803,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'INTNUM',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -818,11 +825,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'SINT',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 38,
|
||||
scale: 0,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -840,11 +847,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'FLOAT1',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 126,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 126,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -862,11 +869,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'FLOAT2',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 90,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 90,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -884,11 +891,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'DOUBLE',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 126,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 126,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -906,11 +913,11 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'RENUM',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 63,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_NUMBER,
|
||||
precision: 63,
|
||||
scale: -127,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -918,16 +925,20 @@ describe('17. extendedMetaData.js', function() {
|
|||
|
||||
});
|
||||
|
||||
it.skip('17.3.20 LONG *** NEW FUNCTIONALITY ***', function(done) {
|
||||
it('17.3.20 LONG', function(done) {
|
||||
|
||||
connection.execute(
|
||||
"SELECT ln FROM nodb_metadata",
|
||||
[],
|
||||
{ extendedMetaData: true },
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-010:');
|
||||
// NJS-010: unsupported data type in select list
|
||||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'LN',
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_LONG,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
@ -944,9 +955,9 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'BF',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_BINARY_FLOAT,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_BINARY_FLOAT,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -964,9 +975,9 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'BD',
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_BINARY_DOUBLE,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.NUMBER,
|
||||
dbType: oracledb.DB_TYPE_BINARY_DOUBLE,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -984,9 +995,9 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'DT',
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_DATE,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_DATE,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1004,10 +1015,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'TS1',
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP,
|
||||
precision: 6,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP,
|
||||
precision: 6,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1025,10 +1036,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'TS2',
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP,
|
||||
precision: 5,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP,
|
||||
precision: 5,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1088,10 +1099,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'TS5',
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP_LTZ,
|
||||
precision: 6,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP_LTZ,
|
||||
precision: 6,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1109,10 +1120,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'TS6',
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP_LTZ,
|
||||
precision: 9,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.DATE,
|
||||
dbType: oracledb.DB_TYPE_TIMESTAMP_LTZ,
|
||||
precision: 9,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1129,6 +1140,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
function(err, result) {
|
||||
(err.message).should.startWith('NJS-010:');
|
||||
// NJS-010: unsupported data type in select list
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
@ -1144,6 +1156,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
function(err, result) {
|
||||
(err.message).should.startWith('NJS-010:');
|
||||
// NJS-010: unsupported data type in select list
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
@ -1200,9 +1213,9 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'CLB',
|
||||
fetchType: oracledb.CLOB,
|
||||
dbType: oracledb.DB_TYPE_CLOB,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.CLOB,
|
||||
dbType: oracledb.DB_TYPE_CLOB,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1220,9 +1233,9 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'BLB',
|
||||
fetchType: oracledb.BLOB,
|
||||
dbType: oracledb.DB_TYPE_BLOB,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.BLOB,
|
||||
dbType: oracledb.DB_TYPE_BLOB,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1240,9 +1253,9 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'NCLB',
|
||||
fetchType: oracledb.CLOB,
|
||||
dbType: oracledb.DB_TYPE_CLOB,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.CLOB,
|
||||
dbType: oracledb.DB_TYPE_CLOB,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1259,6 +1272,8 @@ describe('17. extendedMetaData.js', function() {
|
|||
function(err, result) {
|
||||
(err.message).should.startWith('NJS-010:');
|
||||
// NJS-010: unsupported data type in select list
|
||||
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
@ -1275,10 +1290,10 @@ describe('17. extendedMetaData.js', function() {
|
|||
should.not.exist(err);
|
||||
(result.metaData).should.deepEqual(
|
||||
[ { name: 'MYRAW',
|
||||
fetchType: oracledb.STRING,
|
||||
dbType: oracledb.DB_TYPE_RAW,
|
||||
byteSize: 2000,
|
||||
nullable: true } ]
|
||||
fetchType: oracledb.BUFFER,
|
||||
dbType: oracledb.DB_TYPE_RAW,
|
||||
byteSize: 2000,
|
||||
nullable: true } ]
|
||||
);
|
||||
done();
|
||||
}
|
||||
|
@ -1411,7 +1426,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
|
||||
async.series([
|
||||
function(cb) {
|
||||
var proc = "CREATE OR REPLACE PROCEDURE get_rc (p_out OUT SYS_REFCURSOR) \n" +
|
||||
var proc = "CREATE OR REPLACE PROCEDURE get_emd_rc (p_out OUT SYS_REFCURSOR) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" OPEN p_out FOR \n" +
|
||||
|
@ -1428,7 +1443,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"BEGIN get_rc(:out); END;",
|
||||
"BEGIN get_emd_rc(:out); END;",
|
||||
{
|
||||
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
|
@ -1442,7 +1457,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE get_rc",
|
||||
"DROP PROCEDURE get_emd_rc",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
|
@ -1524,13 +1539,12 @@ describe('17. extendedMetaData.js', function() {
|
|||
|
||||
it("17.6.2 oracledb.fetchAsString", function(done) {
|
||||
|
||||
var defaultValue = oracledb.fetchAsString;
|
||||
async.series([
|
||||
function(cb) {
|
||||
function change(cb) {
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
cb();
|
||||
},
|
||||
function(cb) {
|
||||
function test(cb) {
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_md",
|
||||
[],
|
||||
|
@ -1559,34 +1573,30 @@ describe('17. extendedMetaData.js', function() {
|
|||
);
|
||||
},
|
||||
function(cb) {
|
||||
var defaultValue = [];
|
||||
(oracledb.fetchAsString).should.eql(defaultValue);
|
||||
cb();
|
||||
}
|
||||
], done);
|
||||
|
||||
}); // 17.6.2
|
||||
|
||||
it("17.6.3 can override at execution", function(done) {
|
||||
|
||||
var defaultValue = oracledb.fetchAsString;
|
||||
async.series([
|
||||
function(cb) {
|
||||
function change(cb) {
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
cb();
|
||||
},
|
||||
function(cb) {
|
||||
function test(cb) {
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_md",
|
||||
[],
|
||||
{ outFormat: oracledb.OBJECT,
|
||||
extendedMetaData: true,
|
||||
fetchInfo:
|
||||
{
|
||||
"DT": { type: oracledb.DEFAULT }
|
||||
}
|
||||
},
|
||||
{ outFormat: oracledb.OBJECT, extendedMetaData: true },
|
||||
function(err, result) {
|
||||
oracledb.fetchAsString = [];
|
||||
should.not.exist(err);
|
||||
(result.rows[0]).DT.should.be.a.Date();
|
||||
(result.rows[0]).DT.should.be.a.String();
|
||||
(result.rows[0]).NUM.should.be.a.String();
|
||||
(result.metaData).should.deepEqual([
|
||||
{ name: 'NUM',
|
||||
|
@ -1600,18 +1610,19 @@ describe('17. extendedMetaData.js', function() {
|
|||
dbType: oracledb.DB_TYPE_VARCHAR,
|
||||
byteSize: 1000,
|
||||
nullable: true },
|
||||
{ name: 'DT', fetchType: oracledb.DATE, dbType: oracledb.DB_TYPE_DATE, nullable: true }
|
||||
{ name: 'DT', fetchType: oracledb.STRING, dbType: oracledb.DB_TYPE_DATE, nullable: true }
|
||||
]);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
oracledb.fetchAsString = [];
|
||||
var defaultValue = [];
|
||||
(oracledb.fetchAsString).should.eql(defaultValue);
|
||||
cb();
|
||||
}
|
||||
], done);
|
||||
|
||||
}); // 17.6.3
|
||||
|
||||
}); // 17.6
|
||||
|
@ -1650,13 +1661,13 @@ describe('17. extendedMetaData.js', function() {
|
|||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_casesensitive'); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_md_casesensitive PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_casesensitive ( \n" +
|
||||
" CREATE TABLE nodb_md_casesensitive ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
' "nAme" VARCHAR2(20) \n' +
|
||||
" ) \n" +
|
||||
|
@ -1673,7 +1684,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_casesensitive",
|
||||
"SELECT * FROM nodb_md_casesensitive",
|
||||
[],
|
||||
{ extendedMetaData: true },
|
||||
function(err, result) {
|
||||
|
@ -1699,7 +1710,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_casesensitive",
|
||||
"DROP TABLE nodb_md_casesensitive PURGE",
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -1712,18 +1723,18 @@ describe('17. extendedMetaData.js', function() {
|
|||
|
||||
}); // 17.8
|
||||
|
||||
describe("17.9 single character column", function(done) {
|
||||
describe("17.9 single character column", function() {
|
||||
|
||||
it("17.9.1 works with column names comprised of single character", function(done) {
|
||||
|
||||
var tableName = "nodb_single_char";
|
||||
var tableName = "nodb_md_singlechar";
|
||||
var sqlCreate =
|
||||
"BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
|
@ -1736,7 +1747,7 @@ describe('17. extendedMetaData.js', function() {
|
|||
" '); \n" +
|
||||
"END; \n";
|
||||
var sqlSelect = "SELECT * FROM " + tableName;
|
||||
var sqlDrop = "DROP TABLE " + tableName;
|
||||
var sqlDrop = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
|
@ -1832,15 +1843,31 @@ describe('17. extendedMetaData.js', function() {
|
|||
return buffer.join();
|
||||
}
|
||||
|
||||
var table_name = "nodb_large_columns";
|
||||
var sqlCreate = "CREATE TABLE " + table_name + " ( " + columns_string + " )";
|
||||
var table_name = "nodb_md_largecolumns";
|
||||
var sqlSelect = "SELECT * FROM " + table_name;
|
||||
var sqlDrop = "DROP TABLE " + table_name;
|
||||
var sqlDrop = "DROP TABLE " + table_name + " PURGE";
|
||||
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_md_largecolumns PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_md_largecolumns ( \n" +
|
||||
columns_string +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
sqlCreate,
|
||||
proc,
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
|
|
@ -1,156 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 5. externalAuthentication.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing external authentication functionality.
|
||||
*
|
||||
* NOTE
|
||||
* The External Authentication should be configured on DB side if
|
||||
* "externalAuth" is true.
|
||||
* You may refer to the doc about external authentication at
|
||||
* https://github.com/oracle/node-oracledb/blob/master/doc/api.md#extauth
|
||||
*
|
||||
* 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 dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('5. externalAuthentication.js', function() {
|
||||
|
||||
it('5.1 connection should succeed when setting externalAuth to be false and providing user/password', function(done){
|
||||
oracledb.getConnection(
|
||||
{
|
||||
externalAuth: false,
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn){
|
||||
should.not.exist(err);
|
||||
conn.should.be.ok;
|
||||
conn.execute(
|
||||
"select (7+8) from dual",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.equal(15);
|
||||
conn.release( function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('5.2 error should be thrown when setting externalAuth to be true and providing user/password', function(done){
|
||||
oracledb.getConnection(
|
||||
{
|
||||
externalAuth: true,
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn){
|
||||
should.exist(err);
|
||||
err.message.should.startWith('DPI-1032:');
|
||||
// user/password cannot be set when using external authentication
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('5.3 can get connection from oracledb', function(done){
|
||||
// console.log(dbConfig);
|
||||
if(dbConfig.externalAuth){
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection){
|
||||
should.not.exist(err);
|
||||
connection.should.be.ok;
|
||||
sql = "select (1+4) from dual";
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.equal(5);
|
||||
connection.release(function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
// console.log("External Authentication Off.");
|
||||
done();
|
||||
}
|
||||
})
|
||||
|
||||
it('5.4 can create pool', function(done){
|
||||
if(dbConfig.externalAuth){
|
||||
oracledb.createPool(
|
||||
dbConfig,
|
||||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
|
||||
pool.getConnection(function(err, connection){
|
||||
should.not.exist(err);
|
||||
connection.should.be.ok;
|
||||
|
||||
sql = "select (1+4) from dual";
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.equal(5);
|
||||
connection.release( function(err){
|
||||
should.not.exist(err);
|
||||
|
||||
pool.terminate(function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
// console.log("External Authentication off.");
|
||||
done();
|
||||
}
|
||||
})
|
||||
|
||||
})
|
206
test/fetchAs.js
206
test/fetchAs.js
|
@ -33,10 +33,12 @@
|
|||
*****************************************************************************/
|
||||
'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');
|
||||
var assist = require ('./dataTypeAssist.js');
|
||||
|
||||
|
||||
describe('56. fetchAs.js', function() {
|
||||
|
||||
|
@ -47,7 +49,7 @@ describe('56. fetchAs.js', function() {
|
|||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
afterEach('release connection, reset fetchAsString property', function(done) {
|
||||
oracledb.fetchAsString = [];
|
||||
|
@ -55,7 +57,7 @@ describe('56. fetchAs.js', function() {
|
|||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('56.1 property value check', function() {
|
||||
|
||||
|
@ -69,7 +71,7 @@ describe('56. fetchAs.js', function() {
|
|||
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
(oracledb.fetchAsString).should.eql( [2003, 2002] );
|
||||
})
|
||||
});
|
||||
|
||||
it('56.2 Fetch DATE column values as STRING - by-Column name', function(done) {
|
||||
connection.execute(
|
||||
|
@ -86,7 +88,7 @@ describe('56. fetchAs.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('56.3 Fetch DATE, NUMBER column values STRING - by Column-name', function(done) {
|
||||
connection.execute(
|
||||
|
@ -109,7 +111,7 @@ describe('56. fetchAs.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('56.4 Fetch DATE, NUMBER as STRING by-time configuration and by-name', function(done) {
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
|
@ -134,7 +136,7 @@ describe('56. fetchAs.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('56.5 Fetch DATE, NUMBER column as STRING by-type and override at execute time', function(done) {
|
||||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ];
|
||||
|
@ -159,7 +161,7 @@ describe('56. fetchAs.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('56.6 Fetch ROWID column values STRING - non-ResultSet', function(done) {
|
||||
connection.execute(
|
||||
|
@ -179,7 +181,7 @@ describe('56. fetchAs.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('56.7 Fetch ROWID column values STRING - ResultSet', function(done) {
|
||||
connection.execute(
|
||||
|
@ -207,7 +209,7 @@ describe('56. fetchAs.js', function() {
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
/*
|
||||
* The maximum safe integer in JavaScript is (2^53 - 1).
|
||||
|
@ -216,22 +218,22 @@ describe('56. fetchAs.js', function() {
|
|||
* The last element is out of Oracle database standard Number range. It will be rounded by database.
|
||||
*/
|
||||
var numStrs =
|
||||
[
|
||||
'17249138680355831',
|
||||
'-17249138680355831',
|
||||
'0.17249138680355831',
|
||||
'-0.17249138680355831',
|
||||
'0.1724913868035583123456789123456789123456'
|
||||
];
|
||||
[
|
||||
'17249138680355831',
|
||||
'-17249138680355831',
|
||||
'0.17249138680355831',
|
||||
'-0.17249138680355831',
|
||||
'0.1724913868035583123456789123456789123456'
|
||||
];
|
||||
|
||||
var numResults =
|
||||
[
|
||||
'17249138680355831',
|
||||
'-17249138680355831',
|
||||
'.17249138680355831',
|
||||
'-.17249138680355831',
|
||||
'.172491386803558312345678912345678912346'
|
||||
];
|
||||
[
|
||||
'17249138680355831',
|
||||
'-17249138680355831',
|
||||
'.17249138680355831',
|
||||
'-.17249138680355831',
|
||||
'.172491386803558312345678912345678912346'
|
||||
];
|
||||
|
||||
it('56.8 large numbers with fetchInfo', function(done) {
|
||||
async.forEach(numStrs, function(element, callback) {
|
||||
|
@ -256,7 +258,7 @@ describe('56. fetchAs.js', function() {
|
|||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('56.9 large numbers with setting fetchAsString property', function(done) {
|
||||
oracledb.fetchAsString = [ oracledb.NUMBER ];
|
||||
|
@ -278,19 +280,155 @@ describe('56. fetchAs.js', function() {
|
|||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
// FetchInfo format should <columName> : {type : oracledb.<type>
|
||||
it ('56.10 invalid syntax for type should result in error', function (done){
|
||||
// FetchInfo format should <columName> : {type : oracledb.<type> }
|
||||
it('56.10 invalid syntax for type should result in error', function (done){
|
||||
connection.execute (
|
||||
"SELECT SYSDATE AS THE_DATE FROM DUAL",
|
||||
{ },
|
||||
{ fetchInfo : { "THE_DATE" : oracledb.STRING }},
|
||||
function ( err, result ) {
|
||||
function ( err ) {
|
||||
should.exist ( err ) ;
|
||||
(err.message).should.startWith ('NJS-015:');
|
||||
should.strictEqual(err.message, 'NJS-015: type was not specified for conversion');
|
||||
done ();
|
||||
} );
|
||||
});
|
||||
|
||||
})
|
||||
it('56.11 assigns an empty array to fetchAsString', function() {
|
||||
oracledb.fetchAsString = [];
|
||||
(oracledb.fetchAsString).should.eql([]);
|
||||
});
|
||||
|
||||
it.skip('56.12 Negative - empty string', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = '';
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('56.13 Negative - null', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = null;
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('56.14 Negative - undefined', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = undefined;
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('56.15 Negative - NaN', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = NaN;
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('56.16 Negative - invalid type of value, number', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = 10;
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('56.17 Negative - invalid type of value, string', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.fetchAsString = 'abc';
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
it('56.18 Negative - passing oracledb.DATE type to fetchInfo', function(done) {
|
||||
connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: { ts_date: { type: oracledb.DATE } }
|
||||
},
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-021: invalid type for conversion specified'
|
||||
);
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('56.19 Negative - passing empty JSON to fetchInfo', function(done) {
|
||||
connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: { }
|
||||
},
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-020: empty array was specified to fetch values as string'
|
||||
);
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('56.20 Negative - passing oracledb.NUMBER type to fetchInfo', function(done) {
|
||||
connection.execute(
|
||||
"select sysdate as ts_date from dual",
|
||||
{ },
|
||||
{
|
||||
fetchInfo: { ts_date: { type: oracledb.NUMBER } }
|
||||
},
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-021: invalid type for conversion specified'
|
||||
);
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('56.21 Negative - invalid type of value, Date', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
var dt = new Date ();
|
||||
oracledb.fetchAsString = dt;
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('56.22 Negative - invalid type of value, Buffer', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
var buf = assist.createBuffer ( 10 ) ; // arbitary sized buffer
|
||||
oracledb.fetchAsString = buf;
|
||||
},
|
||||
/NJS-004: invalid value for property fetchAsString/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -287,26 +287,6 @@ describe('19. fetchTimestampAsString.js', function() {
|
|||
|
||||
|
||||
}); // 19.3
|
||||
|
||||
function test9(table, want, callback) {
|
||||
var sql = "select content from " + table + " order by num";
|
||||
var stream = connection.queryStream(
|
||||
sql,
|
||||
[],
|
||||
{ fetchInfo: { "CONTENT": { type: oracledb.STRING } } }
|
||||
);
|
||||
|
||||
var result = [];
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
result.push(data);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
should.deepEqual(result, want);
|
||||
setTimeout(callback, 100);
|
||||
});
|
||||
}
|
||||
|
||||
// fetchInfo option
|
||||
function test1(table, want, callback) {
|
||||
|
@ -496,14 +476,24 @@ 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 } } }
|
||||
);
|
||||
|
||||
var result = [];
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
result.push(data);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
should.deepEqual(result, want);
|
||||
setTimeout(callback, 100);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
|
@ -1,85 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 52. getConnAfterPoolTerminate.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing driver behaviour when trying to get connection from terminated pool.
|
||||
*
|
||||
* 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 dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('52. getConnAfterPoolTerminate.js', function() {
|
||||
|
||||
it('can not get connections from pool after pool is terminated', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
poolMin : 2,
|
||||
poolMax : 10
|
||||
},
|
||||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
|
||||
pool.getConnection( function(err, connection){
|
||||
should.not.exist(err);
|
||||
(pool.connectionsInUse).should.eql(1);
|
||||
|
||||
connection.execute(
|
||||
"SELECT (4+1) FROM dual",
|
||||
function(err, result){
|
||||
should.not.exist(err);
|
||||
(result.rows[0][0]).should.be.exactly(5);
|
||||
|
||||
connection.release( function(err){
|
||||
should.not.exist(err);
|
||||
|
||||
pool.terminate( function(err){
|
||||
should.not.exist(err);
|
||||
|
||||
pool.getConnection( function(err){
|
||||
should.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
|
@ -30,7 +30,6 @@
|
|||
*****************************************************************************/
|
||||
'use strict';
|
||||
|
||||
var oracledbCLib;
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
@ -38,7 +37,7 @@ var dbConfig = require('./dbconfig.js');
|
|||
describe('45. instanceof.js', function() {
|
||||
|
||||
it('45.1 instanceof works for the oracledb instance', function(done) {
|
||||
(oracledb instanceof oracledb.Oracledb).should.be.true;
|
||||
(oracledb instanceof oracledb.Oracledb).should.be.true();
|
||||
|
||||
done();
|
||||
});
|
||||
|
@ -46,7 +45,6 @@ describe('45. instanceof.js', function() {
|
|||
it('45.2 instanceof works for pool instances', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -57,7 +55,7 @@ describe('45. instanceof.js', function() {
|
|||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
|
||||
(pool instanceof oracledb.Pool).should.be.true;
|
||||
(pool instanceof oracledb.Pool).should.be.true();
|
||||
|
||||
pool.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
|
@ -69,66 +67,104 @@ describe('45. instanceof.js', function() {
|
|||
});
|
||||
|
||||
it('45.3 instanceof works for connection instances', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
(conn instanceof oracledb.Connection).should.be.true;
|
||||
|
||||
conn.release(function(err) {
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
(conn instanceof oracledb.Connection).should.be.true();
|
||||
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('45.4 instanceof works for resultset instances', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.execute(
|
||||
'select 1 from dual union select 2 from dual',
|
||||
[], // no binds
|
||||
{
|
||||
resultSet: true
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
(result.resultSet instanceof oracledb.ResultSet).should.be.true;
|
||||
|
||||
result.resultSet.close(function(err) {
|
||||
conn.execute(
|
||||
'select 1 from dual union select 2 from dual',
|
||||
[], // no binds
|
||||
{
|
||||
resultSet: true
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
(result.resultSet instanceof oracledb.ResultSet).should.be.true();
|
||||
|
||||
result.resultSet.close(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('45.5 instanceof works for lob instances', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.execute(
|
||||
'select to_clob(dummy) from dual',
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
(result.rows[0][0] instanceof oracledb.Lob).should.be.true;
|
||||
|
||||
conn.release(function(err) {
|
||||
conn.execute(
|
||||
'select to_clob(dummy) from dual',
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
(result.rows[0][0] instanceof oracledb.Lob).should.be.true();
|
||||
|
||||
var lob = result.rows[0][0];
|
||||
|
||||
lob.on("close", function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
}); // lob close event
|
||||
|
||||
lob.on("error", function(err) {
|
||||
should.not.exist(err, "lob.on 'error' event.");
|
||||
});
|
||||
|
||||
lob.close(function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}); // 45.5
|
||||
|
||||
});
|
||||
|
|
2740
test/list.txt
2740
test/list.txt
File diff suppressed because it is too large
Load Diff
|
@ -1,471 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 62. lobProperties.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing getters and setters for LOB class.
|
||||
* This test aims to increase the code coverage rate.
|
||||
*
|
||||
* 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 fs = require('fs');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('62. lobProperties.js', function() {
|
||||
|
||||
var tableName = "nodb_mylobs";
|
||||
var connection = null;
|
||||
var sqlSelect = "SELECT * FROM " + tableName + " WHERE id = :i";
|
||||
var defaultChunkSize = null;
|
||||
|
||||
before('prepare table and LOB data', function(done) {
|
||||
|
||||
var sqlCreateTab =
|
||||
" BEGIN "
|
||||
+ " DECLARE "
|
||||
+ " e_table_exists EXCEPTION; "
|
||||
+ " PRAGMA EXCEPTION_INIT(e_table_exists, -00942); "
|
||||
+ " BEGIN "
|
||||
+ " EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); "
|
||||
+ " EXCEPTION "
|
||||
+ " WHEN e_table_exists "
|
||||
+ " THEN NULL; "
|
||||
+ " END; "
|
||||
+ " EXECUTE IMMEDIATE (' "
|
||||
+ " CREATE TABLE " + tableName + " ( "
|
||||
+ " id NUMBER, c CLOB, b BLOB "
|
||||
+ " ) "
|
||||
+ " '); "
|
||||
+ " END; ";
|
||||
|
||||
var sqlInsert = "INSERT INTO " + tableName + " VALUES (:i, EMPTY_CLOB(), EMPTY_BLOB()) "
|
||||
+ " RETURNING c, b INTO :clob, :blob";
|
||||
|
||||
var bindVar =
|
||||
{
|
||||
i: 1,
|
||||
clob: { type: oracledb.CLOB, dir: oracledb.BIND_OUT },
|
||||
blob: { type: oracledb.BLOB, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
var clobFileName = './test/clobexample.txt';
|
||||
var blobFileName = './test/fuzzydinosaur.jpg';
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlCreateTab,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function insertLobData(cb) {
|
||||
connection.execute(
|
||||
sqlInsert,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
|
||||
var clob = result.outBinds.clob[0];
|
||||
var blob = result.outBinds.blob[0];
|
||||
var clobStream = fs.createReadStream(clobFileName);
|
||||
var blobStream = fs.createReadStream(blobFileName);
|
||||
|
||||
clobStream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
blobStream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
clob.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
blob.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
async.parallel([
|
||||
function(callback) {
|
||||
clob.on('finish', function() {
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
blob.on('finish', function() {
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], function() {
|
||||
connection.commit( function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
clobStream.pipe(clob);
|
||||
blobStream.pipe(blob);
|
||||
}
|
||||
);
|
||||
},
|
||||
function saveDefaultChunkSize(cb) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1];
|
||||
|
||||
defaultChunkSize = clob.chunkSize;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
|
||||
after(function(done) {
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}) // after
|
||||
|
||||
it('62.1 chunkSize (read-only)', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
var t1 = clob.chunkSize,
|
||||
t2 = blob.chunkSize;
|
||||
|
||||
t1.should.be.a.Number();
|
||||
t2.should.be.a.Number();
|
||||
t1.should.eql(t2);
|
||||
defaultChunkSize = clob.chunkSize;
|
||||
|
||||
try {
|
||||
clob.chunkSize = t1 + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
// console.log(err.message);
|
||||
// Cannot assign to read only property 'chunkSize' of #<Lob>
|
||||
}
|
||||
|
||||
try {
|
||||
blob.chunkSize = t2 + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
// console.log(err.message);
|
||||
// Cannot assign to read only property 'chunkSize' of #<Lob>
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.1
|
||||
|
||||
it('62.2 length (read-only)', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
var t1 = clob.length,
|
||||
t2 = blob.length;
|
||||
|
||||
t1.should.be.a.Number();
|
||||
t2.should.be.a.Number();
|
||||
t1.should.not.eql(t2);
|
||||
|
||||
try {
|
||||
clob.length = t1 + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
//console.log(err.message);
|
||||
// Cannot set property length of #<Lob> which has only a getter
|
||||
}
|
||||
|
||||
try {
|
||||
blob.length = t2 + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
//console.log(err.message);
|
||||
// Cannot set property length of #<Lob> which has only a getter
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.2
|
||||
|
||||
it('62.3 pieceSize -default value is chunkSize', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
var t1 = clob.pieceSize,
|
||||
t2 = blob.pieceSize;
|
||||
t1.should.eql(defaultChunkSize);
|
||||
t2.should.eql(defaultChunkSize);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.3
|
||||
|
||||
it('62.4 pieceSize - can be increased', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
var newValue = clob.pieceSize * 5;
|
||||
|
||||
clob.pieceSize = clob.pieceSize * 5;
|
||||
blob.pieceSize = blob.pieceSize * 5;
|
||||
|
||||
(clob.pieceSize).should.eql(newValue);
|
||||
(blob.pieceSize).should.eql(newValue);
|
||||
|
||||
// Remember to restore the value
|
||||
clob.pieceSize = defaultChunkSize;
|
||||
blob.pieceSize = defaultChunkSize;
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.4
|
||||
|
||||
it('62.5 pieceSize - can be decreased', function(done) {
|
||||
if (defaultChunkSize <= 500) {
|
||||
console.log('As default chunkSize is too small, this case is not applicable');
|
||||
done();
|
||||
} else {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
var newValue = clob.pieceSize - 500;
|
||||
|
||||
clob.pieceSize -= 500;
|
||||
blob.pieceSize -= 500;
|
||||
(clob.pieceSize).should.eql(newValue);
|
||||
(blob.pieceSize).should.eql(newValue);
|
||||
|
||||
// Restore
|
||||
clob.pieceSize = defaultChunkSize;
|
||||
blob.pieceSize = defaultChunkSize;
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
}
|
||||
}) // 62.5
|
||||
|
||||
it('62.6 pieceSize - can be zero', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
clob.pieceSize = 0;
|
||||
blob.pieceSize = 0;
|
||||
|
||||
(clob.pieceSize).should.eql(0);
|
||||
(blob.pieceSize).should.eql(0);
|
||||
|
||||
// Remember to restore the value
|
||||
clob.pieceSize = defaultChunkSize;
|
||||
blob.pieceSize = defaultChunkSize;
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.6
|
||||
|
||||
it('62.7 pieceSize - cannot be less than zero', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
try {
|
||||
clob.pieceSize = -100;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-004:');
|
||||
// NJS-004: invalid value for property pieceSize
|
||||
}
|
||||
|
||||
// Remember to restore the value
|
||||
clob.pieceSize = defaultChunkSize;
|
||||
blob.pieceSize = defaultChunkSize;
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.7
|
||||
|
||||
it('62.8 pieceSize - cannot be null', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
try {
|
||||
clob.pieceSize = null;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-004:');
|
||||
// NJS-004: invalid value for property pieceSize
|
||||
}
|
||||
|
||||
// Remember to restore the value
|
||||
clob.pieceSize = defaultChunkSize;
|
||||
blob.pieceSize = defaultChunkSize;
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.8
|
||||
|
||||
it('62.9 pieceSize - must be a number', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
try {
|
||||
clob.pieceSize = NaN;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-004:');
|
||||
// NJS-004: invalid value for property pieceSize
|
||||
}
|
||||
|
||||
// Remember to restore the value
|
||||
clob.pieceSize = defaultChunkSize;
|
||||
blob.pieceSize = defaultChunkSize;
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.9
|
||||
|
||||
it('62.10 type (read-only)', function(done) {
|
||||
connection.execute(
|
||||
sqlSelect,
|
||||
{ i: 1 },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var clob = result.rows[0][1],
|
||||
blob = result.rows[0][2];
|
||||
|
||||
var t1 = clob.type,
|
||||
t2 = blob.type;
|
||||
|
||||
t1.should.eql(oracledb.CLOB);
|
||||
t2.should.eql(oracledb.BLOB);
|
||||
|
||||
try {
|
||||
clob.type = t2;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
// console.log(err);
|
||||
// [TypeError: Cannot set property type of #<Lob> which has only a getter]
|
||||
}
|
||||
|
||||
try {
|
||||
blob.type = t1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
// console.log(err);
|
||||
// [TypeError: Cannot set property type of #<Lob> which has only a getter]
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
}) // 62.10
|
||||
})
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. */
|
||||
/* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -41,94 +41,75 @@ var oracledb = require('oracledb');
|
|||
var fs = require('fs');
|
||||
var async = require('async');
|
||||
var should = require('should');
|
||||
var stream = require('stream');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var assist = require('./dataTypeAssist.js');
|
||||
|
||||
var inFileName = './test/clobexample.txt';
|
||||
|
||||
describe('59. lobResultSet.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var node6plus = false; // assume node runtime version is lower than 6
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
// Check whether node runtime version is >= 6 or not
|
||||
if ( process.versions["node"].substring (0, 1) >= "6")
|
||||
node6plus = true;
|
||||
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('59.1 CLOB data', function() {
|
||||
|
||||
var insertID = 1;
|
||||
var tableName = "nodb_myclobs";
|
||||
var inFileName = './test/clobexample.txt';
|
||||
before('create table', function(done) {
|
||||
assist.createTable(connection, tableName, done);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
after('drop table', function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName,
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('59.1.1 reads clob data one by one row from result set', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
insertClob(1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
insertClob(2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
insertClob(3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
fetchOneRowFromRS(result.resultSet, callback);
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
|
||||
function fetchOneRowFromRS(resultSet, callback)
|
||||
{
|
||||
function fetchOneRowFromRS(resultSet, rowsFetched, rowsExpected, callback) {
|
||||
resultSet.getRow( function(err, row) {
|
||||
should.not.exist(err);
|
||||
if (!row) {
|
||||
resultSet.close( function(err) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(rowsFetched, rowsExpected);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var lob = row[1];
|
||||
lob.setEncoding('utf8');
|
||||
|
||||
var text = '';
|
||||
var text = "";
|
||||
lob.on('data', function(chunk) {
|
||||
text += chunk;
|
||||
text = text + chunk;
|
||||
});
|
||||
|
||||
lob.on('end', function() {
|
||||
fetchOneRowFromRS(resultSet, callback);
|
||||
rowsFetched ++;
|
||||
fs.readFile(inFileName, { encoding: 'utf8' }, function(err, originalData) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(text, originalData);
|
||||
});
|
||||
fetchOneRowFromRS(resultSet, rowsFetched, rowsExpected, callback);
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
|
@ -136,12 +117,10 @@ describe('59. lobResultSet.js', function() {
|
|||
console.error(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function insertClob(id, cb)
|
||||
{
|
||||
function streamIntoClob(id, cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO " + tableName + " VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv",
|
||||
{ n: id, lobbv: { type: oracledb.CLOB, dir: oracledb.BIND_OUT } },
|
||||
|
@ -159,6 +138,230 @@ describe('59. lobResultSet.js', function() {
|
|||
});
|
||||
});
|
||||
|
||||
inStream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
it('59.1.1 reads clob data one by one row from result set', function(done) {
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoClob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 59.1.1
|
||||
|
||||
it('59.1.2 works with oracledb.maxRows > actual number of rows fetched', function(done) {
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 10;
|
||||
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoClob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
callback();
|
||||
}
|
||||
], done);
|
||||
}); // 59.1.2
|
||||
|
||||
it('59.1.3 works with oracledb.maxRows = actual number of rows fetched', function(done) {
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 3;
|
||||
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoClob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
callback();
|
||||
}
|
||||
], done);
|
||||
}); // 59.1.3
|
||||
|
||||
it('59.1.4 works with oracledb.maxRows < actual number of rows fetched', function(done) {
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 1;
|
||||
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoClob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoClob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
callback();
|
||||
}
|
||||
], done);
|
||||
}); // 59.1.4
|
||||
|
||||
}); // 59.1
|
||||
|
||||
describe('59.2 BLOB data', function() {
|
||||
var insertID = 1;
|
||||
var tableName = "nodb_myblobs";
|
||||
var jpgFileName = "./test/fuzzydinosaur.jpg";
|
||||
before('create table', function(done) {
|
||||
assist.createTable(connection, tableName, done);
|
||||
});
|
||||
|
||||
after('drop table', function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function fetchOneRowFromRS(resultSet, rowsFetched, rowsExpected, callback) {
|
||||
resultSet.getRow( function(err, row) {
|
||||
should.not.exist(err);
|
||||
if (!row) {
|
||||
resultSet.close( function(err) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(rowsFetched, rowsExpected);
|
||||
rowsFetched = 0;
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
var lob = row[1];
|
||||
var blobData = 0;
|
||||
var totalLength = 0;
|
||||
blobData = node6plus ? Buffer.alloc(0) : new Buffer(0);
|
||||
|
||||
lob.on('data', function(chunk) {
|
||||
totalLength = totalLength + chunk.length;
|
||||
blobData = Buffer.concat([blobData, chunk], totalLength);
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.not.exist(err, "lob.on 'error' event.");
|
||||
});
|
||||
|
||||
lob.on('end', function() {
|
||||
fs.readFile( jpgFileName, function(err, originalData) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(totalLength, originalData.length);
|
||||
originalData.should.eql(blobData);
|
||||
});
|
||||
rowsFetched ++;
|
||||
fetchOneRowFromRS(resultSet, rowsFetched, rowsExpected, callback);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function streamIntoBlob(id, cb) {
|
||||
connection.execute(
|
||||
"INSERT INTO " + tableName + " VALUES (:n, EMPTY_BLOB()) RETURNING content INTO :lobbv",
|
||||
{ n: id, lobbv: { type: oracledb.BLOB, dir: oracledb.BIND_OUT } },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var lob = result.outBinds.lobbv[0];
|
||||
var inStream = fs.createReadStream(jpgFileName);
|
||||
|
||||
inStream.pipe(lob);
|
||||
|
||||
inStream.on('end', function() {
|
||||
connection.commit( function(err) {
|
||||
should.not.exist(err);
|
||||
cb(); // insertion done
|
||||
});
|
||||
});
|
||||
|
||||
inStream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
@ -167,6 +370,147 @@ describe('59. lobResultSet.js', function() {
|
|||
);
|
||||
}
|
||||
|
||||
}) // 59.1
|
||||
it('59.2.1 reads blob data one by one row from result set', function(done) {
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoBlob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 59.2.1
|
||||
|
||||
}) // 59
|
||||
it('59.2.2 works with oracledb.maxRows > actual number of rows fetched', function(done) {
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 10;
|
||||
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoBlob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
callback();
|
||||
}
|
||||
], done);
|
||||
}); // 59.2.2
|
||||
|
||||
it('59.2.3 works with oracledb.maxRows = actual number of rows fetched', function(done) {
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 3;
|
||||
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoBlob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
callback();
|
||||
}
|
||||
], done);
|
||||
}); // 59.2.3
|
||||
|
||||
it('59.2.4 works with oracledb.maxRows < actual number of rows fetched', function(done) {
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 1;
|
||||
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var id_3 = insertID++;
|
||||
async.series([
|
||||
function(callback) {
|
||||
streamIntoBlob(id_1, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_2, callback);
|
||||
},
|
||||
function(callback) {
|
||||
streamIntoBlob(id_3, callback);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT num, content FROM " + tableName + " where num = " + id_1 + " or num = " + id_2 + " or num = " + id_3,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var actualRowsFetched = 0; // actual rows read from resultset
|
||||
var rowsExpected = 3; // expected rows read from resultSet
|
||||
fetchOneRowFromRS(result.resultSet, actualRowsFetched, rowsExpected, callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
callback();
|
||||
}
|
||||
], done);
|
||||
}); // 59.2.4
|
||||
|
||||
}); // 59.2
|
||||
|
||||
}); // 59
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
* DESCRIPTION
|
||||
* Testing nested cursor.
|
||||
*
|
||||
* Note: Nested cursor is still not a supported data type. So NJS-010
|
||||
* error is expected.
|
||||
*
|
||||
* NUMBERING RULE
|
||||
* Test numbers follow this numbering rule:
|
||||
* 1 - 20 are reserved for basic functional tests
|
||||
|
@ -33,29 +36,30 @@
|
|||
*****************************************************************************/
|
||||
"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 createParentTable =
|
||||
var connection = null;
|
||||
var createParentTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_parent_tab'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_parent_tab PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_parent_tab ( \
|
||||
id NUMBER, \
|
||||
description VARCHAR2(32), \
|
||||
CONSTRAINT parent_tab_pk PRIMARY KEY (id) \
|
||||
CONSTRAINT nodb_parent_tab_pk PRIMARY KEY (id) \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
|
@ -75,15 +79,15 @@ describe('57. nestedCursor.js', function() {
|
|||
'); \
|
||||
END; ";
|
||||
|
||||
var createChildTable =
|
||||
var createChildTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_child_tab'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_child_tab PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
|
@ -91,8 +95,8 @@ describe('57. nestedCursor.js', function() {
|
|||
id NUMBER, \
|
||||
parent_id NUMBER, \
|
||||
description VARCHAR2(32), \
|
||||
CONSTRAINT child_tab_pk PRIMARY KEY (id), \
|
||||
CONSTRAINT child_parent_fk FOREIGN KEY (parent_id) REFERENCES nodb_parent_tab(id) \
|
||||
CONSTRAINT nodb_child_tab_pk PRIMARY KEY (id), \
|
||||
CONSTRAINT nodb_child_parent_fk FOREIGN KEY (parent_id) REFERENCES nodb_parent_tab(id) \
|
||||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
|
@ -127,103 +131,78 @@ describe('57. nestedCursor.js', function() {
|
|||
'); \
|
||||
END; ";
|
||||
|
||||
var cursorExpr =
|
||||
"CREATE OR REPLACE PROCEDURE cursor_parent_child (p_out OUT SYS_REFCURSOR) \
|
||||
AS \
|
||||
BEGIN \
|
||||
OPEN p_out FOR \
|
||||
SELECT p ";
|
||||
|
||||
var connection = false;
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
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(
|
||||
"DROP TABLE nodb_child_tab",
|
||||
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(
|
||||
"DROP TABLE nodb_parent_tab",
|
||||
},
|
||||
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);
|
||||
});
|
||||
|
||||
function fetchOneRowFromRS(rs, cb) {
|
||||
rs.getRow(function(err, row) {
|
||||
if(err) {
|
||||
// NJS-010: unsupported data type in select list
|
||||
(err.message).should.startWith('NJS-010:');
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
} else if(row) {
|
||||
// console.log(row);
|
||||
fetchOneRowFromRS(rs, cb);
|
||||
} else {
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
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 \
|
||||
|
@ -232,7 +211,7 @@ describe('57. nestedCursor.js', function() {
|
|||
) children \
|
||||
FROM nodb_parent_tab p";
|
||||
|
||||
connection.execute(
|
||||
connection.execute(
|
||||
sql,
|
||||
[],
|
||||
{ resultSet: true },
|
||||
|
@ -245,11 +224,11 @@ describe('57. nestedCursor.js', function() {
|
|||
}
|
||||
);
|
||||
|
||||
})
|
||||
}); // 57.1
|
||||
|
||||
it('57.2 testing nested cursor support - REF Cursor', function(done) {
|
||||
var testproc =
|
||||
"CREATE OR REPLACE PROCEDURE get_family_tree(p_out OUT SYS_REFCURSOR) \
|
||||
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 \
|
||||
OPEN p_out FOR \
|
||||
|
@ -262,37 +241,41 @@ describe('57. nestedCursor.js', function() {
|
|||
FROM nodb_parent_tab p; \
|
||||
END; ";
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
testproc,
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"BEGIN get_family_tree(:out); END;",
|
||||
{
|
||||
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
},
|
||||
function(callback){
|
||||
connection.execute(
|
||||
"BEGIN nodb_get_family_tree(:out); END;",
|
||||
{
|
||||
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fetchOneRowFromRS(result.outBinds.out, callback);
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-010:');
|
||||
// NJS-010: unsupported data type in select list
|
||||
should.not.exist(result);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE get_family_tree",
|
||||
function(err, result) {
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_get_family_tree",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
})
|
||||
}
|
||||
], done);
|
||||
}); // 57.2
|
||||
|
||||
});
|
||||
|
|
|
@ -45,16 +45,16 @@ describe('10. nullColumnValues.js', function() {
|
|||
var makeTable =
|
||||
"BEGIN \
|
||||
DECLARE \
|
||||
e_table_exists EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \
|
||||
e_table_missing EXCEPTION; \
|
||||
PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \
|
||||
BEGIN \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_departments'); \
|
||||
EXECUTE IMMEDIATE ('DROP TABLE nodb_nullcol_dept PURGE'); \
|
||||
EXCEPTION \
|
||||
WHEN e_table_exists \
|
||||
WHEN e_table_missing \
|
||||
THEN NULL; \
|
||||
END; \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
CREATE TABLE nodb_departments ( \
|
||||
CREATE TABLE nodb_nullcol_dept ( \
|
||||
department_id NUMBER, \
|
||||
department_name VARCHAR2(20), \
|
||||
manager_id NUMBER, \
|
||||
|
@ -62,37 +62,44 @@ describe('10. nullColumnValues.js', function() {
|
|||
) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_nullcol_dept \
|
||||
VALUES \
|
||||
(40,''Human Resources'', 203, 2400) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_nullcol_dept \
|
||||
VALUES \
|
||||
(50,''Shipping'', 121, 1500) \
|
||||
'); \
|
||||
EXECUTE IMMEDIATE (' \
|
||||
INSERT INTO nodb_departments \
|
||||
INSERT INTO nodb_nullcol_dept \
|
||||
VALUES \
|
||||
(90, ''Executive'', 100, 1700) \
|
||||
'); \
|
||||
END; ";
|
||||
oracledb.getConnection(dbConfig, function(err, conn){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
conn.execute(
|
||||
makeTable,
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
})
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn){
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
conn.execute(
|
||||
makeTable,
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
afterEach('drop table and release connection', function(done){
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_departments",
|
||||
"DROP TABLE nodb_nullcol_dept PURGE",
|
||||
function(err){
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection.release( function(err){
|
||||
|
@ -101,10 +108,10 @@ describe('10. nullColumnValues.js', function() {
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('10.1 a simple query for null value', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
connection.execute(
|
||||
"SELECT null FROM DUAL",
|
||||
|
@ -114,15 +121,15 @@ describe('10. nullColumnValues.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('10.2 in-bind for null column value', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_departments VALUES(:did, :dname, :mid, :mname)",
|
||||
"INSERT INTO nodb_nullcol_dept VALUES(:did, :dname, :mid, :mname)",
|
||||
{
|
||||
did: 101,
|
||||
dname: 'Facility',
|
||||
|
@ -138,7 +145,7 @@ describe('10. nullColumnValues.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments WHERE department_id = :did",
|
||||
"SELECT * FROM nodb_nullcol_dept WHERE department_id = :did",
|
||||
{ did: 101 },
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
|
@ -154,10 +161,10 @@ describe('10. nullColumnValues.js', function() {
|
|||
}
|
||||
], done);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('10.3 out-bind for null column value', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
|
@ -197,24 +204,24 @@ describe('10. nullColumnValues.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
it('10.4 DML Returning for null column value', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
connection.execute(
|
||||
"UPDATE nodb_departments SET department_name = :dname, \
|
||||
"UPDATE nodb_nullcol_dept SET department_name = :dname, \
|
||||
manager_id = :mid WHERE department_id = :did \
|
||||
RETURNING department_id, department_name, manager_id INTO \
|
||||
:rdid, :rdname, :rmid",
|
||||
{
|
||||
dname: '',
|
||||
mid: null,
|
||||
did: 90,
|
||||
rdid: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
rdname: { type: oracledb.STRING, dir: oracledb.BIND_OUT },
|
||||
rmid: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{
|
||||
dname: '',
|
||||
mid: null,
|
||||
did: 90,
|
||||
rdid: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
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);
|
||||
|
@ -226,15 +233,15 @@ describe('10. nullColumnValues.js', function() {
|
|||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('10.5 resultSet for null value', function(done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"UPDATE nodb_departments SET department_name = :dname, \
|
||||
"UPDATE nodb_nullcol_dept SET department_name = :dname, \
|
||||
manager_id = :mid WHERE department_id = :did ",
|
||||
{
|
||||
dname: '',
|
||||
|
@ -250,7 +257,7 @@ describe('10. nullColumnValues.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"SELECT * FROM nodb_departments WHERE department_id = :1",
|
||||
"SELECT * FROM nodb_nullcol_dept WHERE department_id = :1",
|
||||
[50],
|
||||
{ resultSet: true },
|
||||
function(err, result) {
|
||||
|
@ -276,6 +283,6 @@ describe('10. nullColumnValues.js', function() {
|
|||
}
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,987 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 43. plsqlBinding1.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing PL/SQL indexed tables (associative arrays).
|
||||
*
|
||||
* 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');
|
||||
|
||||
describe('43. plsqlBinding1.js', function() {
|
||||
|
||||
describe('43.1 binding PL/SQL indexed table', function() {
|
||||
var connection = null;
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
after(function(done) {
|
||||
connection.release( function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
it('43.1.1 binding PL/SQL indexed table IN by name', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" TYPE stringsType IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE numbersType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" FUNCTION test(strings IN stringsType, numbers IN numbersType) RETURN VARCHAR2;\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" FUNCTION test(strings IN stringsType, numbers IN numbersType) RETURN VARCHAR2\n" +
|
||||
" IS\n" +
|
||||
" s VARCHAR2(2000) := '';\n" +
|
||||
" BEGIN\n" +
|
||||
" FOR i IN 1 .. strings.COUNT LOOP\n" +
|
||||
" s := s || strings(i);\n" +
|
||||
" END LOOP;\n" +
|
||||
" FOR i IN 1 .. numbers.COUNT LOOP\n" +
|
||||
" s := s || numbers(i);\n" +
|
||||
" END LOOP;\n" +
|
||||
" RETURN s;\n" +
|
||||
" END;\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var bindvars = {
|
||||
result: {type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 2000},
|
||||
strings: {type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['John', 'Doe']},
|
||||
numbers: {type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: [0, 8, 11]}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN :result := nodb_testpack.test(:strings, :numbers); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
result.outBinds.result.should.be.exactly('JohnDoe0811');
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE nodb_testpack",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
it('43.1.2 binding PL/SQL indexed table IN by position', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" TYPE stringsType IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE numbersType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE test(s IN stringsType, n IN numbersType);\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" PROCEDURE test(s IN stringsType, n IN numbersType)\n" +
|
||||
" IS\n" +
|
||||
" BEGIN\n" +
|
||||
" IF (s(1) IS NULL OR s(1) <> 'John') THEN\n" +
|
||||
" raise_application_error(-20000, 'Invalid s(1): \"' || s(1) || '\"');\n" +
|
||||
" END IF;\n" +
|
||||
" IF (s(2) IS NULL OR s(2) <> 'Doe') THEN\n" +
|
||||
" raise_application_error(-20000, 'Invalid s(2): \"' || s(2) || '\"');\n" +
|
||||
" END IF;\n" +
|
||||
" END;\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var bindvars = [
|
||||
{type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['John', 'Doe']},
|
||||
{type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: [8, 11]}
|
||||
];
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test(:1, :2); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE nodb_testpack",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
it('43.1.3 binding PL/SQL indexed table IN OUT', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" TYPE stringsType IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE numbersType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE test(strings IN OUT NOCOPY stringsType, numbers IN OUT NOCOPY numbersType);\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" PROCEDURE test(strings IN OUT NOCOPY stringsType, numbers IN OUT NOCOPY numbersType)\n" +
|
||||
" IS\n" +
|
||||
" BEGIN\n" +
|
||||
" FOR i IN 1 .. strings.COUNT LOOP\n" +
|
||||
" strings(i) := '(' || strings(i) || ')';\n" +
|
||||
" END LOOP;\n" +
|
||||
" FOR i IN 1 .. numbers.COUNT LOOP\n" +
|
||||
" numbers(i) := numbers(i) * 10;\n" +
|
||||
" END LOOP;\n" +
|
||||
" numbers(numbers.COUNT + 1) := 4711;\n" +
|
||||
" END;\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var bindvars = {
|
||||
strings: {type: oracledb.STRING, dir: oracledb.BIND_INOUT, val: ['John', 'Doe'], maxArraySize: 2},
|
||||
numbers: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 4}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test(:strings, :numbers); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
//console.log(result);
|
||||
should.deepEqual(result.outBinds.strings, ['(John)', '(Doe)']);
|
||||
should.deepEqual(result.outBinds.numbers, [10, 20, 30, 4711]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE nodb_testpack",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
it('43.1.4 binding PL/SQL indexed table OUT', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" TYPE stringsType IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE numbersType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE test(items IN NUMBER, strings OUT NOCOPY stringsType, numbers OUT NOCOPY numbersType);\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" PROCEDURE test(items IN NUMBER, strings OUT NOCOPY stringsType, numbers OUT NOCOPY numbersType)\n" +
|
||||
" IS\n" +
|
||||
" BEGIN\n" +
|
||||
" FOR i IN 1 .. items LOOP\n" +
|
||||
" strings(i) := i;\n" +
|
||||
" END LOOP;\n" +
|
||||
" FOR i IN 1 .. items LOOP\n" +
|
||||
" numbers(i) := i;\n" +
|
||||
" END LOOP;\n" +
|
||||
" END;\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var bindvars = {
|
||||
items: {type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: 3},
|
||||
strings: {type: oracledb.STRING, dir: oracledb.BIND_OUT, maxArraySize: 3},
|
||||
numbers: {type: oracledb.NUMBER, dir: oracledb.BIND_OUT, maxArraySize: 3}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test(:items, :strings, :numbers); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
//console.log(result);
|
||||
should.deepEqual(result.outBinds.strings, ['1', '2', '3']);
|
||||
should.deepEqual(result.outBinds.numbers, [1, 2, 3]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE nodb_testpack",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
describe('43.2 test exceptions when using PL/SQL indexed table bindings', function() {
|
||||
var connection = null;
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" TYPE datesType IS TABLE OF DATE INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE numbersType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringsType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE test1(p IN numbersType);\n" +
|
||||
" PROCEDURE test2(p IN OUT NOCOPY numbersType);\n" +
|
||||
" PROCEDURE test3(p IN datesType);\n" +
|
||||
" PROCEDURE test4(p IN stringsType);\n" +
|
||||
" PROCEDURE test5(p OUT stringsType);\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" PROCEDURE test1(p IN numbersType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test2(p IN OUT NOCOPY numbersType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test3(p IN datesType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test4(p IN stringsType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test5(p OUT stringsType) IS BEGIN NULL; END;\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE nodb_testpack",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}) // after
|
||||
|
||||
it('43.2.1 maxArraySize is ignored when specifying BIND_IN', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: [1, 2, 3], maxArraySize: 2}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test1(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.2.2 maxArraySize is mandatory for BIND_INOUT ', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3]}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-035:');
|
||||
// NJS-035: maxArraySize is required for IN OUT array bind
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('42.2.3 maxArraySize cannot smaller than the number of array elements', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 2}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test3(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-036:');
|
||||
// NJS-036: Given Array is of size greater than maxArraySize property.
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('42.2.4 DATE type has not been supported yet', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.DATE, dir: oracledb.BIND_IN, val: [new Date(), new Date()]}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test3(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-034:');
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('42.2.5 negative case (string): incorrect type of array elements', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['hello', 1]}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test4(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-037:');
|
||||
// NJS-037: incompatible type of value provided.
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('42.2.6 negative case (number): incorrect type of array element', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: [1, 'hello']}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test1(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-037:');
|
||||
// NJS-037: incompatible type of value provided.
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('42.2.7 supports binding by position', function(done) {
|
||||
var bindvars = [
|
||||
{type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['hello', 'node.js']}
|
||||
];
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test4(:1); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
}) // 43.2
|
||||
|
||||
describe('43.3 binding PL/SQL scalar', function() {
|
||||
var connection = null;
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
after(function(done) {
|
||||
connection.release( function(err) {
|
||||
if(err) { console.error(err.message); return; }
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
it('43.3.1 binding PL/SQL scalar IN', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE\n" +
|
||||
"FUNCTION nodb_test(stringValue IN VARCHAR2, numberValue IN NUMBER, dateValue IN DATE) RETURN VARCHAR2\n" +
|
||||
"IS\n" +
|
||||
"BEGIN\n" +
|
||||
" RETURN stringValue || ' ' || numberValue || ' released in ' || TO_CHAR(dateValue, 'MON YYYY');\n" +
|
||||
"END nodb_test;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var bindvars = {
|
||||
result: {type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 2000},
|
||||
stringValue: {type: oracledb.STRING, dir: oracledb.BIND_IN, val: 'Space odyssey'},
|
||||
numberValue: {type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: 2001 },
|
||||
dateValue: {type: oracledb.DATE, dir: oracledb.BIND_IN, val: new Date(1968, 3, 2) }
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN :result := nodb_test(:stringValue, :numberValue, :dateValue); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
//console.log(result);
|
||||
result.outBinds.result.should.be.exactly('Space odyssey 2001 released in APR 1968');
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP FUNCTION nodb_test",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
// Date data type not support yet
|
||||
it.skip('43.3.2 binding PL/SQL scalar IN/OUT', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE\n" +
|
||||
"PROCEDURE nodb_test(stringValue IN OUT NOCOPY VARCHAR2, numberValue IN OUT NOCOPY NUMBER, dateValue IN OUT NOCOPY DATE)\n" +
|
||||
"IS\n" +
|
||||
"BEGIN\n" +
|
||||
" stringValue := '(' || stringValue || ')';\n" +
|
||||
" numberValue := NumberValue + 100;\n" +
|
||||
//" dateValue := "
|
||||
"END nodb_test;\n";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var releaseDate = new Date(1968, 3, 2);
|
||||
var bindvars = {
|
||||
stringValue: {type: oracledb.STRING, dir: oracledb.BIND_INOUT, val: 'Space odyssey'},
|
||||
numberValue: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: 2001},
|
||||
dateValue: {type: oracledb.DATE, dir: oracledb.BIND_INOUT, val: releaseDate}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_test(:stringValue, :numberValue, :dateValue); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
result.outBinds.stringValue.should.be.exactly('(Space odyssey)');
|
||||
result.outBinds.numberValue.should.be.exactly(2101);
|
||||
//result.outBinds.dateValue.should.eql(releaseDate)
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_test",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
it('43.3.3 binding PL/SQL scalar OUT by name', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE\n" +
|
||||
"PROCEDURE nodb_test(stringValue OUT VARCHAR2, numberValue OUT NUMBER, dateValue OUT DATE)\n" +
|
||||
"IS\n" +
|
||||
"BEGIN\n" +
|
||||
" stringValue := 'Space odyssey';\n" +
|
||||
" numberValue := 2001;\n" +
|
||||
" dateValue := TO_DATE('04-02-1968', 'MM-DD-YYYY');" +
|
||||
"END nodb_test;\n";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var bindvars = {
|
||||
stringValue: {type: oracledb.STRING, dir: oracledb.BIND_OUT},
|
||||
numberValue: {type: oracledb.NUMBER, dir: oracledb.BIND_OUT},
|
||||
dateValue: {type: oracledb.DATE, dir: oracledb.BIND_OUT}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_test(:stringValue, :numberValue, :dateValue); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
result.outBinds.stringValue.should.be.exactly('Space odyssey');
|
||||
result.outBinds.numberValue.should.be.exactly(2001);
|
||||
(Object.prototype.toString.call(result.outBinds.dateValue)).should.eql('[object Date]');
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_test",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
it('43.3.4 binding PL/SQL scalar OUT by postion', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE\n" +
|
||||
"PROCEDURE nodb_test(stringValue OUT VARCHAR2, numberValue OUT NUMBER, dateValue OUT DATE)\n" +
|
||||
"IS\n" +
|
||||
"BEGIN\n" +
|
||||
" stringValue := 'Space odyssey';\n" +
|
||||
" numberValue := 2001;\n" +
|
||||
" dateValue := TO_DATE('04-02-1968', 'MM-DD-YYYY');" +
|
||||
"END nodb_test;\n";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var bindvars = [
|
||||
{type: oracledb.STRING, dir: oracledb.BIND_OUT},
|
||||
{type: oracledb.NUMBER, dir: oracledb.BIND_OUT},
|
||||
{type: oracledb.DATE, dir: oracledb.BIND_OUT}
|
||||
];
|
||||
connection.execute(
|
||||
"BEGIN nodb_test(:1, :2, :3); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result);
|
||||
result.outBinds[0].should.be.exactly('Space odyssey');
|
||||
result.outBinds[1].should.be.exactly(2001);
|
||||
(Object.prototype.toString.call(result.outBinds[2])).should.eql('[object Date]');
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE nodb_test",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
|
||||
}) // 43.3
|
||||
|
||||
describe('43.4 test attribute - maxArraySize', function() {
|
||||
var connection = null;
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" TYPE datesType IS TABLE OF DATE INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE numbersType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE stringsType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE test1(p IN numbersType);\n" +
|
||||
" PROCEDURE test2(p IN OUT NOCOPY numbersType);\n" +
|
||||
" PROCEDURE test3(p IN datesType);\n" +
|
||||
" PROCEDURE test4(p IN stringsType);\n" +
|
||||
" PROCEDURE test5(p IN numbersType);\n" +
|
||||
"END;";
|
||||
connection.should.be.ok;
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
|
||||
"nodb_testpack\n" +
|
||||
"IS\n" +
|
||||
" PROCEDURE test1(p IN numbersType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test2(p IN OUT NOCOPY numbersType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test3(p IN datesType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test4(p IN stringsType) IS BEGIN NULL; END;\n" +
|
||||
" PROCEDURE test5(p IN numbersType) IS BEGIN NULL; END;\n" +
|
||||
"END;";
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE nodb_testpack",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}) // after
|
||||
|
||||
it('43.4.1 maxArraySize property is ignored for BIND_IN', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: [1, 2, 3], maxArraySize: 1}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test1(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.4.2 maxArraySize is mandatory for BIND_INOUT', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3]}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-035:');
|
||||
// NJS-035: maxArraySize is required for IN OUT array bind
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.4.3 maxArraySize cannot smaller than the number of array elements', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 2}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-036:');
|
||||
// NJS-036: given Array is of size greater than maxArraySize property.
|
||||
should.not.exist(result);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.4.4 maxArraySize can be equal to the number of array elements', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 3}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
// known bug
|
||||
// The maximum safe integer in JavaScript is (2^53 - 1).
|
||||
it.skip('43.4.5 negative case: large value', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 987654321}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.4.6 negative case: < 0', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: -9}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
// NJS-007: invalid value for "maxArraySize"
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.4.7 negative case: = 0', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 0}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-035:');
|
||||
// NJS-035: maxArraySize is required for IN OUT array bind
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.4.8 negative case: assign a string to it', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: 'foobar'}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-008:');
|
||||
// NJS-008: invalid type for "maxArraySize"
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
it('43.4.9 negative case: NaN', function(done) {
|
||||
var bindvars = {
|
||||
p: {type: oracledb.NUMBER, dir: oracledb.BIND_INOUT, val: [1, 2, 3], maxArraySize: NaN}
|
||||
};
|
||||
connection.execute(
|
||||
"BEGIN nodb_testpack.test2(:p); END;",
|
||||
bindvars,
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
// NJS-007: invalid value for "maxArraySize"
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
}) // 43.4
|
||||
})
|
|
@ -1,716 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 44. plsqlBinding2.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing PL/SQL indexed tables (associative arrays).
|
||||
*
|
||||
* 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');
|
||||
|
||||
describe('44. plsqlBinding2.js', function() {
|
||||
|
||||
var connection = null;
|
||||
|
||||
beforeEach(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function createTab(callback) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_waveheight'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_waveheight (beach VARCHAR2(50), depth NUMBER) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
function createPkg(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE nodb_beachpkg IS\n" +
|
||||
" TYPE beachType IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;\n" +
|
||||
" TYPE depthType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE array_in(beaches IN beachType, depths IN depthType);\n" +
|
||||
" PROCEDURE array_out(beaches OUT beachType, depths OUT depthType); \n" +
|
||||
" PROCEDURE array_inout(beaches IN OUT beachType, depths IN OUT depthType); \n" +
|
||||
"END;";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY nodb_beachpkg IS \n" +
|
||||
" PROCEDURE array_in(beaches IN beachType, depths IN depthType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" IF beaches.COUNT <> depths.COUNT THEN \n" +
|
||||
" RAISE_APPLICATION_ERROR(-20000, 'Array lengths must match for this example.'); \n" +
|
||||
" END IF; \n" +
|
||||
" FORALL i IN INDICES OF beaches \n" +
|
||||
" INSERT INTO nodb_waveheight (beach, depth) VALUES (beaches(i), depths(i)); \n" +
|
||||
" END; \n" +
|
||||
" PROCEDURE array_out(beaches OUT beachType, depths OUT depthType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" SELECT beach, depth BULK COLLECT INTO beaches, depths FROM nodb_waveheight; \n" +
|
||||
" END; \n" +
|
||||
" PROCEDURE array_inout(beaches IN OUT beachType, depths IN OUT depthType) IS \n" +
|
||||
" BEGIN \n" +
|
||||
" IF beaches.COUNT <> depths.COUNT THEN \n" +
|
||||
" RAISE_APPLICATION_ERROR(-20001, 'Array lenghts must match for this example.'); \n" +
|
||||
" END IF; \n" +
|
||||
" FORALL i IN INDICES OF beaches \n" +
|
||||
" INSERT INTO nodb_waveheight (beach, depth) VALUES (beaches(i), depths(i)); \n" +
|
||||
" SELECT beach, depth BULK COLLECT INTO beaches, depths FROM nodb_waveheight ORDER BY 1; \n" +
|
||||
" END; \n " +
|
||||
"END;";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.commit(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
|
||||
afterEach(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_waveheight",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE nodb_beachpkg",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
}) // after
|
||||
|
||||
it('44.1 example case', function(done) {
|
||||
async.series([
|
||||
// Pass arrays of values to a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_in(:beach_in, :depth_in); END;",
|
||||
{
|
||||
beach_in: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: ["Malibu Beach", "Bondi Beach", "Waikiki Beach"] },
|
||||
depth_in: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: [45, 30, 67]
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
// Fetch arrays of values from a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_out(:beach_out, :depth_out); END;",
|
||||
{
|
||||
beach_out: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 },
|
||||
depth_out: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds.beach_out).should.eql([ 'Malibu Beach', 'Bondi Beach', 'Waikiki Beach' ]);
|
||||
(result.outBinds.depth_out).should.eql([45, 30, 67]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.rollback(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
// Return input arrays sorted by beach name
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_inout(:beach_inout, :depth_inout); END;",
|
||||
{
|
||||
beach_inout: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: ["Port Melbourne Beach", "Eighty Mile Beach", "Chesil Beach"],
|
||||
maxArraySize: 3},
|
||||
depth_inout: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [8, 3, 70],
|
||||
maxArraySize: 3}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
//console.log(result.outBinds);
|
||||
(result.outBinds.beach_inout).should.eql([ 'Chesil Beach', 'Eighty Mile Beach', 'Port Melbourne Beach' ]);
|
||||
(result.outBinds.depth_inout).should.eql([ 70, 3, 8 ]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // 44.1
|
||||
|
||||
it('44.2 example case binding by position', function(done) {
|
||||
async.series([
|
||||
// Pass arrays of values to a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_in(:1, :2); END;",
|
||||
[
|
||||
{ type: oracledb.STRING,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: ["Malibu Beach", "Bondi Beach", "Waikiki Beach"] },
|
||||
{ type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: [45, 30, 67]
|
||||
}
|
||||
],
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
// Fetch arrays of values from a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_out(:1, :2); END;",
|
||||
[
|
||||
{ type: oracledb.STRING,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 },
|
||||
{ type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 }
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds[0]).should.eql([ 'Malibu Beach', 'Bondi Beach', 'Waikiki Beach' ]);
|
||||
(result.outBinds[1]).should.eql([45, 30, 67]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.rollback(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
// Return input arrays sorted by beach name
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_inout(:1, :2); END;",
|
||||
[
|
||||
{ type: oracledb.STRING,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: ["Port Melbourne Beach", "Eighty Mile Beach", "Chesil Beach"],
|
||||
maxArraySize: 3},
|
||||
{ type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [8, 3, 70],
|
||||
maxArraySize: 3}
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds[0]).should.eql([ 'Chesil Beach', 'Eighty Mile Beach', 'Port Melbourne Beach' ]);
|
||||
(result.outBinds[1]).should.eql([ 70, 3, 8 ]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
|
||||
it.skip('44.3 default binding type and direction with binding by name', function(done) {
|
||||
async.series([
|
||||
// Pass arrays of values to a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_in(:beach_in, :depth_in); END;",
|
||||
{
|
||||
beach_in: { //type: oracledb.STRING,
|
||||
//dir: oracledb.BIND_IN,
|
||||
val: ["Malibu Beach", "Bondi Beach", "Waikiki Beach"] },
|
||||
depth_in: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: [45, 30, 67]
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
// Fetch arrays of values from a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_out(:beach_out, :depth_out); END;",
|
||||
{
|
||||
beach_out: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 },
|
||||
depth_out: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds.beach_out).should.eql([ 'Malibu Beach', 'Bondi Beach', 'Waikiki Beach' ]);
|
||||
(result.outBinds.depth_out).should.eql([45, 30, 67]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.rollback(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
// Return input arrays sorted by beach name
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_inout(:beach_inout, :depth_inout); END;",
|
||||
{
|
||||
beach_inout: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: ["Port Melbourne Beach", "Eighty Mile Beach", "Chesil Beach"],
|
||||
maxArraySize: 3},
|
||||
depth_inout: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [8, 3, 70],
|
||||
maxArraySize: 3}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
//console.log(result.outBinds);
|
||||
(result.outBinds.beach_inout).should.eql([ 'Chesil Beach', 'Eighty Mile Beach', 'Port Melbourne Beach' ]);
|
||||
(result.outBinds.depth_inout).should.eql([ 70, 3, 8 ]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // 44.3
|
||||
|
||||
it('44.4 default binding type and direction with binding by position', function(done) {
|
||||
async.series([
|
||||
// Pass arrays of values to a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_in(:1, :2); END;",
|
||||
[
|
||||
{ type: oracledb.STRING,
|
||||
// dir: oracledb.BIND_IN,
|
||||
val: ["Malibu Beach", "Bondi Beach", "Waikiki Beach"] },
|
||||
{ type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: [45, 30, 67]
|
||||
}
|
||||
],
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
// Fetch arrays of values from a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_out(:1, :2); END;",
|
||||
[
|
||||
{ type: oracledb.STRING,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 },
|
||||
{ type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 }
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds[0]).should.eql([ 'Malibu Beach', 'Bondi Beach', 'Waikiki Beach' ]);
|
||||
(result.outBinds[1]).should.eql([45, 30, 67]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.rollback(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
// Return input arrays sorted by beach name
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_inout(:1, :2); END;",
|
||||
[
|
||||
{ type: oracledb.STRING,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: ["Port Melbourne Beach", "Eighty Mile Beach", "Chesil Beach"],
|
||||
maxArraySize: 3},
|
||||
{ type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [8, 3, 70],
|
||||
maxArraySize: 3}
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds[0]).should.eql([ 'Chesil Beach', 'Eighty Mile Beach', 'Port Melbourne Beach' ]);
|
||||
(result.outBinds[1]).should.eql([ 70, 3, 8 ]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
|
||||
it('44.5 null elements in String and Number arrays', function(done) {
|
||||
async.series([
|
||||
// Pass arrays of values to a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_in(:beach_in, :depth_in); END;",
|
||||
{
|
||||
beach_in: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: ["Malibu Beach", "Bondi Beach", null, "Waikiki Beach", '', null] },
|
||||
depth_in: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: [null, null, 45, 30, 67, null, ]
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
// Fetch arrays of values from a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_out(:beach_out, :depth_out); END;",
|
||||
{
|
||||
beach_out: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 10 },
|
||||
depth_out: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 10 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds.beach_out).should.eql([ 'Malibu Beach', 'Bondi Beach', null, 'Waikiki Beach', null, null ]);
|
||||
(result.outBinds.depth_out).should.eql([ null, null, 45, 30, 67, null ]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.rollback(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
// Return input arrays sorted by beach name
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_inout(:beach_inout, :depth_inout); END;",
|
||||
{
|
||||
beach_inout: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: ["Port Melbourne Beach", "Eighty Mile Beach", '', "Chesil Beach", null, ''],
|
||||
maxArraySize: 10},
|
||||
depth_inout: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [null, 8, null, 3, null, 70],
|
||||
maxArraySize: 10}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
// console.log(result.outBinds);
|
||||
(result.outBinds.beach_inout).should.eql([ 'Chesil Beach', 'Eighty Mile Beach', 'Port Melbourne Beach', null, null, null ]);
|
||||
(result.outBinds.depth_inout).should.eql([ 3, 8, null, null, 70, null ]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // 44.5
|
||||
|
||||
it('44.6 empty array for BIND_IN and BIND_INOUT', function(done) {
|
||||
async.series([
|
||||
// Pass arrays of values to a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_in(:beach_in, :depth_in); END;",
|
||||
{
|
||||
beach_in: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: [] },
|
||||
depth_in: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: []
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-039:');
|
||||
// NJS-039: empty array is not allowed for IN bind
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
// Return input arrays sorted by beach name
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_inout(:beach_inout, :depth_inout); END;",
|
||||
{
|
||||
beach_inout: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [],
|
||||
maxArraySize: 0
|
||||
},
|
||||
depth_inout: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [],
|
||||
maxArraySize: 3}
|
||||
},
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-039:');
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // 44.6
|
||||
|
||||
it('44.7 empty array for BIND_OUT', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE\n" +
|
||||
"oracledb_testpack\n" +
|
||||
"IS\n" +
|
||||
" TYPE stringsType IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;\n" +
|
||||
" PROCEDURE test(p OUT stringsType);\n" +
|
||||
"END;";
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
|
||||
"oracledb_testpack\n" +
|
||||
"IS\n" +
|
||||
" PROCEDURE test(p OUT stringsType) IS BEGIN NULL; END;\n" +
|
||||
"END;";
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN oracledb_testpack.test(:0); END;",
|
||||
[
|
||||
{type: oracledb.STRING, dir: oracledb.BIND_OUT, maxArraySize: 1}
|
||||
],
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.outBinds[0].should.eql([]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP PACKAGE oracledb_testpack",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // 44.7
|
||||
|
||||
it.skip('44.8 maxSize option applies to each elements of an array', function(done) {
|
||||
async.series([
|
||||
// Pass arrays of values to a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_in(:beach_in, :depth_in); END;",
|
||||
{
|
||||
beach_in: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: ["Malibu", "Bondi", "Waikiki"] },
|
||||
depth_in: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_IN,
|
||||
val: [45, 30, 67]
|
||||
}
|
||||
},
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
// Fetch arrays of values from a PL/SQL procedure
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_out(:beach_out, :depth_out); END;",
|
||||
{
|
||||
beach_out: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3,
|
||||
maxSize: 6 },
|
||||
depth_out: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_OUT,
|
||||
maxArraySize: 3 }
|
||||
},
|
||||
function(err, result) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-06502');
|
||||
// ORA-06502: PL/SQL: numeric or value error: host bind array too small
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
connection.rollback(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
// Return input arrays sorted by beach name
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"BEGIN nodb_beachpkg.array_inout(:beach_inout, :depth_inout); END;",
|
||||
{
|
||||
beach_inout: { type: oracledb.STRING,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: ["Port Melbourne Beach", "Eighty Mile Beach", "Chesil Beach"],
|
||||
maxArraySize: 3,
|
||||
maxSize : 5},
|
||||
depth_inout: { type: oracledb.NUMBER,
|
||||
dir: oracledb.BIND_INOUT,
|
||||
val: [8, 3, 70],
|
||||
maxArraySize: 3}
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
//console.log(result.outBinds);
|
||||
(result.outBinds.beach_inout).should.eql([ 'Chesil Beach', 'Eighty Mile Beach', 'Port Melbourne Beach' ]);
|
||||
(result.outBinds.depth_inout).should.eql([ 70, 3, 8 ]);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}) // 44.8
|
||||
|
||||
})
|
328
test/pool.js
328
test/pool.js
|
@ -34,46 +34,57 @@
|
|||
'use strict';
|
||||
|
||||
var oracledb = require('oracledb');
|
||||
var async = require('async');
|
||||
var async = require('async');
|
||||
var should = require('should');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('2. pool.js', function() {
|
||||
|
||||
describe('2.1 default values', function() {
|
||||
it('2.1.1 set properties to default values if not explicitly specified', function(done) {
|
||||
oracledb.createPool(dbConfig, function(err, pool) {
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
describe('2.1 default settting', function() {
|
||||
|
||||
var defaultMin = 0;
|
||||
var defaultMax = 4;
|
||||
var defaultIncrement = 1;
|
||||
var defaultTimeout = 60;
|
||||
var defaultStmtCacheSize = 30;
|
||||
it('2.1.1 testing default values of pool properties', function(done) {
|
||||
|
||||
pool.poolMin.should.be.exactly(defaultMin).and.be.a.Number();
|
||||
pool.poolMax.should.be.exactly(defaultMax).and.be.a.Number();
|
||||
pool.poolIncrement.should.be.exactly(defaultIncrement).and.be.a.Number();
|
||||
pool.poolTimeout.should.be.exactly(defaultTimeout).and.be.a.Number();
|
||||
pool.stmtCacheSize.should.be.exactly(defaultStmtCacheSize).and.be.a.Number();
|
||||
|
||||
pool.connectionsOpen.should.equal(0);
|
||||
pool.connectionsInUse.should.equal(0);
|
||||
|
||||
pool.terminate(function(err){
|
||||
oracledb.createPool(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, pool) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
pool.should.be.ok();
|
||||
|
||||
var defaultMin = 0;
|
||||
var defaultMax = 4;
|
||||
var defaultIncrement = 1;
|
||||
var defaultTimeout = 60;
|
||||
var defaultStmtCacheSize = 30;
|
||||
|
||||
pool.poolMin.should.be.exactly(defaultMin).and.be.a.Number();
|
||||
pool.poolMax.should.be.exactly(defaultMax).and.be.a.Number();
|
||||
pool.poolIncrement.should.be.exactly(defaultIncrement).and.be.a.Number();
|
||||
pool.poolTimeout.should.be.exactly(defaultTimeout).and.be.a.Number();
|
||||
pool.stmtCacheSize.should.be.exactly(defaultStmtCacheSize).and.be.a.Number();
|
||||
|
||||
pool.connectionsOpen.should.equal(0);
|
||||
pool.connectionsInUse.should.equal(0);
|
||||
|
||||
pool.terminate(function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('2.2 poolMin', function() {
|
||||
|
||||
describe('2.2 poolMin', function(){
|
||||
it('2.2.1 poolMin cannot be a negative number', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -86,15 +97,16 @@ describe('2. pool.js', function() {
|
|||
function(err, pool){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.2.2 poolMin must be a Number', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -107,15 +119,16 @@ describe('2. pool.js', function() {
|
|||
function(err, pool){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.2.3 poolMin cannot equal to poolMax', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -126,19 +139,18 @@ describe('2. pool.js', function() {
|
|||
stmtCacheSize : 23
|
||||
},
|
||||
function(err, pool){
|
||||
if(!dbConfig.externalAuth){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
}
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.2.4 poolMin cannot greater than poolMax', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -149,19 +161,18 @@ describe('2. pool.js', function() {
|
|||
stmtCacheSize : 23
|
||||
},
|
||||
function(err, pool){
|
||||
if(!dbConfig.externalAuth){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
}
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.2.5 (poolMin + poolIncrement) cannot greater than poolMax', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -172,19 +183,19 @@ describe('2. pool.js', function() {
|
|||
stmtCacheSize : 23
|
||||
},
|
||||
function(err, pool){
|
||||
if(!dbConfig.externalAuth){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
}
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.2.6 (poolMin + poolIncrement) can equal to poolMax', function(done) {
|
||||
|
||||
it('2.2.6 (poolMin + poolIncrement) can equal to poolMax', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -196,12 +207,8 @@ describe('2. pool.js', function() {
|
|||
},
|
||||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
if(dbConfig.externalAuth){
|
||||
pool.connectionsOpen.should.be.exactly(0);
|
||||
} else {
|
||||
pool.connectionsOpen.should.be.exactly(pool.poolMin);
|
||||
}
|
||||
pool.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(pool.poolMin);
|
||||
pool.connectionsInUse.should.be.exactly(0);
|
||||
|
||||
pool.terminate(function(err){
|
||||
|
@ -211,16 +218,15 @@ describe('2. pool.js', function() {
|
|||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
}); // 2.2
|
||||
|
||||
describe('2.3 poolMax', function(){
|
||||
|
||||
it('2.3.1 poolMax cannot be a negative value', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -233,15 +239,16 @@ describe('2. pool.js', function() {
|
|||
function(err, pool){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.3.2 poolMax cannot be 0', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -254,15 +261,16 @@ describe('2. pool.js', function() {
|
|||
function(err, pool){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.3.3 poolMax must be a number', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -275,15 +283,16 @@ describe('2. pool.js', function() {
|
|||
function(err, pool){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-008:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.3.4 poolMax limits the pool capacity', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -296,23 +305,19 @@ describe('2. pool.js', function() {
|
|||
},
|
||||
function(err, pool) {
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
if(!dbConfig.externalAuth){
|
||||
pool.connectionsOpen.should.be.exactly(1);
|
||||
} else {
|
||||
pool.connectionsOpen.should.be.exactly(0);
|
||||
}
|
||||
pool.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(1);
|
||||
pool.connectionsInUse.should.be.exactly(0);
|
||||
|
||||
pool.getConnection( function(err, conn1){
|
||||
should.not.exist(err);
|
||||
conn1.should.be.ok;
|
||||
conn1.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(1);
|
||||
pool.connectionsInUse.should.be.exactly(1);
|
||||
|
||||
pool.getConnection( function(err, conn2){
|
||||
should.not.exist(err);
|
||||
conn2.should.be.ok;
|
||||
conn2.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(2);
|
||||
pool.connectionsInUse.should.be.exactly(2);
|
||||
|
||||
|
@ -321,6 +326,8 @@ describe('2. pool.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24418:');
|
||||
|
||||
should.not.exist(conn3);
|
||||
|
||||
conn2.release( function(err){
|
||||
should.not.exist(err);
|
||||
conn1.release( function(err){
|
||||
|
@ -337,15 +344,14 @@ describe('2. pool.js', function() {
|
|||
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
}); // 2.3
|
||||
|
||||
describe('2.4 poolIncrement', function(){
|
||||
it('2.4.1 poolIncrement cannot be a negative value', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -359,15 +365,16 @@ describe('2. pool.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
// NJS-007: invalid value for
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.4.2 poolIncrement cannot be 0', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -378,17 +385,18 @@ describe('2. pool.js', function() {
|
|||
stmtCacheSize : 23
|
||||
},
|
||||
function(err, pool){
|
||||
should.exist(err); // Bug 20774464 - Occurs on External Authentication
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24413:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.4.3 poolIncrement must be a Number', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -401,15 +409,16 @@ describe('2. pool.js', function() {
|
|||
function(err, pool){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-008:');
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.4.4 the amount of open connections equals to poolMax when (connectionsOpen + poolIncrement) > poolMax', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -421,30 +430,30 @@ describe('2. pool.js', function() {
|
|||
},
|
||||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
pool.should.be.ok();
|
||||
|
||||
pool.getConnection( function(err, conn1){
|
||||
should.not.exist(err);
|
||||
conn1.should.be.ok;
|
||||
conn1.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(1);
|
||||
pool.connectionsInUse.should.be.exactly(1);
|
||||
|
||||
pool.getConnection( function(err, conn2){
|
||||
should.not.exist(err);
|
||||
conn2.should.be.ok;
|
||||
pool.connectionsOpen.should.be.exactly(3); // Bug 20774464 - Occurs on External Authentication
|
||||
conn2.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(3);
|
||||
pool.connectionsInUse.should.be.exactly(2);
|
||||
|
||||
pool.getConnection( function(err, conn3){
|
||||
should.not.exist(err);
|
||||
conn3.should.be.ok;
|
||||
conn3.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(3);
|
||||
pool.connectionsInUse.should.be.exactly(3);
|
||||
|
||||
// (connectionsOpen + poolIncrement) > poolMax
|
||||
pool.getConnection( function(err, conn4){
|
||||
should.not.exist(err);
|
||||
conn4.should.be.ok;
|
||||
conn4.should.be.ok();
|
||||
pool.connectionsOpen.should.be.exactly(4);
|
||||
pool.connectionsOpen.should.be.exactly(4);
|
||||
conn4.release( function(err){
|
||||
|
@ -469,15 +478,15 @@ describe('2. pool.js', function() {
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
}); // 2.4
|
||||
|
||||
describe('2.5 poolTimeout', function() {
|
||||
|
||||
describe('2.5 poolTimeout', function(){
|
||||
it('2.5.1 poolTimeout cannot be a negative number', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -491,15 +500,16 @@ describe('2. pool.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
// NJS-007: invalid value for
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.5.2 poolTimeout can be 0, which disables timeout feature', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -511,7 +521,7 @@ describe('2. pool.js', function() {
|
|||
},
|
||||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
pool.should.be.ok();
|
||||
|
||||
pool.terminate(function(err){
|
||||
should.not.exist(err);
|
||||
|
@ -519,12 +529,11 @@ describe('2. pool.js', function() {
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.5.3 poolTimeout must be a number', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -538,18 +547,20 @@ describe('2. pool.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
// NJS-007: invalid value for
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('2.6 stmtCacheSize', function() {
|
||||
|
||||
describe('2.6 stmtCacheSize', function(){
|
||||
it('2.6.1 stmtCacheSize cannot be a negative value', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -563,15 +574,16 @@ describe('2. pool.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
// NJS-007: invalid value for
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.6.2 stmtCacheSize can be 0', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -583,19 +595,18 @@ describe('2. pool.js', function() {
|
|||
},
|
||||
function(err, pool){
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok;
|
||||
pool.should.be.ok();
|
||||
pool.terminate(function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('2.6.3 stmtCacheSize must be a Number', function(done){
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -609,12 +620,14 @@ describe('2. pool.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-007:');
|
||||
// NJS-007: invalid value for
|
||||
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe('2.7 getConnection', function(){
|
||||
var pool1;
|
||||
|
@ -622,7 +635,6 @@ describe('2. pool.js', function() {
|
|||
beforeEach('get pool ready', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -639,24 +651,7 @@ describe('2. pool.js', function() {
|
|||
);
|
||||
});
|
||||
|
||||
// Skipping this test because assertions were added to the JS layer for all
|
||||
// public methods. This now throws NJS-009: invalid number of parameters.
|
||||
it.skip('2.7.1 throws error if called after pool is terminated and a callback is not provided', function(done) {
|
||||
pool1.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
try {
|
||||
pool1.getConnection();
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-002:');
|
||||
// NJS-002: invalid pool
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('2.7.2 passes error in callback if called after pool is terminated and a callback is provided', function(done) {
|
||||
it('2.7.1 passes error in callback if called after pool is terminated and a callback is provided', function(done) {
|
||||
pool1.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
|
@ -664,10 +659,13 @@ describe('2. pool.js', function() {
|
|||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-002:');
|
||||
// NJS-002: invalid pool
|
||||
|
||||
should.not.exist(conn);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('2.8 connection request queue (basic functionality)', function(){
|
||||
|
@ -693,7 +691,6 @@ describe('2. pool.js', function() {
|
|||
it('2.8.1 generates ORA-24418 when calling getConnection if queueing is disabled', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -712,10 +709,11 @@ describe('2. pool.js', function() {
|
|||
pool.getConnection(function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.execute(getBlockingSql(3), function(err, result) {
|
||||
conn.execute(getBlockingSql(3), function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
@ -726,13 +724,17 @@ describe('2. pool.js', function() {
|
|||
setTimeout(function() {
|
||||
pool.getConnection(function(err, conn) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24418: Cannot open further sessions');
|
||||
// ORA-24418: Cannot open further sessions
|
||||
(err.message).should.startWith('ORA-24418:');
|
||||
should.not.exist(conn);
|
||||
cb();
|
||||
});
|
||||
}, 200);
|
||||
}
|
||||
],
|
||||
function(err, results){
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
|
||||
pool.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
|
@ -746,7 +748,6 @@ describe('2. pool.js', function() {
|
|||
it('2.8.2 does not generate ORA-24418 when calling getConnection if queueing is enabled', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -765,10 +766,11 @@ describe('2. pool.js', function() {
|
|||
pool.getConnection(function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.execute(getBlockingSql(3), function(err, result) {
|
||||
conn.execute(getBlockingSql(3), function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
@ -789,7 +791,8 @@ describe('2. pool.js', function() {
|
|||
}, 100);
|
||||
}
|
||||
],
|
||||
function(err, results){
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
pool.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
|
@ -803,7 +806,6 @@ describe('2. pool.js', function() {
|
|||
it('2.8.3 generates NJS-040 if request is queued and queueTimeout expires', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -823,10 +825,11 @@ describe('2. pool.js', function() {
|
|||
pool.getConnection(function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.execute(getBlockingSql(4), function(err, result) {
|
||||
conn.execute(getBlockingSql(4), function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
@ -838,12 +841,15 @@ describe('2. pool.js', function() {
|
|||
pool.getConnection(function(err, conn) {
|
||||
should.exist(err);
|
||||
(err.message).should.equal('NJS-040: connection request timeout');
|
||||
|
||||
should.not.exist(conn);
|
||||
cb();
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
],
|
||||
function(err, results){
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
pool.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
|
@ -857,7 +863,6 @@ describe('2. pool.js', function() {
|
|||
it('2.8.4 does not generate NJS-040 if request is queued for less time than queueTimeout', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -877,10 +882,11 @@ describe('2. pool.js', function() {
|
|||
pool.getConnection(function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.execute(getBlockingSql(4), function(err, result) {
|
||||
conn.execute(getBlockingSql(4), function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
@ -893,13 +899,15 @@ describe('2. pool.js', function() {
|
|||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
}, 100);
|
||||
}
|
||||
],
|
||||
function(err, results){
|
||||
function(err){
|
||||
should.not.exist(err);
|
||||
pool.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
|
@ -912,10 +920,9 @@ describe('2. pool.js', function() {
|
|||
});
|
||||
|
||||
describe('2.9 connection request queue (_enableStats & _logStats functionality)', function(){
|
||||
it('2.9.1 works after the pool as been terminated', function(done) {
|
||||
it('2.9.1 does not works after the pool has been terminated', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -932,7 +939,7 @@ describe('2. pool.js', function() {
|
|||
pool.getConnection(function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.execute('select 1 from dual', function(err, result) {
|
||||
conn.execute('select 1 from dual', function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
conn.release(function(err) {
|
||||
|
@ -944,7 +951,8 @@ describe('2. pool.js', function() {
|
|||
try {
|
||||
pool._logStats();
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
should.exist(err);
|
||||
(err.message).should.startWith("NJS-002:"); // NJS-002: invalid pool
|
||||
}
|
||||
|
||||
done();
|
||||
|
@ -961,7 +969,6 @@ describe('2. pool.js', function() {
|
|||
it('2.10.1 close can be used as an alternative to release', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -981,5 +988,28 @@ describe('2. pool.js', function() {
|
|||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}); // 2.10
|
||||
|
||||
describe.skip('2.11 invalid credentials', function() {
|
||||
|
||||
it('2.11.1 cannot get connections with invalid credentials', function(done) {
|
||||
|
||||
oracledb.createPool(
|
||||
{
|
||||
user: 'notexist',
|
||||
password: 'nopass',
|
||||
connectString: 'inst1'
|
||||
},
|
||||
function(err, pool) {
|
||||
should.exist(err);
|
||||
console.log(err.message);
|
||||
should.not.exist(pool);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
}); // 2.11
|
||||
|
||||
});
|
||||
|
|
|
@ -122,15 +122,14 @@ describe('51. poolClose.js', function(){
|
|||
function(err, pool) {
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok();
|
||||
|
||||
pool.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
pool.terminate(function(err) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "NJS-002: invalid pool");
|
||||
});
|
||||
|
||||
should.throws(
|
||||
function() {
|
||||
pool.terminate(function() {});
|
||||
},
|
||||
/NJS-002: invalid pool/
|
||||
);
|
||||
done();
|
||||
}); // terminate()
|
||||
}
|
||||
|
@ -143,15 +142,14 @@ describe('51. poolClose.js', function(){
|
|||
function(err, pool) {
|
||||
should.not.exist(err);
|
||||
pool.should.be.ok();
|
||||
|
||||
pool.close(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
pool.close(function(err) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "NJS-002: invalid pool");
|
||||
});
|
||||
|
||||
should.throws(
|
||||
function() {
|
||||
pool.close(function() {});
|
||||
},
|
||||
/NJS-002: invalid pool/
|
||||
);
|
||||
done();
|
||||
}); // terminate()
|
||||
}
|
||||
|
@ -218,11 +216,13 @@ describe('51. poolClose.js', function(){
|
|||
});
|
||||
},
|
||||
function close2(cb) {
|
||||
conn.close(function(err) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, 'NJS-003: invalid connection');
|
||||
cb();
|
||||
});
|
||||
should.throws(
|
||||
function() {
|
||||
conn.close(function() {});
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
cb();
|
||||
},
|
||||
function(cb) {
|
||||
pool.terminate(function(err) {
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 53. poolValidityAfterFailingTernimate.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Pool should be available after failing termination.
|
||||
*
|
||||
* 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 dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('53. poolValidityAfterFailingTernimate.js', function() {
|
||||
|
||||
it('pool should be available after failing terminate', function(done) {
|
||||
oracledb.createPool(
|
||||
dbConfig,
|
||||
function(err, pool) {
|
||||
should.not.exist(err);
|
||||
pool.getConnection( function(err, connection) {
|
||||
should.not.exist(err);
|
||||
pool.terminate(
|
||||
function(err){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24422:');
|
||||
|
||||
// console.log("Before release, Open connections: " + pool.connectionsOpen);
|
||||
connection.release( function(err){
|
||||
should.not.exist(err);
|
||||
|
||||
// console.log("Open connections: " + pool.connectionsOpen);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
|
@ -35,7 +35,6 @@
|
|||
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
// Need to skip these tests if Promises are not supported
|
||||
|
@ -50,7 +49,7 @@ describe('16. promises.js', function(){
|
|||
|
||||
promise
|
||||
.then(function(conn) {
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
conn.release(function(err) {
|
||||
if (err)
|
||||
return done(err);
|
||||
|
@ -59,9 +58,10 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.2 returns a promise from oracledb.createPool', function(done) {
|
||||
var promise = oracledb.createPool(dbConfig);
|
||||
|
@ -70,7 +70,7 @@ describe('16. promises.js', function(){
|
|||
|
||||
promise
|
||||
.then(function(pool) {
|
||||
pool.should.be.ok;
|
||||
pool.should.be.ok();
|
||||
pool.terminate(function(err) {
|
||||
if (err)
|
||||
return done(err);
|
||||
|
@ -79,14 +79,15 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.3 returns a promise from pool.terminate', function(done) {
|
||||
oracledb.createPool(dbConfig)
|
||||
.then(function(pool) {
|
||||
pool.should.be.ok;
|
||||
pool.should.be.ok();
|
||||
var promise = pool.terminate();
|
||||
promise.should.be.an.instanceof(oracledb.Promise);
|
||||
return promise;
|
||||
|
@ -95,14 +96,15 @@ describe('16. promises.js', function(){
|
|||
return done();
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.4 returns a promise from pool.getConnection', function(done) {
|
||||
oracledb.createPool(dbConfig)
|
||||
.then(function(pool) {
|
||||
pool.should.be.ok;
|
||||
pool.should.be.ok();
|
||||
var getConnPromise = pool.getConnection();
|
||||
getConnPromise.should.be.an.instanceof(oracledb.Promise);
|
||||
getConnPromise
|
||||
|
@ -123,14 +125,15 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.5 returns a promise from connection.release', function(done) {
|
||||
oracledb.getConnection(dbConfig)
|
||||
.then(function(conn) {
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
var promise = conn.release();
|
||||
promise.should.be.an.instanceof(oracledb.Promise);
|
||||
return promise;
|
||||
|
@ -139,14 +142,15 @@ describe('16. promises.js', function(){
|
|||
return done();
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.6 returns a promise from connection.execute', function(done) {
|
||||
oracledb.getConnection(dbConfig)
|
||||
.then(function(conn) {
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
var executePromise = conn.execute('select 1 from dual');
|
||||
executePromise.should.be.an.instanceof(oracledb.Promise);
|
||||
return executePromise
|
||||
|
@ -158,15 +162,16 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.7 returns a promise from connection.commit', function(done) {
|
||||
oracledb.getConnection(dbConfig)
|
||||
.then(function(conn) {
|
||||
var commitPromise;
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
commitPromise = conn.commit();
|
||||
commitPromise.should.be.an.instanceof(oracledb.Promise);
|
||||
|
||||
|
@ -177,15 +182,16 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.8 returns a promise form connection.rollback', function(done) {
|
||||
oracledb.getConnection(dbConfig)
|
||||
.then(function(conn) {
|
||||
var rollbackPromise;
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
rollbackPromise = conn.rollback();
|
||||
rollbackPromise.should.be.an.instanceof(oracledb.Promise);
|
||||
|
||||
|
@ -196,14 +202,15 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.9 returns a promise from resultSet.close', function(done) {
|
||||
oracledb.getConnection(dbConfig)
|
||||
.then(function(conn) {
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
|
||||
return conn.execute('select 1 from dual', [], {resultSet: true})
|
||||
.then(function(result) {
|
||||
|
@ -219,9 +226,10 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('16.10 returns a promise from resultSet.getRow', function(done) {
|
||||
|
||||
|
@ -229,7 +237,7 @@ describe('16. promises.js', function(){
|
|||
return resultSet.close()
|
||||
.then(function() {
|
||||
conn.release();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function processResultSet(conn, resultSet) {
|
||||
|
@ -264,7 +272,7 @@ describe('16. promises.js', function(){
|
|||
|
||||
oracledb.getConnection(dbConfig)
|
||||
.then(function(conn) {
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
|
||||
return conn.execute('select 1 from dual', [], {resultSet: true})
|
||||
.then(function(result) {
|
||||
|
@ -275,10 +283,11 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
});
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
|
||||
}) // 16.10
|
||||
}); // 16.10
|
||||
|
||||
it('16.11 returns a promise from resultSet.getRows', function(done) {
|
||||
function finishProcessing(conn, resultSet) {
|
||||
|
@ -321,7 +330,7 @@ describe('16. promises.js', function(){
|
|||
|
||||
oracledb.getConnection(dbConfig)
|
||||
.then(function(conn) {
|
||||
conn.should.be.ok;
|
||||
conn.should.be.ok();
|
||||
|
||||
return conn.execute('select 1 from dual union select 2 from dual', [], {resultSet: true})
|
||||
.then(function(result) {
|
||||
|
@ -332,8 +341,9 @@ describe('16. promises.js', function(){
|
|||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
return done(err);
|
||||
should.not.exist(err);
|
||||
return done();
|
||||
});
|
||||
}) // 16.11
|
||||
}); // 16.11
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
'use strict';
|
||||
|
||||
var oracledb = require('oracledb');
|
||||
var fs = require('fs');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
@ -48,23 +47,25 @@ describe('58. properties.js', function() {
|
|||
var defaultValues = {};
|
||||
|
||||
before('save the default values', function() {
|
||||
defaultValues.poolMin = oracledb.poolMin;
|
||||
defaultValues.poolMax = oracledb.poolMax;
|
||||
defaultValues.poolIncrement = oracledb.poolIncrement;
|
||||
defaultValues.poolTimeout = oracledb.poolTimeout;
|
||||
defaultValues.maxRows = oracledb.maxRows;
|
||||
defaultValues.prefetchRows = oracledb.prefetchRows;
|
||||
defaultValues.autoCommit = oracledb.autoCommit;
|
||||
defaultValues.version = oracledb.version;
|
||||
defaultValues.connClass = oracledb.connClass;
|
||||
defaultValues.externalAuth = oracledb.externalAuth;
|
||||
defaultValues.fetchAsString = oracledb.fetchAsString;
|
||||
defaultValues.outFormat = oracledb.outFormat;
|
||||
defaultValues.lobPrefetchSize = oracledb.lobPrefetchSize;
|
||||
defaultValues.queueRequests = oracledb.queueRequests;
|
||||
defaultValues.queueTimeout = oracledb.queueTimeout;
|
||||
defaultValues.stmtCacheSize = oracledb.stmtCacheSize;
|
||||
})
|
||||
defaultValues.poolMin = oracledb.poolMin;
|
||||
defaultValues.poolMax = oracledb.poolMax;
|
||||
defaultValues.poolIncrement = oracledb.poolIncrement;
|
||||
defaultValues.poolTimeout = oracledb.poolTimeout;
|
||||
defaultValues.maxRows = oracledb.maxRows;
|
||||
defaultValues.prefetchRows = oracledb.prefetchRows;
|
||||
defaultValues.autoCommit = oracledb.autoCommit;
|
||||
defaultValues.version = oracledb.version;
|
||||
defaultValues.connectionClass = oracledb.connectionClass;
|
||||
defaultValues.externalAuth = oracledb.externalAuth;
|
||||
defaultValues.fetchAsString = oracledb.fetchAsString;
|
||||
defaultValues.outFormat = oracledb.outFormat;
|
||||
defaultValues.lobPrefetchSize = oracledb.lobPrefetchSize;
|
||||
defaultValues.queueRequests = oracledb.queueRequests;
|
||||
defaultValues.queueTimeout = oracledb.queueTimeout;
|
||||
defaultValues.stmtCacheSize = oracledb.stmtCacheSize;
|
||||
defaultValues.poolPingInterval = oracledb.poolPingInterval;
|
||||
defaultValues.fetchAsBuffer = oracledb.fetchAsBuffer;
|
||||
});
|
||||
|
||||
after('restore the values', function() {
|
||||
oracledb.poolMin = defaultValues.poolMin;
|
||||
|
@ -83,7 +84,9 @@ describe('58. properties.js', function() {
|
|||
oracledb.queueRequests = defaultValues.queueRequests;
|
||||
oracledb.queueTimeout = defaultValues.queueTimeout;
|
||||
oracledb.stmtCacheSize = defaultValues.stmtCacheSize;
|
||||
})
|
||||
oracledb.poolPingInterval = defaultValues.poolPingInterval;
|
||||
oracledb.fetchAsBuffer = defaultValues.fetchAsBuffer;
|
||||
});
|
||||
|
||||
it('58.1.1 poolMin', function() {
|
||||
var t = oracledb.poolMin;
|
||||
|
@ -91,7 +94,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.poolMin);
|
||||
(oracledb.poolMin).should.eql(defaultValues.poolMin + 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.2 poolMax', function() {
|
||||
var t = oracledb.poolMax;
|
||||
|
@ -99,7 +102,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.poolMax);
|
||||
(oracledb.poolMax).should.eql(defaultValues.poolMax + 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.3 poolIncrement', function() {
|
||||
var t = oracledb.poolIncrement;
|
||||
|
@ -107,7 +110,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.poolIncrement);
|
||||
(oracledb.poolIncrement).should.eql(defaultValues.poolIncrement + 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.4 poolTimeout', function() {
|
||||
var t = oracledb.poolTimeout;
|
||||
|
@ -115,7 +118,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.poolTimeout);
|
||||
(oracledb.poolTimeout).should.eql(defaultValues.poolTimeout + 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.5 maxRows', function() {
|
||||
var t = oracledb.maxRows;
|
||||
|
@ -123,7 +126,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.maxRows);
|
||||
(oracledb.maxRows).should.eql(defaultValues.maxRows + 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.6 prefetchRows', function() {
|
||||
var t = oracledb.prefetchRows;
|
||||
|
@ -131,7 +134,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.prefetchRows);
|
||||
(oracledb.prefetchRows).should.eql(defaultValues.prefetchRows + 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.7 autoCommit', function() {
|
||||
var t = oracledb.autoCommit;
|
||||
|
@ -140,24 +143,26 @@ describe('58. properties.js', function() {
|
|||
t.should.eql(defaultValues.autoCommit);
|
||||
(oracledb.autoCommit).should.eql( !defaultValues.autoCommit );
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.8 version (read-only)', function() {
|
||||
(oracledb.version).should.be.a.Number();
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.version = 5;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
try {
|
||||
oracledb.version = 5;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
// console.log(err.message);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
it('58.1.9 connectionClass', function() {
|
||||
var t = oracledb.connectionClass;
|
||||
oracledb.connectionClass = 'DEVPOOL';
|
||||
var cclass = oracledb.connectionClass;
|
||||
|
||||
it('58.1.9 connClass', function() {
|
||||
oracledb.connClass = "cc";
|
||||
(oracledb.connClass).should.be.a.String();
|
||||
})
|
||||
should.equal(t, '');
|
||||
should.strictEqual(cclass, 'DEVPOOL');
|
||||
});
|
||||
|
||||
it('58.1.10 externalAuth', function() {
|
||||
var t = oracledb.externalAuth;
|
||||
|
@ -165,7 +170,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.externalAuth);
|
||||
(oracledb.externalAuth).should.eql( !defaultValues.externalAuth );
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.11 fetchAsString', function() {
|
||||
var t = oracledb.fetchAsString;
|
||||
|
@ -173,7 +178,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.fetchAsString);
|
||||
(oracledb.fetchAsString).should.not.eql(defaultValues.fetchAsString);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.12 outFormat', function() {
|
||||
var t = oracledb.outFormat;
|
||||
|
@ -181,7 +186,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(oracledb.ARRAY);
|
||||
(oracledb.outFormat).should.not.eql(defaultValues.outFormat);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.13 lobPrefetchSize', function() {
|
||||
var t = oracledb.lobPrefetchSize;
|
||||
|
@ -189,7 +194,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
t.should.eql(defaultValues.lobPrefetchSize);
|
||||
(oracledb.lobPrefetchSize).should.eql(defaultValues.lobPrefetchSize + 1);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.14 oracleClientVersion (read-only)', function () {
|
||||
var t = oracledb.oracleClientVersion ;
|
||||
|
@ -209,7 +214,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
should.equal(t, true);
|
||||
should.notEqual(t, oracledb.queueRequests);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.16 queueTimeout', function() {
|
||||
var t = oracledb.queueTimeout;
|
||||
|
@ -217,7 +222,7 @@ describe('58. properties.js', function() {
|
|||
|
||||
should.equal(t, defaultValues.queueTimeout);
|
||||
should.notEqual(oracledb.queueTimeout, defaultValues.queueTimeout);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.1.17 stmtCacheSize', function() {
|
||||
var t = oracledb.stmtCacheSize;
|
||||
|
@ -225,158 +230,233 @@ describe('58. properties.js', function() {
|
|||
|
||||
should.equal(t, defaultValues.stmtCacheSize);
|
||||
should.notEqual(oracledb.stmtCacheSize, defaultValues.stmtCacheSize);
|
||||
})
|
||||
});
|
||||
|
||||
}) // 58.1
|
||||
it('58.1.18 poolPingInterval', function() {
|
||||
var t = oracledb.poolPingInterval;
|
||||
oracledb.poolPingInterval = t + 100;
|
||||
|
||||
should.equal(t, defaultValues.poolPingInterval);
|
||||
should.notEqual(oracledb.poolPingInterval, defaultValues.poolPingInterval);
|
||||
});
|
||||
|
||||
it('58.1.19 fetchAsBuffer', function() {
|
||||
var t = oracledb.fetchAsBuffer;
|
||||
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
|
||||
|
||||
t.should.eql(defaultValues.fetchAsBuffer);
|
||||
(oracledb.fetchAsBuffer).should.not.eql(defaultValues.fetchAsBuffer);
|
||||
});
|
||||
|
||||
it('58.1.20 Negative - connectionClass ', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.connectionClass = NaN;
|
||||
},
|
||||
/NJS-004: invalid value for property [\w]/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.1.21 Negative - autoCommit', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.autoCommit = 2017;
|
||||
},
|
||||
/NJS-004: invalid value for property [\w]/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.1.22 Negative - outFormat', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.outFormat = 'abc';
|
||||
},
|
||||
/NJS-004: invalid value for property [\w]/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('58.1.23 Negative - externalAuth', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
oracledb.externalAuth = 2017;
|
||||
},
|
||||
/NJS-004: invalid value for property [\w]/
|
||||
);
|
||||
});
|
||||
|
||||
}); // 58.1
|
||||
|
||||
describe('58.2 Pool Class', function() {
|
||||
var pool = null;
|
||||
|
||||
before(function(done) {
|
||||
oracledb.createPool(
|
||||
dbConfig,
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, p) {
|
||||
should.not.exist(err);
|
||||
pool = p;
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
pool.terminate(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('58.2.1 poolMin', function() {
|
||||
var t = pool.poolMin;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.poolMin = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.poolMin = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.2.2 poolMax', function() {
|
||||
var t = pool.poolMax;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.poolMax = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.poolMax = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.2.3 poolIncrement', function() {
|
||||
var t = pool.poolIncrement;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.poolIncrement = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.poolIncrement = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.2.4 poolTimeout', function() {
|
||||
var t = pool.poolTimeout;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.poolTimeout = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.poolTimeout = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.2.5 stmtCacheSize', function() {
|
||||
var t = pool.stmtCacheSize;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.stmtCacheSize = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.stmtCacheSize = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.2.6 connectionsInUse', function() {
|
||||
var t = pool.connectionsInUse;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.connectionsInUse = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.connectionsInUse = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.2.7 connectionsOpen', function() {
|
||||
var t = pool.connectionsOpen;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.connectionsOpen = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.connectionsOpen = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('58.2.8 queueRequests', function() {
|
||||
it('58.2.8 queueRequests', function() {
|
||||
var t = pool.queueRequests;
|
||||
t.should.be.a.Boolean;
|
||||
|
||||
try {
|
||||
pool.queueRequests = !t;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.queueRequests = !t;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('58.2.9 queueTimeout', function() {
|
||||
it('58.2.9 queueTimeout', function() {
|
||||
var t = pool.queueTimeout;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
pool.queueTimeout = t + 1000;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
pool.queueTimeout = t + 1000;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
}) // 58.2
|
||||
it('58.2.10 poolPingInterval', function() {
|
||||
var t = pool.poolPingInterval;
|
||||
t.should.be.a.Number();
|
||||
|
||||
should.throws(
|
||||
function() {
|
||||
pool.poolPingInterval = t + 100;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
}); // 58.2
|
||||
|
||||
describe('58.3 Connection Class', function() {
|
||||
var connection = null;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('58.3.1 Connection object initial toString values', function() {
|
||||
connection.should.be.an.Object;
|
||||
|
@ -387,90 +467,87 @@ describe('58. properties.js', function() {
|
|||
|
||||
(connection.stmtCacheSize).should.be.a.Number();
|
||||
(connection.stmtCacheSize).should.be.greaterThan(0);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.3.2 stmtCacheSize (read-only)', function() {
|
||||
var t = connection.stmtCacheSize;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
connection.stmtCacheSize = t + 1;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
connection.stmtCacheSize = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
it('58.3.3 clientId (write-only)', function() {
|
||||
try {
|
||||
var t = connection.clientId;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-015:'); // write-only
|
||||
}
|
||||
var t = connection.clientId;
|
||||
should.strictEqual(t, null);
|
||||
|
||||
try {
|
||||
connection.clientId = 4;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-004:'); // invalid value
|
||||
}
|
||||
should.throws(
|
||||
function() {
|
||||
connection.clientId = 4;
|
||||
},
|
||||
/NJS-004: invalid value for property [\w]/
|
||||
);
|
||||
|
||||
connection.clientId = "103.3";
|
||||
})
|
||||
should.doesNotThrow(
|
||||
function() {
|
||||
connection.clientId = "103.3";
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('58.3.4 action (write-only)', function() {
|
||||
var t = connection.action;
|
||||
should.strictEqual(t, null);
|
||||
|
||||
try {
|
||||
var t = connection.action;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-015:');
|
||||
}
|
||||
should.throws(
|
||||
function() {
|
||||
connection.action = 4;
|
||||
},
|
||||
/NJS-004: invalid value for property [\w]/
|
||||
);
|
||||
|
||||
try {
|
||||
connection.action = 4;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-004:'); // invalid value
|
||||
}
|
||||
|
||||
connection.action = "103.3 action";
|
||||
})
|
||||
should.doesNotThrow(
|
||||
function() {
|
||||
connection.action = "103.3 action";
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('58.3.5 module (write-only)', function() {
|
||||
var t = connection.module;
|
||||
should.strictEqual(t, null);
|
||||
|
||||
try {
|
||||
var t = connection.module;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-015:');
|
||||
}
|
||||
should.throws(
|
||||
function() {
|
||||
connection.module = 4;
|
||||
},
|
||||
/NJS-004: invalid value for property [\w]/
|
||||
);
|
||||
|
||||
try {
|
||||
connection.module = 4;
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-004:'); // invalid value
|
||||
}
|
||||
|
||||
connection.module = "103.3 module";
|
||||
})
|
||||
should.doesNotThrow(
|
||||
function() {
|
||||
connection.clientId = "103.3 module";
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('58.3.6 oracleServerVersion (read-only)', function () {
|
||||
var t = connection.oracleServerVersion;
|
||||
t.should.be.a.Number();
|
||||
|
||||
try {
|
||||
connection.oracleServerVersion = t + 1;
|
||||
}
|
||||
catch (err) {
|
||||
should.exist ( err );
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
should.throws(
|
||||
function() {
|
||||
connection.oracleServerVersion = t + 1;
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
}) // 58.3
|
||||
}); // 58.3
|
||||
|
||||
describe('58.4 ResultSet Class', function() {
|
||||
|
||||
|
@ -482,11 +559,18 @@ describe('58. properties.js', function() {
|
|||
before('get resultSet class', function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
assist.setUp(connection, tableName, numbers, callback);
|
||||
|
@ -504,11 +588,11 @@ describe('58. properties.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
});
|
||||
|
||||
after( function(done) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName,
|
||||
"DROP TABLE " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
|
@ -518,20 +602,20 @@ describe('58. properties.js', function() {
|
|||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('58.4.1 metaData (read-only)', function() {
|
||||
should.exist(resultSet.metaData);
|
||||
var t = resultSet.metaData;
|
||||
t.should.eql( [ { name: 'NUM' }, { name: 'CONTENT' } ] );
|
||||
|
||||
try {
|
||||
resultSet.metaData = {"foo": "bar"};
|
||||
} catch(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-014:');
|
||||
}
|
||||
})
|
||||
should.throws(
|
||||
function() {
|
||||
resultSet.metaData = {"foo": "bar"};
|
||||
},
|
||||
/NJS-014: [\w]+ is a read-only property/
|
||||
);
|
||||
});
|
||||
|
||||
}) // 58.5
|
||||
})
|
||||
}); // 58.4
|
||||
});
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/* Copyright (c) 2015, 2016, 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
|
||||
* 54. releaseAfterFailingTerminate.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing connection release after pool's failing termination.
|
||||
*
|
||||
* 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 - are for other tests
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('54. releaseAfterFailingTerminate.js', function() {
|
||||
|
||||
it('can still release connections after failing pool termination', function(done){
|
||||
oracledb.createPool(
|
||||
dbConfig,
|
||||
function(err, pool) {
|
||||
should.not.exist(err);
|
||||
pool.getConnection( function(err, connection){
|
||||
should.not.exist(err);
|
||||
pool.terminate(
|
||||
function(err){
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('ORA-24422:');
|
||||
|
||||
connection.release( function(err){
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
})
|
File diff suppressed because it is too large
Load Diff
1335
test/resultSet2.js
1335
test/resultSet2.js
File diff suppressed because it is too large
Load Diff
|
@ -119,40 +119,32 @@ describe('53. resultSetClose.js', function() {
|
|||
);
|
||||
}); // 53.1
|
||||
|
||||
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();
|
||||
});
|
||||
it('53.2 can not call close() again', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
resultSet.close(function() {});
|
||||
},
|
||||
/NJS-018: invalid ResultSet/
|
||||
);
|
||||
}); // 53.2
|
||||
|
||||
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();
|
||||
});
|
||||
it('53.3 can not call getRow()', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
resultSet.getRow(function() {});
|
||||
},
|
||||
/NJS-018: invalid ResultSet/
|
||||
);
|
||||
}); // 53.3
|
||||
|
||||
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();
|
||||
});
|
||||
it('53.4 can not call getRows()', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
var numRows = 3;
|
||||
resultSet.getRows(numRows, function() {});
|
||||
},
|
||||
/NJS-018: invalid ResultSet/
|
||||
);
|
||||
}); // 53.4
|
||||
|
||||
it('53.5 can not call toQueryStream()', function() {
|
||||
|
|
|
@ -45,25 +45,32 @@ describe('15. resultsetToStream.js', function () {
|
|||
before(function(done) {
|
||||
async.series([
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createTab(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942);\n " +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_rs2stream PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_employees ( \n" +
|
||||
" CREATE TABLE nodb_rs2stream ( \n" +
|
||||
" employees_id NUMBER, \n" +
|
||||
" employees_name VARCHAR2(20), \n" +
|
||||
" employees_history CLOB \n" +
|
||||
|
@ -88,7 +95,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
" FOR i IN 1..217 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO nodb_employees VALUES (x, n, EMPTY_CLOB()) RETURNING employees_history INTO clobData; \n" +
|
||||
" INSERT INTO nodb_rs2stream VALUES (x, n, EMPTY_CLOB()) RETURNING employees_history INTO clobData; \n" +
|
||||
" DBMS_LOB.WRITE(clobData, 20, 1, '12345678901234567890'); \n" +
|
||||
" END LOOP; \n" +
|
||||
"end; ";
|
||||
|
@ -102,13 +109,13 @@ describe('15. resultsetToStream.js', function () {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_employees",
|
||||
"DROP TABLE nodb_rs2stream PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -122,13 +129,13 @@ describe('15. resultsetToStream.js', function () {
|
|||
});
|
||||
},
|
||||
], done);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
describe('15.1 Testing ResultSet.toQueryStream', function () {
|
||||
it('15.1.1 should allow resultsets to be converted to streams', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
|
@ -163,7 +170,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
it('15.2.1 should prevent conversion to stream after getRow is invoked', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
|
@ -173,7 +180,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
|
||||
var cursor = result.outBinds.cursor;
|
||||
|
||||
cursor.getRow(function(err, row) {
|
||||
cursor.getRow(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
cursor.close(function(err) {
|
||||
|
@ -183,7 +190,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
});
|
||||
|
||||
try {
|
||||
var stream = cursor.toQueryStream();
|
||||
cursor.toQueryStream();
|
||||
} catch (err) {
|
||||
(err.message).should.startWith('NJS-041:');
|
||||
// NJS-041: cannot convert to stream after invoking methods
|
||||
|
@ -195,7 +202,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
it('15.2.2 should prevent conversion to stream after getRows is invoked', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
|
@ -205,7 +212,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
|
||||
var cursor = result.outBinds.cursor;
|
||||
|
||||
cursor.getRows(5, function(err, rows) {
|
||||
cursor.getRows(5, function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
cursor.close(function(err) {
|
||||
|
@ -215,7 +222,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
});
|
||||
|
||||
try {
|
||||
var stream = cursor.toQueryStream();
|
||||
cursor.toQueryStream();
|
||||
} catch (err) {
|
||||
(err.message).should.startWith('NJS-041:');
|
||||
}
|
||||
|
@ -226,7 +233,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
it('15.2.3 should prevent conversion to stream after close is invoked', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
|
@ -243,7 +250,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
});
|
||||
|
||||
try {
|
||||
var stream = cursor.toQueryStream();
|
||||
cursor.toQueryStream();
|
||||
} catch (err) {
|
||||
(err.message).should.startWith('NJS-041:');
|
||||
}
|
||||
|
@ -254,7 +261,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
it('15.2.4 should prevent invoking getRow after conversion to stream', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
|
@ -265,7 +272,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
var cursor = result.outBinds.cursor;
|
||||
var stream = cursor.toQueryStream();
|
||||
|
||||
cursor.getRow(function(err, row) {
|
||||
cursor.getRow(function(err) {
|
||||
(err.message).should.startWith('NJS-042:');
|
||||
// NJS-042: cannot invoke methods after converting to stream
|
||||
|
||||
|
@ -283,7 +290,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
it('15.2.5 should prevent invoking getRows after conversion to stream', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
|
@ -294,7 +301,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
var cursor = result.outBinds.cursor;
|
||||
var stream = cursor.toQueryStream();
|
||||
|
||||
cursor.getRows(5, function(err, rows) {
|
||||
cursor.getRows(5, function(err) {
|
||||
(err.message).should.startWith('NJS-042:');
|
||||
|
||||
// Closing cursor via stream._close because the cursor.close method
|
||||
|
@ -311,7 +318,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
it('15.2.6 should prevent invoking close after conversion to stream', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
|
@ -339,7 +346,7 @@ describe('15. resultsetToStream.js', function () {
|
|||
it('15.2.7 should prevent calling toQueryStream more than once', function (done) {
|
||||
connection.execute(
|
||||
'begin \n' +
|
||||
' open :cursor for select employees_name from nodb_employees; \n' +
|
||||
' open :cursor for select employees_name from nodb_rs2stream; \n' +
|
||||
'end;',
|
||||
{
|
||||
cursor: { type: oracledb.CURSOR, dir : oracledb.BIND_OUT }
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
"use strict";
|
||||
|
||||
var oracledb = require('oracledb');
|
||||
var fs = require('fs');
|
||||
var should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
@ -45,19 +44,26 @@ describe('64. sqlWithWarnings.js', function() {
|
|||
|
||||
var connection = null;
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
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();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe('64.1 test case offered by GitHub user', function() {
|
||||
|
||||
|
@ -67,12 +73,12 @@ describe('64. sqlWithWarnings.js', function() {
|
|||
var sqlCreateTab =
|
||||
"BEGIN " +
|
||||
" DECLARE " +
|
||||
" e_table_exists EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942); " +
|
||||
" e_table_missing EXCEPTION; " +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); " +
|
||||
" BEGIN " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " '); " +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE'); " +
|
||||
" EXCEPTION " +
|
||||
" WHEN e_table_exists " +
|
||||
" WHEN e_table_missing " +
|
||||
" THEN NULL; " +
|
||||
" END; " +
|
||||
" EXECUTE IMMEDIATE (' " +
|
||||
|
@ -117,31 +123,31 @@ describe('64. sqlWithWarnings.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName,
|
||||
"DROP TABLE " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
it('64.1.1 Executes an aggregate query which causes warnings', function(done) {
|
||||
connection.execute(
|
||||
"SELECT MAX(NUM_COL) AS NUM_COL FROM " + tableName,
|
||||
[],
|
||||
{ maxRows: 1 },
|
||||
function(err, result) {
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
}) // 64.1
|
||||
}); // 64.1
|
||||
|
||||
describe('64.2 PL/SQL - Success With Info', function() {
|
||||
|
||||
|
@ -149,20 +155,20 @@ describe('64. sqlWithWarnings.js', function() {
|
|||
" CREATE OR REPLACE PROCEDURE get_emp_rs_inout " +
|
||||
" (p_in IN NUMBER, p_out OUT SYS_REFCURSOR ) AS " +
|
||||
" BEGIN " +
|
||||
" OPEN p_out FOR SELECT * FROM nodb_employees " +
|
||||
" END;"
|
||||
" OPEN p_out FOR SELECT * FROM nodb_sql_emp " +
|
||||
" END;";
|
||||
|
||||
it('64.2.1 Execute SQL Statement to create PLSQL procedure with warnings', function(done) {
|
||||
connection.should.be.an.Object;
|
||||
connection.execute (
|
||||
plsqlWithWarning,
|
||||
function ( err, result ) {
|
||||
function (err) {
|
||||
should.not.exist ( err );
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
||||
|
||||
}) // 64.2
|
||||
}); // 64.2
|
||||
|
||||
})
|
||||
});
|
||||
|
|
137
test/stream1.js
137
test/stream1.js
|
@ -40,31 +40,40 @@ var dbConfig = require('./dbconfig.js');
|
|||
|
||||
describe('13. stream1.js', function () {
|
||||
|
||||
this.timeout(100000);
|
||||
|
||||
var connection = null;
|
||||
var rowsAmount = 217;
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createTab(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942);\n " +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_stream1 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_employees ( \n" +
|
||||
" CREATE TABLE nodb_stream1 ( \n" +
|
||||
" employee_id NUMBER, \n" +
|
||||
" employee_name VARCHAR2(20), \n" +
|
||||
" employee_history CLOB \n" +
|
||||
|
@ -89,7 +98,7 @@ describe('13. stream1.js', function () {
|
|||
" FOR i IN 1..217 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO nodb_employees VALUES (x, n, EMPTY_CLOB()) RETURNING employee_history INTO clobData; \n" +
|
||||
" INSERT INTO nodb_stream1 VALUES (x, n, EMPTY_CLOB()) RETURNING employee_history INTO clobData; \n" +
|
||||
" DBMS_LOB.WRITE(clobData, 20, 1, '12345678901234567890'); \n" +
|
||||
" END LOOP; \n" +
|
||||
"end; ";
|
||||
|
@ -103,13 +112,13 @@ describe('13. stream1.js', function () {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_employees",
|
||||
"DROP TABLE nodb_stream1 PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -123,13 +132,13 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
},
|
||||
], done);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
describe('13.1 Testing QueryStream', function () {
|
||||
it('13.1.1 stream results for oracle connection', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name');
|
||||
|
||||
stream.on('error', function (error) {
|
||||
should.fail(error, null, 'Error event should not be triggered');
|
||||
|
@ -149,9 +158,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.2 stream results for oracle connection (outFormat: oracledb.OBJECT)', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name', {}, {
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name', {}, {
|
||||
outFormat: oracledb.OBJECT
|
||||
});
|
||||
|
||||
|
@ -173,9 +182,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.3 errors in query', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT no_such_column FROM nodb_employees');
|
||||
var stream = connection.queryStream('SELECT no_such_column FROM nodb_stream1');
|
||||
|
||||
stream.on('error', function (error) {
|
||||
should.exist(error);
|
||||
|
@ -188,9 +197,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.4 no result', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT * FROM nodb_employees WHERE employee_name = :name', {
|
||||
var stream = connection.queryStream('SELECT * FROM nodb_stream1 WHERE employee_name = :name', {
|
||||
name: 'TEST_NO_RESULT'
|
||||
});
|
||||
|
||||
|
@ -211,9 +220,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.5 single row', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees WHERE employee_name = :name', {
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 WHERE employee_name = :name', {
|
||||
name: 'staff 10'
|
||||
});
|
||||
|
||||
|
@ -237,9 +246,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.6 multiple row', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees WHERE employee_id <= :maxId ORDER BY employee_id', {
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 WHERE employee_id <= :maxId ORDER BY employee_id', {
|
||||
maxId: 10
|
||||
}, {
|
||||
outFormat: oracledb.OBJECT
|
||||
|
@ -267,9 +276,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.7 invalid SQL', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('UPDATE nodb_employees SET employee_name = :name WHERE employee_id = :id', {
|
||||
var stream = connection.queryStream('UPDATE nodb_stream1 SET employee_name = :name WHERE employee_id = :id', {
|
||||
id: 10,
|
||||
name: 'test_update'
|
||||
}, {
|
||||
|
@ -288,9 +297,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.8 Read CLOBs', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name, employee_history FROM nodb_employees where employee_id <= :maxId ORDER BY employee_id', {
|
||||
var stream = connection.queryStream('SELECT employee_name, employee_history FROM nodb_stream1 where employee_id <= :maxId ORDER BY employee_id', {
|
||||
maxId: 10
|
||||
}, {
|
||||
outFormat: oracledb.OBJECT
|
||||
|
@ -340,11 +349,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.9 Read CLOBs after stream close', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
this.timeout(10000);
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name, employee_history FROM nodb_employees where employee_id <= :maxId ORDER BY employee_id', {
|
||||
var stream = connection.queryStream('SELECT employee_name, employee_history FROM nodb_stream1 where employee_id <= :maxId ORDER BY employee_id', {
|
||||
maxId: 10
|
||||
}, {
|
||||
outFormat: oracledb.OBJECT
|
||||
|
@ -398,9 +405,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.10 meta data', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees WHERE employee_name = :name', {
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 WHERE employee_name = :name', {
|
||||
name: 'staff 10'
|
||||
});
|
||||
|
||||
|
@ -430,11 +437,10 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.1.11 stream stress test', function (done) {
|
||||
this.timeout(30000);
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name');
|
||||
|
||||
stream.on('error', function (error) {
|
||||
should.fail(error, null, 'Error event should not be triggered');
|
||||
|
@ -453,7 +459,7 @@ describe('13. stream1.js', function () {
|
|||
|
||||
var testDone = 0;
|
||||
var subTest = function (callback) {
|
||||
var query = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
var query = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name');
|
||||
|
||||
query.on('error', function (error) {
|
||||
should.fail(error, null, 'Error event should not be triggered');
|
||||
|
@ -484,16 +490,16 @@ describe('13. stream1.js', function () {
|
|||
should.equal(testDone, tests.length);
|
||||
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('13.2 Testing QueryStream._close', function () {
|
||||
it('13.2.1 should be able to stop the stream early with _close', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name');
|
||||
|
||||
stream.on('data', function () {
|
||||
stream.pause();
|
||||
|
@ -514,9 +520,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.2.2 should be able to stop the stream before any data', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name');
|
||||
|
||||
stream.on('close', function() {
|
||||
done();
|
||||
|
@ -539,9 +545,9 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
|
||||
it('13.2.3 should invoke an optional callback passed to _close', function (done) {
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name');
|
||||
|
||||
stream._close(function() {
|
||||
done();
|
||||
|
@ -566,13 +572,13 @@ describe('13. stream1.js', function () {
|
|||
var defaultMaxRows;
|
||||
var testMaxRows = 9;
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
defaultMaxRows = oracledb.maxRows;
|
||||
|
||||
oracledb.maxRows = testMaxRows;
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_stream1 ORDER BY employee_name');
|
||||
|
||||
stream.on('data', function () {
|
||||
stream.pause();
|
||||
|
@ -596,38 +602,23 @@ describe('13. stream1.js', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('13.3.2 should default to 100 if oracledb.maxRows is false', function (done) {
|
||||
it('13.3.2 Negative - should fail with NJS-026 if oracledb.maxRows is zero', function (done) {
|
||||
var defaultMaxRows;
|
||||
var testMaxRows = 0;
|
||||
|
||||
connection.should.be.ok;
|
||||
connection.should.be.ok();
|
||||
|
||||
defaultMaxRows = oracledb.maxRows;
|
||||
|
||||
oracledb.maxRows = testMaxRows;
|
||||
|
||||
var stream = connection.queryStream('SELECT employee_name FROM nodb_employees ORDER BY employee_name');
|
||||
|
||||
stream.on('data', function () {
|
||||
stream.pause();
|
||||
|
||||
// Using the internal/private caches to validate
|
||||
should.equal(stream._fetchedRows.length, (99 - stream._readableState.buffer.length));
|
||||
stream._close();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
try {
|
||||
oracledb.maxRows = testMaxRows;
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-026:');
|
||||
// NJS-026: maxRows must be greater than zero
|
||||
oracledb.maxRows = defaultMaxRows;
|
||||
done();
|
||||
});
|
||||
|
||||
stream.on('end', function () {
|
||||
done(new Error('Reached the end of the stream'));
|
||||
});
|
||||
|
||||
stream.on('error', function (err) {
|
||||
done(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
665
test/stream2.js
665
test/stream2.js
|
@ -39,18 +39,26 @@ var async = require('async');
|
|||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('14. stream2.js', function() {
|
||||
this.timeout(10000);
|
||||
|
||||
var connection = null;
|
||||
var rowsAmount = 217;
|
||||
|
||||
beforeEach(function(done) {
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createTab(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
|
@ -58,13 +66,13 @@ describe('14. stream2.js', function() {
|
|||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_employees'); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_stream2 PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_employees ( \n" +
|
||||
" CREATE TABLE nodb_stream2 ( \n" +
|
||||
" employee_id NUMBER, \n" +
|
||||
" employee_name VARCHAR2(20), \n" +
|
||||
" employee_history CLOB \n" +
|
||||
|
@ -89,7 +97,7 @@ describe('14. stream2.js', function() {
|
|||
" FOR i IN 1..217 LOOP \n" +
|
||||
" x := x + 1; \n" +
|
||||
" n := 'staff ' || x; \n" +
|
||||
" INSERT INTO nodb_employees VALUES (x, n, EMPTY_CLOB()) RETURNING employee_history INTO clobData; \n" +
|
||||
" INSERT INTO nodb_stream2 VALUES (x, n, EMPTY_CLOB()) RETURNING employee_history INTO clobData; \n" +
|
||||
" DBMS_LOB.WRITE(clobData, 20, 1, '12345678901234567890'); \n" +
|
||||
" END LOOP; \n" +
|
||||
"end; ";
|
||||
|
@ -103,13 +111,13 @@ describe('14. stream2.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
afterEach(function(done) {
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_employees",
|
||||
"DROP TABLE nodb_stream2 PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -123,10 +131,219 @@ describe('14. stream2.js', function() {
|
|||
});
|
||||
},
|
||||
], done);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
it('14.1 meta data event', function(done) {
|
||||
var sql = 'SELECT * FROM nodb_employees ORDER BY employee_id';
|
||||
it('14.1 Bind by position and return an array', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :1';
|
||||
var stream = connection.queryStream(sql, [40]);
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
data.should.eql(['staff 40']);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.2 Bind by name and return an array', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :id';
|
||||
var stream = connection.queryStream(sql, {id: 40});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
data.should.eql(['staff 40']);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.3 Bind by position and return an object', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :1';
|
||||
var stream = connection.queryStream(sql, [40], {outFormat: oracledb.OBJECT});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
(data.EMPLOYEE_NAME).should.eql('staff 40');
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.4 Bind by name and return an object', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :id';
|
||||
var stream = connection.queryStream(sql, {id: 40}, {outFormat: oracledb.OBJECT});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
(data.EMPLOYEE_NAME).should.eql('staff 40');
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.5 explicitly setting resultSet option to be false takes no effect', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :1';
|
||||
var stream = connection.queryStream(sql, [40], {resultSet: false});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
data.should.eql(['staff 40']);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.6 maxRows option is ignored as expect', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 ORDER BY employee_name';
|
||||
var stream = connection.queryStream(sql, [], {maxRows: 50});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
var rowCount = 0;
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
rowCount++;
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
rowCount.should.eql(rowsAmount);
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('14.7 Negative - queryStream() has no parameters', function(done) {
|
||||
|
||||
try {
|
||||
connection.queryStream();
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-009:');
|
||||
// NJS-009: invalid number of parameters
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('14.8 Negative - give invalid SQL as first parameter', function(done) {
|
||||
var stream = connection.queryStream('foobar');
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.exist(error);
|
||||
(error.message).should.startWith('NJS-019:');
|
||||
// NJS-019: resultSet cannot be returned for non-query statements
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.not.exist(data);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.9 Negatvie - give non-query SQL', function(done) {
|
||||
var sql = "INSERT INTO nodb_stream2 VALUES (300, 'staff 300', EMPTY_CLOB())";
|
||||
var stream = connection.queryStream(sql);
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.exist(error);
|
||||
(error.message).should.startWith('NJS-019:');
|
||||
// NJS-019: resultSet cannot be returned for non-query statements
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.not.exist(data);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.10 metadata event - single column', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :id';
|
||||
var stream = connection.queryStream(sql, { id: 40 });
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function(metaData) {
|
||||
should.deepEqual(
|
||||
metaData,
|
||||
[ { name: 'EMPLOYEE_NAME' } ]
|
||||
);
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
should.equal(metaDataRead, true);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.11 metadata event - multiple columns', function(done) {
|
||||
var sql = 'SELECT employee_name, employee_history FROM nodb_stream2 WHERE employee_id = :id';
|
||||
var stream = connection.queryStream(sql, { id: 40 });
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function(metaData) {
|
||||
should.deepEqual(
|
||||
metaData,
|
||||
[ { name: 'EMPLOYEE_NAME' },
|
||||
{ name: 'EMPLOYEE_HISTORY' } ]
|
||||
);
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
should.equal(metaDataRead, true);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
|
||||
it('14.12 metadata event - all column names occurring', function(done) {
|
||||
var sql = 'SELECT * FROM nodb_stream2 ORDER BY employee_id';
|
||||
var stream = connection.queryStream(sql);
|
||||
|
||||
var metaDataRead = false;
|
||||
|
@ -152,11 +369,20 @@ describe('14. stream2.js', function() {
|
|||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('14.2 Bind by position and return an array', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_employees WHERE employee_id = :1';
|
||||
var stream = connection.queryStream(sql, [40]);
|
||||
it('14.13 metadata event - no return rows', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_stream2 WHERE employee_id = :id';
|
||||
var stream = connection.queryStream(sql, { id: 400 });
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function(metaData) {
|
||||
should.deepEqual(
|
||||
metaData,
|
||||
[ { name: 'EMPLOYEE_NAME' } ]
|
||||
);
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
|
@ -164,149 +390,296 @@ describe('14. stream2.js', function() {
|
|||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
data.should.eql(['staff 40']);
|
||||
should.equal(metaDataRead, true);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
it('14.3 Bind by name and return an array', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_employees WHERE employee_id = :id';
|
||||
var stream = connection.queryStream(sql, {id: 40});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
data.should.eql(['staff 40']);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
})
|
||||
|
||||
it('14.4 Bind by position and return an object', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_employees WHERE employee_id = :1';
|
||||
var stream = connection.queryStream(sql, [40], {outFormat: oracledb.OBJECT});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
(data.EMPLOYEE_NAME).should.eql('staff 40');
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
})
|
||||
|
||||
it('14.5 Bind by name and return an object', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_employees WHERE employee_id = :id';
|
||||
var stream = connection.queryStream(sql, {id: 40}, {outFormat: oracledb.OBJECT});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
(data.EMPLOYEE_NAME).should.eql('staff 40');
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
})
|
||||
|
||||
it('14.6 explicitly setting resultSet option to be false takes no effect', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_employees WHERE employee_id = :1';
|
||||
var stream = connection.queryStream(sql, [40], {resultSet: false});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
data.should.eql(['staff 40']);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
})
|
||||
|
||||
it('14.7 maxRows option is ignored as expect', function(done) {
|
||||
var sql = 'SELECT employee_name FROM nodb_employees ORDER BY employee_name';
|
||||
var stream = connection.queryStream(sql, [], {maxRows: 50});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
var rowCount = 0;
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
rowCount++;
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
rowCount.should.eql(rowsAmount);
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
it('14.8 Negative - queryStream() has no parameters', function(done) {
|
||||
var stream;
|
||||
|
||||
try {
|
||||
stream = connection.queryStream();
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
(err.message).should.startWith('NJS-009:');
|
||||
// NJS-009: invalid number of parameters
|
||||
done();
|
||||
}
|
||||
})
|
||||
|
||||
it('14.9 Negative - give invalid SQL as first parameter', function(done) {
|
||||
var stream = connection.queryStream('foobar');
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.exist(error);
|
||||
(error.message).should.startWith('NJS-019:');
|
||||
// NJS-019: resultSet cannot be returned for non-query statements
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.not.exist(data);
|
||||
});
|
||||
})
|
||||
|
||||
it('14.10 Negatvie - give non-query SQL', function(done) {
|
||||
var sql = "INSERT INTO nodb_employees VALUES (300, 'staff 300', EMPTY_CLOB())";
|
||||
it('14.14 metadata event - negative: non-query SQL', function(done) {
|
||||
var sql = "INSERT INTO nodb_stream2 VALUES (300, 'staff 300', EMPTY_CLOB())";
|
||||
var stream = connection.queryStream(sql);
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function() {
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.exist(error);
|
||||
(error.message).should.startWith('NJS-019:');
|
||||
// NJS-019: resultSet cannot be returned for non-query statements
|
||||
|
||||
should.equal(metaDataRead, false);
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.not.exist(data);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
it('14.15 metadata event - case sensitive columns', function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_streamcases PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_streamcases ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
' "nAmE" VARCHAR2(20) \n' +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" INSERT INTO nodb_streamcases VALUES (23, ''Changjie'') \n" +
|
||||
" '); \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" INSERT INTO nodb_streamcases VALUES (24, ''Nancy'') \n" +
|
||||
" '); \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" INSERT INTO nodb_streamcases VALUES (25, ''Chris'') \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var sql = 'SELECT "nAmE" FROM nodb_streamcases ORDER BY id';
|
||||
var stream = connection.queryStream(sql);
|
||||
var resultArray = new Array();
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function(metaData) {
|
||||
should.deepEqual(
|
||||
metaData,
|
||||
[ { name: 'nAmE' } ]
|
||||
);
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
resultArray.push(data);
|
||||
should.equal(metaDataRead, true);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
should.deepEqual(
|
||||
resultArray,
|
||||
[ [ 'Changjie' ], [ 'Nancy' ], [ 'Chris' ] ]
|
||||
);
|
||||
setTimeout(cb, 500);
|
||||
});
|
||||
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_streamcases PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 14.15
|
||||
|
||||
it('14.16 metadata event - large number of columns', function(done) {
|
||||
|
||||
var column_size = 100;
|
||||
var columns_string = genColumns(column_size);
|
||||
|
||||
function genColumns(size) {
|
||||
var buffer = [];
|
||||
for(var i = 0; i < size; i++) {
|
||||
buffer[i] = " column_" + i + " NUMBER";
|
||||
}
|
||||
return buffer.join();
|
||||
}
|
||||
|
||||
var table_name = "nodb_streamstess";
|
||||
var sqlSelect = "SELECT * FROM " + table_name;
|
||||
var sqlDrop = "DROP TABLE " + table_name + " PURGE";
|
||||
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_streamstess PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_streamstess ( \n" +
|
||||
columns_string +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var stream = connection.queryStream(sqlSelect);
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function(metaData) {
|
||||
for (var i = 0; i < column_size; i++) {
|
||||
metaData[i].name.should.eql('COLUMN_' + i);
|
||||
}
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
should.equal(metaDataRead, true);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(cb, 500);
|
||||
});
|
||||
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlDrop,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 14.16
|
||||
|
||||
it('14.17 metadata event - single character column', function(done) {
|
||||
|
||||
var tableName = "nodb_streamsinglechar";
|
||||
var sqlCreate =
|
||||
"BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE " + tableName +" ( \n" +
|
||||
" a VARCHAR2(20), \n" +
|
||||
' b VARCHAR2(20) \n' +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; \n";
|
||||
var sqlSelect = "SELECT * FROM " + tableName;
|
||||
var sqlDrop = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlCreate,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var stream = connection.queryStream(sqlSelect);
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function(metaData) {
|
||||
should.deepEqual(
|
||||
metaData,
|
||||
[ { name: 'A' }, { name: 'B' } ]
|
||||
);
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function() {
|
||||
should.equal(metaDataRead, true);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(cb, 500);
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sqlDrop,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 14.17
|
||||
|
||||
it('14.18 metadata event - duplicate column alias', function(done) {
|
||||
|
||||
var stream = connection.queryStream("SELECT 1 a, 'abc' a FROM dual");
|
||||
|
||||
var metaDataRead = false;
|
||||
stream.on('metadata', function(metaData) {
|
||||
should.deepEqual(
|
||||
metaData,
|
||||
[ { name: 'A' }, { name: 'A' } ]
|
||||
);
|
||||
metaDataRead = true;
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
data.should.eql([1, 'abc']);
|
||||
should.equal(metaDataRead, true);
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
setTimeout(done, 500);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -46,22 +46,29 @@ describe('65. uninitializedLob.js', function() {
|
|||
var connection = null;
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(callback) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
});
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(
|
||||
{
|
||||
user: dbConfig.user,
|
||||
password: dbConfig.password,
|
||||
connectString: dbConfig.connectString
|
||||
},
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function createTab(callback) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_exists EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_exists, -00942);\n " +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n " +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_lobdpi'); \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE nodb_lobdpi PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_exists \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
|
@ -149,7 +156,7 @@ describe('65. uninitializedLob.js', function() {
|
|||
);
|
||||
}
|
||||
], done);
|
||||
}) // before
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
|
@ -164,7 +171,7 @@ describe('65. uninitializedLob.js', function() {
|
|||
},
|
||||
function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_lobdpi",
|
||||
"DROP TABLE nodb_lobdpi PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
|
@ -178,7 +185,7 @@ describe('65. uninitializedLob.js', function() {
|
|||
});
|
||||
}
|
||||
], done);
|
||||
}) // after
|
||||
}); // after
|
||||
|
||||
it('65.1 an uninitialized Lob is returned from a PL/SQL block', function(done) {
|
||||
// async's times applies a function n times in series.
|
||||
|
@ -218,10 +225,9 @@ describe('65. uninitializedLob.js', function() {
|
|||
|
||||
if (result.outBinds.id == -1) {
|
||||
// a dup was found
|
||||
return next(null)
|
||||
return next(null);
|
||||
}
|
||||
|
||||
var randomBlob = new Buffer(0);
|
||||
crypto.randomBytes(16, function(ex, buf) {
|
||||
var passthrough = new stream.PassThrough();
|
||||
passthrough.on('error', function(err) {
|
||||
|
@ -230,7 +236,7 @@ describe('65. uninitializedLob.js', function() {
|
|||
|
||||
result.outBinds.blob_1.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
})
|
||||
});
|
||||
|
||||
result.outBinds.blob_1.on('finish',function(err) {
|
||||
next(err);
|
||||
|
@ -248,5 +254,5 @@ describe('65. uninitializedLob.js', function() {
|
|||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
}) //65.1
|
||||
})
|
||||
}); //65.1
|
||||
});
|
||||
|
|
|
@ -1,174 +0,0 @@
|
|||
/* Copyright (c) 2016, 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
|
||||
* 67. utf8MultibyteCharacter.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing UTF-8 multibyte characters.
|
||||
*
|
||||
* 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');
|
||||
|
||||
describe('67. utf8MultibyteCharacter.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var strLength = 10;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
||||
it('67.1 works with UTF-8 multibyte characters', function(done) {
|
||||
async.series([
|
||||
function doCreate(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE nodb_testutf8'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE nodb_testutf8 ( \n" +
|
||||
" id NUMBER(9), \n" +
|
||||
" name VARCHAR2(30) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function doInsert(cb) {
|
||||
var sql = "INSERT INTO nodb_testutf8 \n" +
|
||||
" SELECT 1, rpad( unistr('\\20ac'), " + strLength + ", unistr('\\20ac') ) FROM dual";
|
||||
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function doCommit(cb) {
|
||||
connection.commit(function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
});
|
||||
},
|
||||
function doSelect(cb) {
|
||||
connection.execute(
|
||||
"SELECT name FROM nodb_testutf8",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var byteLen = getByteLen(result.rows[0][0]);
|
||||
byteLen.should.be.exactly(strLength * 3);
|
||||
(result.rows[0][0]).should.eql('€€€€€€€€€€');
|
||||
|
||||
return cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function doplsql(cb) {
|
||||
var proc = "BEGIN \n" +
|
||||
" SELECT name INTO :o FROM nodb_testutf8; \n" +
|
||||
"END;";
|
||||
var bindVar = { o: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 30 } };
|
||||
|
||||
connection.execute(
|
||||
proc,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var byteLen = getByteLen(result.outBinds.o);
|
||||
byteLen.should.be.exactly(strLength * 3);
|
||||
(result.outBinds.o).should.eql('€€€€€€€€€€');
|
||||
|
||||
return cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function doDrop(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_testutf8",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
return cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
/*
|
||||
* Count bytes of a utf-8 String
|
||||
*/
|
||||
var getByteLen = function(str) {
|
||||
// String type conversion
|
||||
str = String(str);
|
||||
|
||||
var byteLen = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
var ch = str.charCodeAt(i);
|
||||
byteLen += ch < (1 << 7) ? 1 :
|
||||
ch < (1 << 11) ? 2 :
|
||||
ch < (1 << 16) ? 3 :
|
||||
ch < (1 << 21) ? 4 :
|
||||
ch < (1 << 26) ? 5 :
|
||||
ch < (1 << 31) ? 6 :
|
||||
Number.NaN;
|
||||
}
|
||||
|
||||
return byteLen;
|
||||
}
|
|
@ -14,21 +14,31 @@
|
|||
*
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**
|
||||
* NAME
|
||||
* 66. writableProperties.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing writable properties.
|
||||
*
|
||||
* 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 oracledbCLib;
|
||||
var oracledb = require('oracledb');
|
||||
var should = require('should');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('66. writeableProperties.js', function() {
|
||||
describe('66. writableProperties.js', function() {
|
||||
|
||||
it('66.1 allows overwriting of public methods on pool instances', function(done) {
|
||||
oracledb.createPool(
|
||||
{
|
||||
externalAuth : dbConfig.externalAuth,
|
||||
user : dbConfig.user,
|
||||
password : dbConfig.password,
|
||||
connectString : dbConfig.connectString,
|
||||
|
@ -69,6 +79,7 @@ describe('66. writeableProperties.js', function() {
|
|||
});
|
||||
|
||||
it('66.2 allows overwriting of public methods on connection instances', function(done) {
|
||||
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
var keys;
|
||||
var keysIdx;
|
||||
|
@ -101,6 +112,7 @@ describe('66. writeableProperties.js', function() {
|
|||
});
|
||||
|
||||
it('66.3 allows overwriting of public methods on resultset instances', function(done) {
|
||||
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
|
@ -148,6 +160,7 @@ describe('66. writeableProperties.js', function() {
|
|||
});
|
||||
|
||||
it('66.4 allows overwriting of public methods on lob instances', function(done) {
|
||||
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
|
||||
|
@ -179,13 +192,27 @@ describe('66. writeableProperties.js', function() {
|
|||
}
|
||||
}
|
||||
|
||||
conn.release(function(err) {
|
||||
lob.on("close", function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
conn.release(function(err) {
|
||||
should.not.exist(err);
|
||||
|
||||
done();
|
||||
});
|
||||
}); // lob close event
|
||||
|
||||
lob.on("error", function(err) {
|
||||
should.not.exist(err, "lob.on 'error' event.");
|
||||
});
|
||||
|
||||
lob.close(function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}); // 66.4
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue