Comparing version 1.0.0 to 1.1.0
# Change Log | ||
## node-oracledb v1.1.0 (3 Sep 2015) | ||
- Enhanced pool.release() to drop the session if it is known to be unusable, allowing a new session to be created. | ||
- Optimized query memory allocation to account for different database-to-client character set expansions. | ||
- Fixed build warnings on Windows with VS 2015. | ||
- Fixed truncation issue while fetching numbers as strings. | ||
- Fixed AIX-specific failures with queries and RETURNING INTO clauses. | ||
- Fixed a crash with NULL or uninitialized REF CURSOR OUT bind variables. | ||
- Fixed potential memory leak when connecting throws an error. | ||
- Added a check to throw an error sooner when a CURSOR type is used for IN or IN OUT binds. (Support is pending). | ||
- Temporarily disabling setting lobPrefetchSize | ||
## node-oracledb v1.0.0 (17 Aug 2015) | ||
- Implemented the Stream interface for CLOB and BLOB types, adding support for LOB queries, inserts, and PL/SQL LOB bind variables. | ||
- Implemented Stream interface for CLOB and BLOB types, adding support for | ||
LOB queries, inserts, and PL/SQL LOB bind variables | ||
@@ -7,0 +28,0 @@ - Added `fetchAsString` and `execute()` option `fetchInfo` properties to allow numbers, dates and ROWIDs to be fetched as strings. |
{ | ||
"name": "oracledb", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Oracle Database driver by Oracle Corp.", | ||
@@ -20,2 +20,3 @@ "license": "Apache-2.0", | ||
"driver", | ||
"add-on", | ||
"extension", | ||
@@ -22,0 +23,0 @@ "binding", |
@@ -1,7 +0,6 @@ | ||
# node-oracledb version 1.0 | ||
# node-oracledb version 1.1 | ||
## <a name="about"></a> 1. About node-oracledb | ||
The Oracle Database Node.js driver powers high performance | ||
Node.js applications. | ||
The node-oracledb add-on for Node.js powers high performance Oracle Database applications. | ||
@@ -32,3 +31,3 @@ Node-oracledb connects Node.js 0.10, Node.js 0.12, and io.js to | ||
- [Client Result Caching](http://docs.oracle.com/database/121/ADFNS/adfns_perf_scale.htm#ADFNS464) | ||
- [End-to-end tracing](http://docs.oracle.com/database/121/TGSQL/tgsql_trace.htm#CHDBDGIJ) | ||
- [End-to-end Tracing, Mid-tier Authentication, and Auditing](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#endtoend) | ||
- High Availability Features | ||
@@ -59,4 +58,6 @@ - [Fast Application Notification (FAN)](http://docs.oracle.com/database/121/ADFNS/adfns_avail.htm#ADFNS538) | ||
connection.execute( | ||
"SELECT department_id, department_name FROM departments WHERE department_id = :did", | ||
[180], // bind value for :did | ||
"SELECT department_id, department_name " + | ||
"FROM departments " + | ||
"WHERE manager_id < :id", | ||
[110], // bind value for :id | ||
function(err, result) | ||
@@ -73,3 +74,3 @@ { | ||
``` | ||
[ [ 180, 'Construction' ] ] | ||
[ [ 60, 'IT' ], [ 90, 'Executive' ], [ 100, 'Finance' ] ] | ||
``` | ||
@@ -92,3 +93,3 @@ | ||
See [Documentation for the Oracle Database Node.js Driver](https://github.com/oracle/node-oracledb/tree/master/doc/api.md). | ||
See [Documentation for the Oracle Database Node.js Add-on](https://github.com/oracle/node-oracledb/tree/master/doc/api.md). | ||
@@ -95,0 +96,0 @@ ## <a name="changes"></a> 5. Changes |
@@ -40,2 +40,28 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
var assist = exports; | ||
/* Mapping between table names and data types */ | ||
assist.allDataTypeNames = | ||
{ | ||
"oracledb_char" : "CHAR(2000)", | ||
"oracledb_nchar" : "NCHAR(1000)", | ||
"oracledb_varchar2" : "VARCHAR2(4000)", | ||
"oracledb_nvarchar2" : "NVARCHAR2(2000)", | ||
"oracledb_number" : "NUMBER", | ||
"oracledb_number2" : "NUMBER(15, 5)", | ||
"oracledb_float" : "FLOAT", | ||
"oracledb_float2" : "FLOAT(90)", | ||
"oracledb_binary_float" : "BINARY_FLOAT", | ||
"oracledb_double" : "BINARY_DOUBLE", | ||
"oracledb_date" : "DATE", | ||
"oracledb_timestamp1" : "TIMESTAMP", | ||
"oracledb_timestamp2" : "TIMESTAMP(5)", | ||
"oracledb_timestamp3" : "TIMESTAMP WITH TIME ZONE", | ||
"oracledb_timestamp4" : "TIMESTAMP (2) WITH TIME ZONE", | ||
"oracledb_timestamp5" : "TIMESTAMP WITH LOCAL TIME ZONE", | ||
"oracledb_timestamp6" : "TIMESTAMP (9) WITH LOCAL TIME ZONE", | ||
"oracledb_rowid" : "ROWID", | ||
"oracledb_myclobs" : "CLOB", | ||
"oracledb_myblobs" : "BLOB" | ||
}; | ||
assist.data = { | ||
@@ -114,5 +140,180 @@ specialChars: [ | ||
'y', 'z' | ||
], | ||
numbers: [ | ||
1, | ||
0, | ||
8, | ||
-8, | ||
1234, | ||
-1234, | ||
9876.54321, | ||
-9876.54321, | ||
0.01234, | ||
-0.01234, | ||
0.00000123, | ||
-0.00000123, | ||
1234567890.0123, | ||
-1234567890.0123 | ||
], | ||
dates: [ | ||
new Date(-100000000), | ||
new Date(0), | ||
new Date(10000000000), | ||
new Date(100000000000), | ||
new Date(1995, 11, 17), | ||
new Date('1995-12-17T03:24:00'), | ||
new Date('2015-07-23 21:00:00'), | ||
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) | ||
] | ||
}; | ||
assist.DATE_STRINGS = | ||
[ | ||
"TO_DATE('2005-01-06','YYYY-DD-MM') ", | ||
"TO_DATE('2005-09-01', 'YYYY-MM-DD')", | ||
"TO_DATE('2005-08-05', 'YYYY-MM-DD')", | ||
"TO_DATE('07-05-1998', 'MM-DD-YYYY')", | ||
"TO_DATE('07-05-1998', 'DD-MM-YYYY')", | ||
"TO_TIMESTAMP('1999-12-01 11:10:01.00123', 'YYYY-MM-DD HH:MI:SS.FF')" | ||
]; | ||
// for TIMESTAMP WITHOUT TIME ZONE | ||
assist.TIMESTAMP_STRINGS = | ||
[ | ||
"TO_TIMESTAMP('2005-01-06', 'YYYY-DD-MM') ", | ||
"TO_TIMESTAMP('2005-09-01', 'YYYY-MM-DD')", | ||
"TO_TIMESTAMP('2005-08-05', 'YYYY-MM-DD')", | ||
"TO_TIMESTAMP('07-05-1998', 'MM-DD-YYYY')", | ||
"TO_TIMESTAMP('07-05-1998', 'DD-MM-YYYY')", | ||
"TO_TIMESTAMP('2005-09-01 07:05:19', 'YYYY-MM-DD HH:MI:SS')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.1', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.12', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.123', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:01:10.0123', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.1234', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.00123', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.12345', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.123456', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.1234567', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:02:20.0000123', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.12345678', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('1999-12-01 11:00:00.123456789', 'YYYY-MM-DD HH:MI:SS.FF')", | ||
"TO_TIMESTAMP('10-Sep-02 14:10:10.123000', 'DD-Mon-RR HH24:MI:SS.FF')" | ||
]; | ||
// for TIMESTAMP WITH TIME ZONE | ||
assist.TIMESTAMP_TZ_STRINGS = | ||
[ | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.1 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.12 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.123 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.0123 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.1234 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.00123 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.12345 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.123456 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.1234567 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:20:02.0000123 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.12345678 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00.123456789 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')", | ||
"TO_TIMESTAMP_TZ('1999-12-01 11:00:00 -8:00', 'YYYY-MM-DD HH:MI:SS TZH:TZM')" | ||
]; | ||
// content serves as reference logs | ||
assist.content = | ||
{ | ||
dates: | ||
[ | ||
'01-06-2005', | ||
'01-09-2005', | ||
'05-08-2005', | ||
'05-07-1998', | ||
'07-05-1998', | ||
'01-12-1999' | ||
], | ||
timestamps1: | ||
[ | ||
'01-06-2005 00:00:00.000000', | ||
'01-09-2005 00:00:00.000000', | ||
'05-08-2005 00:00:00.000000', | ||
'05-07-1998 00:00:00.000000', | ||
'07-05-1998 00:00:00.000000', | ||
'01-09-2005 07:05:19.000000', | ||
'01-12-1999 11:00:00.100000', | ||
'01-12-1999 11:00:00.120000', | ||
'01-12-1999 11:00:00.123000', | ||
'01-12-1999 11:01:10.012300', | ||
'01-12-1999 11:00:00.123400', | ||
'01-12-1999 11:00:00.001230', | ||
'01-12-1999 11:00:00.123450', | ||
'01-12-1999 11:00:00.123456', | ||
'01-12-1999 11:00:00.123457', | ||
'01-12-1999 11:02:20.000012', | ||
'01-12-1999 11:00:00.123457', | ||
'01-12-1999 11:00:00.123457', | ||
'10-09-2002 14:10:10.123000' | ||
], | ||
timestamps2: | ||
[ | ||
'01-06-2005 00:00:00.00000', | ||
'01-09-2005 00:00:00.00000', | ||
'05-08-2005 00:00:00.00000', | ||
'05-07-1998 00:00:00.00000', | ||
'07-05-1998 00:00:00.00000', | ||
'01-09-2005 07:05:19.00000', | ||
'01-12-1999 11:00:00.10000', | ||
'01-12-1999 11:00:00.12000', | ||
'01-12-1999 11:00:00.12300', | ||
'01-12-1999 11:01:10.01230', | ||
'01-12-1999 11:00:00.12340', | ||
'01-12-1999 11:00:00.00123', | ||
'01-12-1999 11:00:00.12345', | ||
'01-12-1999 11:00:00.12346', | ||
'01-12-1999 11:00:00.12346', | ||
'01-12-1999 11:02:20.00001', | ||
'01-12-1999 11:00:00.12346', | ||
'01-12-1999 11:00:00.12346', | ||
'10-09-2002 14:10:10.12300' | ||
], | ||
timestamps5: | ||
[ | ||
'01-12-1999 11:00:00.100000 -08:00', | ||
'01-12-1999 11:00:00.120000 -08:00', | ||
'01-12-1999 11:00:00.123000 -08:00', | ||
'01-12-1999 11:00:00.012300 -08:00', | ||
'01-12-1999 11:00:00.123400 -08:00', | ||
'01-12-1999 11:00:00.001230 -08:00', | ||
'01-12-1999 11:00:00.123450 -08:00', | ||
'01-12-1999 11:00:00.123456 -08:00', | ||
'01-12-1999 11:00:00.123457 -08:00', | ||
'01-12-1999 11:20:02.000012 -08:00', | ||
'01-12-1999 11:00:00.123457 -08:00', | ||
'01-12-1999 11:00:00.123457 -08:00', | ||
'01-12-1999 11:00:00.000000 -08:00' | ||
], | ||
timestamps6: | ||
[ | ||
'01-12-1999 11:00:00.100000000 -08:00', | ||
'01-12-1999 11:00:00.120000000 -08:00', | ||
'01-12-1999 11:00:00.123000000 -08:00', | ||
'01-12-1999 11:00:00.012300000 -08:00', | ||
'01-12-1999 11:00:00.123400000 -08:00', | ||
'01-12-1999 11:00:00.001230000 -08:00', | ||
'01-12-1999 11:00:00.123450000 -08:00', | ||
'01-12-1999 11:00:00.123456000 -08:00', | ||
'01-12-1999 11:00:00.123456700 -08:00', | ||
'01-12-1999 11:20:02.000012300 -08:00', | ||
'01-12-1999 11:00:00.123456780 -08:00', | ||
'01-12-1999 11:00:00.123456789 -08:00', | ||
'01-12-1999 11:00:00.000000000 -08:00' | ||
] | ||
}; | ||
/******************************* Helper Functions ***********************************/ | ||
var StringBuffer = function() { | ||
@@ -152,27 +353,10 @@ this.buffer = []; | ||
assist.setup = function(connection, tableName, sqlCreate, array, done) { | ||
assist.setUp = function(connection, tableName, array, done) | ||
{ | ||
async.series([ | ||
function(callback) { | ||
connection.execute( | ||
sqlCreate, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
assist.createTable(connection, tableName, callback); | ||
}, | ||
function(callback) { | ||
async.forEach(array, function(element, cb) { | ||
connection.execute( | ||
"INSERT INTO " + tableName + " VALUES(:no, :bindValue)", | ||
{ no: array.indexOf(element), bindValue: element }, | ||
function(err) { | ||
should.not.exist(err); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
}); | ||
assist.insertDataArray(connection, tableName, array, callback); | ||
} | ||
@@ -182,2 +366,91 @@ ], done); | ||
assist.setUp4sql = function(connection, tableName, array, done) | ||
{ | ||
async.series([ | ||
function(callback) { | ||
assist.createTable(connection, tableName, callback); | ||
}, | ||
function(callback) { | ||
assist.insertData4sql(connection, tableName, array, callback); | ||
} | ||
], done); | ||
} | ||
assist.createTable = function(connection, tableName, done) | ||
{ | ||
var sqlCreate = assist.sqlCreateTable(tableName); | ||
connection.execute( | ||
sqlCreate, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
} | ||
assist.insertDataArray = function(connection, tableName, array, done) | ||
{ | ||
async.forEach(array, function(element, cb) { | ||
connection.execute( | ||
"INSERT INTO " + tableName + " VALUES(:no, :bindValue)", | ||
{ no: array.indexOf(element), bindValue: element }, | ||
{ autoCommit: true }, | ||
function(err) { | ||
should.not.exist(err); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
} | ||
assist.insertData4sql = function(connection, tableName, array, done) | ||
{ | ||
async.forEach(array, function(element, cb) { | ||
var sql = "INSERT INTO " + tableName + " VALUES(:no, " + element + " )"; | ||
connection.execute( | ||
sql, | ||
{ no: array.indexOf(element) }, | ||
function(err) { | ||
should.not.exist(err); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
} | ||
assist.sqlCreateTable = function(tableName) | ||
{ | ||
var createTab = | ||
"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(10), " + | ||
" content " + assist.allDataTypeNames[tableName] + ", " + | ||
" CONSTRAINT " + tableName + "_pk PRIMARY KEY (num) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
return createTab; | ||
} | ||
/************************* Functions for Verifiction *********************************/ | ||
assist.dataTypeSupport = function(connection, tableName, array, done) { | ||
@@ -194,8 +467,8 @@ connection.should.be.ok; | ||
if( (typeof result.rows[i].CONTENT) === 'string' ) | ||
result.rows[i].CONTENT.trim().should.eql(array[result.rows[i].NUM]); | ||
result.rows[i].CONTENT.trim().should.eql(array[result.rows[i].NUM]); | ||
else if( (typeof result.rows[i].CONTENT) === 'number' ) | ||
result.rows[i].CONTENT.should.eql(array[result.rows[i].NUM]); | ||
else | ||
else | ||
result.rows[i].CONTENT.toUTCString().should.eql(array[result.rows[i].NUM].toUTCString()); | ||
} | ||
} | ||
done(); | ||
@@ -206,5 +479,4 @@ } | ||
assist.resultSetSupport = function(connection, tableName, array, done) { | ||
connection.should.be.ok; | ||
var numRows = 3; // number of rows to return from each call to getRows() | ||
assist.verifyResultSet = function(connection, tableName, array, done) | ||
{ | ||
connection.execute( | ||
@@ -218,41 +490,103 @@ "SELECT * FROM " + tableName, | ||
(result.resultSet.metaData[1]).name.should.eql('CONTENT'); | ||
fetchRowsFromRS(result.resultSet); | ||
fetchRowsFromRS(result.resultSet, array, done); | ||
} | ||
); | ||
function fetchRowsFromRS(rs) { | ||
rs.getRows(numRows, function(err, rows) { | ||
should.not.exist(err); | ||
if(rows.length > 0) { | ||
for(var i = 0; i < rows.length; i++) { | ||
if( (typeof rows[i].CONTENT) === 'string' ) | ||
rows[i].CONTENT.trim().should.eql(array[rows[i].NUM]); | ||
else if( (typeof rows[i].CONTENT) === 'number' ) | ||
rows[i].CONTENT.should.eql(array[rows[i].NUM]); | ||
else | ||
rows[i].CONTENT.toUTCString().should.eql(array[rows[i].NUM].toUTCString()); | ||
} | ||
assist.verifyRefCursor = function(connection, tableName, array, 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(); | ||
} | ||
return fetchRowsFromRS(rs); | ||
} else if(rows.length == 0) { | ||
rs.close(function(err) { | ||
); | ||
}, | ||
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); | ||
done(); | ||
}); | ||
} else { | ||
var lengthLessThanZero = true; | ||
should.not.exist(lengthLessThanZero); | ||
done(); | ||
fetchRowsFromRS(result.outBinds[0], array, callback); | ||
} | ||
); | ||
}, | ||
function dropProcedure(callback) { | ||
connection.execute( | ||
"DROP PROCEDURE testproc", | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
} | ||
], done); | ||
} | ||
var numRows = 3; // number of rows to return from each call to getRows() | ||
function fetchRowsFromRS(rs, array, cb) | ||
{ | ||
rs.getRows(numRows, function(err, rows) { | ||
if(rows.length > 0) { | ||
for(var i = 0; i < rows.length; i++) { | ||
if( (typeof rows[i].CONTENT) === 'string' ) | ||
rows[i].CONTENT.trim().should.eql(array[rows[i].NUM]); | ||
else if( (typeof rows[i].CONTENT) === 'number' ) | ||
rows[i].CONTENT.should.eql(array[rows[i].NUM]); | ||
else | ||
rows[i].CONTENT.toUTCString().should.eql(array[rows[i].NUM].toUTCString()); | ||
} | ||
}); | ||
} | ||
return fetchRowsFromRS(rs, array, cb); | ||
} else { | ||
rs.close(function(err) { | ||
should.not.exist(err); | ||
cb(); | ||
}); | ||
} | ||
}); | ||
} | ||
assist.nullValueSupport = function(connection, tableName, done) { | ||
assist.selectOriginalData = function(connection, tableName, array, done) | ||
{ | ||
async.forEach(array, function(element, cb) { | ||
connection.execute( | ||
"SELECT * FROM " + tableName + " WHERE num = :no", | ||
{ no: array.indexOf(element) }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
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; | ||
var sqlInsert = "INSERT INTO " + tableName + " VALUES(:no, :bindValue)"; | ||
async.series([ | ||
function(callback) { | ||
function createTable(callback) { | ||
var sqlCreate = assist.sqlCreateTable(tableName); | ||
connection.execute( | ||
sqlInsert, | ||
{ no: 998, bindValue: '' }, | ||
sqlCreate, | ||
function(err) { | ||
@@ -262,22 +596,76 @@ should.not.exist(err); | ||
} | ||
); | ||
}, | ||
function JSEmptyString(callback) { | ||
var num = 1; | ||
connection.execute( | ||
sqlInsert, | ||
{ no: num, bindValue: '' }, | ||
function(err) { | ||
should.not.exist(err); | ||
verifyNull(num, callback); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
function JSNull(callback) { | ||
var num = 2; | ||
connection.execute( | ||
sqlInsert, | ||
{ no: 999, bindValue: null }, | ||
{ no: num, bindValue: null }, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
verifyNull(num, callback); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
function JSUndefined(callback) { | ||
var num = 3; | ||
var foobar; // undefined value | ||
connection.execute( | ||
"SELECT * FROM " + tableName + " WHERE num > :1 ORDER BY num", | ||
[990], | ||
function(err, result) { | ||
sqlInsert, | ||
{ no: num, bindValue: foobar }, | ||
function(err) { | ||
should.not.exist(err); | ||
// console.log(result); | ||
result.rows.should.eql([ [998, null], [999, null] ]); | ||
verifyNull(num, callback); | ||
} | ||
); | ||
}, | ||
function sqlNull(callback) { | ||
var num = 4; | ||
connection.execute( | ||
"INSERT INTO " + tableName + " VALUES(:1, NULL)", | ||
[num], | ||
function(err) { | ||
should.not.exist(err); | ||
verifyNull(num, callback); | ||
} | ||
); | ||
}, | ||
function sqlEmpty(callback) { | ||
var num = 5; | ||
connection.execute( | ||
"INSERT INTO " + tableName + " VALUES(:1, '')", | ||
[num], | ||
function(err) { | ||
should.not.exist(err); | ||
verifyNull(num, callback); | ||
} | ||
); | ||
}, | ||
function sqlNullColumn(callback) { | ||
var num = 6; | ||
connection.execute( | ||
"INSERT INTO " + tableName + "(num) VALUES(:1)", | ||
[num], | ||
function(err) { | ||
should.not.exist(err); | ||
verifyNull(num, callback); | ||
} | ||
); | ||
}, | ||
function dropTable(callback) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
@@ -288,4 +676,19 @@ } | ||
], done); | ||
} | ||
function verifyNull(id, cb) | ||
{ | ||
connection.execute( | ||
"SELECT content FROM " + tableName + " WHERE num = :1", | ||
[id], | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result); | ||
result.rows.should.eql([ [null] ]); | ||
cb(); | ||
} | ||
); | ||
} | ||
} | ||
module.exports = assist; |
@@ -38,3 +38,4 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
@@ -54,98 +55,57 @@ var should = require('should'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_double"; | ||
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 BINARY_DOUBLE " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var sqlDrop = "DROP table " + tableName; | ||
before( function(done){ | ||
oracledb.getConnection(credential, function(err, conn){ | ||
if(err) { console.error(err.message); return; } | ||
var connection = null; | ||
var tableName = "oracledb_double"; | ||
var numbers = assist.data.numbers; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
should.not.exist(err); | ||
connection = conn; | ||
connection.execute( | ||
sqlCreate, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
done(); | ||
} | ||
); | ||
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(); | ||
}); | ||
} | ||
); | ||
after('release connection', function(done) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
it.skip('supports BINARY_DOUBLE data type', function(done) { | ||
connection.should.be.ok; | ||
var numbers = [ | ||
1, | ||
0, | ||
8, | ||
-8, | ||
123456789, | ||
-123456789, | ||
9876.54321, | ||
-9876.54321, | ||
0.01234, | ||
-0.01234, | ||
0.00000123, | ||
-0.00000123 | ||
]; | ||
var sqlInsert = "INSERT INTO " + tableName + " VALUES(:no, :bindValue)"; | ||
async.forEach(numbers, function(num, callback) { | ||
describe.skip('31.1 testing BINARY_DOUBLE data', function() { | ||
before('create table, insert data',function(done) { | ||
assist.setUp(connection, tableName, numbers, done); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
sqlInsert, | ||
{ no: numbers.indexOf(num), bindValue: num }, | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
done(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
connection.execute( | ||
"SELECT * FROM " + tableName, | ||
[], | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result); | ||
for(var j = 0; j < numbers.length; j++) | ||
result.rows[j].CONTENT.should.be.exactly(numbers[result.rows[j].NUM]); | ||
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); | ||
}) | ||
}) | ||
}) |
@@ -38,3 +38,4 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
@@ -54,98 +55,57 @@ var should = require('should'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_binary_float"; | ||
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 BINARY_FLOAT " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var sqlDrop = "DROP table " + tableName; | ||
before( function(done){ | ||
oracledb.getConnection(credential, function(err, conn){ | ||
if(err) { console.error(err.message); return; } | ||
var connection = null; | ||
var tableName = "oracledb_binary_float"; | ||
var numbers = assist.data.numbers; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
should.not.exist(err); | ||
connection = conn; | ||
connection.execute( | ||
sqlCreate, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
done(); | ||
} | ||
); | ||
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(); | ||
}); | ||
} | ||
); | ||
after('release connection', function(done) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
it.skip('supports BINARY_FLOAT data type', function(done) { | ||
connection.should.be.ok; | ||
var numbers = [ | ||
1, | ||
0, | ||
8, | ||
-8, | ||
123456789, | ||
-123456789, | ||
9876.54321, | ||
-9876.54321, | ||
0.01234, | ||
-0.01234, | ||
0.00000123, | ||
-0.00000123 | ||
]; | ||
var sqlInsert = "INSERT INTO " + tableName + " VALUES(:no, :bindValue)"; | ||
async.forEach(numbers, function(num, callback) { | ||
describe.skip('30.1 testing BINARY_FLOAT data', function() { | ||
before('create table, insert data',function(done) { | ||
assist.setUp(connection, tableName, numbers, done); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
sqlInsert, | ||
{ no: numbers.indexOf(num), bindValue: num }, | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
done(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
connection.execute( | ||
"SELECT * FROM " + tableName, | ||
[], | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result); | ||
for(var j = 0; j < numbers.length; j++) | ||
result.rows[j].CONTENT.should.be.exactly(numbers[result.rows[j].NUM]); | ||
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); | ||
}) | ||
}) | ||
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); | ||
}) | ||
}) | ||
}) |
@@ -39,3 +39,4 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
@@ -52,3 +53,5 @@ var fs = require('fs'); | ||
describe('41. dataTypeBlob', function() { | ||
if(dbConfig.externalAuth){ | ||
this.timeout(10000); | ||
if(dbConfig.externalAuth){ | ||
var credential = { externalAuth: true, connectString: dbConfig.connectString }; | ||
@@ -61,185 +64,174 @@ } else { | ||
var tableName = "oracledb_myblobs"; | ||
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 BLOB " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
before(function(done) { | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
conn.execute( | ||
sqlCreate, | ||
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, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
}); | ||
}) | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
done(); | ||
}); | ||
} | ||
); | ||
}) | ||
it('41.1.1 stores BLOB value correctly', function(done) { | ||
connection.should.be.ok; | ||
async.series([ | ||
function blobinsert1(callback) { | ||
var streamEndEventFired = false; | ||
setTimeout( function() { | ||
streamEndEventFired.should.equal(true, "inStream does not call 'end' event!") | ||
callback(); | ||
}, 2000); | ||
it('41.1 processes null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
connection.execute( | ||
"INSERT INTO oracledb_myblobs (num, content) VALUES (:n, EMPTY_BLOB()) RETURNING content INTO :lobbv", | ||
{ n: 2, lobbv: {type: oracledb.BLOB, dir: oracledb.BIND_OUT} }, | ||
{ autoCommit: false }, // a transaction needs to span the INSERT and pipe() | ||
function(err, result) { | ||
should.not.exist(err); | ||
(result.rowsAffected).should.be.exactly(1); | ||
(result.outBinds.lobbv.length).should.be.exactly(1); | ||
var inStream = fs.createReadStream(inFileName); | ||
inStream.on('error', function(err) { | ||
should.not.exist(err, "inStream.on 'end' event"); | ||
}); | ||
it('41.2 stores BLOB value correctly', function(done) { | ||
connection.should.be.ok; | ||
async.series([ | ||
function blobinsert1(callback) { | ||
var streamEndEventFired = false; | ||
setTimeout( function() { | ||
streamEndEventFired.should.equal(true, "inStream does not call 'end' event!") | ||
callback(); | ||
}, 500); | ||
inStream.on('end', function() { | ||
streamEndEventFired = true; | ||
// now commit updates | ||
connection.commit( function(err) { | ||
should.not.exist(err); | ||
}); | ||
}); | ||
connection.execute( | ||
"INSERT INTO oracledb_myblobs (num, content) VALUES (:n, EMPTY_BLOB()) RETURNING content INTO :lobbv", | ||
{ n: 2, lobbv: {type: oracledb.BLOB, dir: oracledb.BIND_OUT} }, | ||
{ autoCommit: false }, // a transaction needs to span the INSERT and pipe() | ||
function(err, result) { | ||
should.not.exist(err); | ||
(result.rowsAffected).should.be.exactly(1); | ||
(result.outBinds.lobbv.length).should.be.exactly(1); | ||
var inStream = fs.createReadStream(inFileName); | ||
inStream.on('error', function(err) { | ||
should.not.exist(err, "inStream.on 'end' event"); | ||
}); | ||
var lob = result.outBinds.lobbv[0]; | ||
inStream.on('end', function() { | ||
streamEndEventFired = true; | ||
// now commit updates | ||
connection.commit( function(err) { | ||
should.not.exist(err); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'error' event"); | ||
}); | ||
}); | ||
var lob = result.outBinds.lobbv[0]; | ||
inStream.pipe(lob); // pipes the data to the BLOB | ||
} | ||
); | ||
}, | ||
function blobstream1(callback) { | ||
var streamFinishEventFired = false; | ||
setTimeout( function() { | ||
streamFinishEventFired.should.equal(true, "stream does not call 'finish' Event!"); | ||
callback(); | ||
}, 2000); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'error' event"); | ||
}); | ||
connection.execute( | ||
"SELECT content FROM oracledb_myblobs WHERE num = :n", | ||
{ n: 2 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
inStream.pipe(lob); // pipes the data to the BLOB | ||
} | ||
); | ||
}, | ||
function blobstream1(callback) { | ||
var streamFinishEventFired = false; | ||
setTimeout( function() { | ||
streamFinishEventFired.should.equal(true, "stream does not call 'finish' Event!"); | ||
callback(); | ||
}, 500); | ||
var lob = result.rows[0][0]; | ||
should.exist(lob); | ||
connection.execute( | ||
"SELECT content FROM oracledb_myblobs WHERE num = :n", | ||
{ n: 2 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
var lob = result.rows[0][0]; | ||
should.exist(lob); | ||
var outStream = fs.createWriteStream(outFileName); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
outStream.on('error', function(err) { | ||
should.not.exist(err, "outStream.on 'end' event"); | ||
}); | ||
var outStream = fs.createWriteStream(outFileName); | ||
outStream.on('error', function(err) { | ||
should.not.exist(err, "outStream.on 'end' event"); | ||
}); | ||
lob.pipe(outStream); | ||
outStream.on('finish', function() { | ||
fs.readFile( inFileName, function(err, originalData) { | ||
should.not.exist(err); | ||
fs.readFile( outFileName, function(err, generatedData) { | ||
lob.pipe(outStream); | ||
outStream.on('finish', function() { | ||
fs.readFile( inFileName, function(err, originalData) { | ||
should.not.exist(err); | ||
originalData.should.eql(generatedData); | ||
fs.readFile( outFileName, function(err, generatedData) { | ||
should.not.exist(err); | ||
originalData.should.eql(generatedData); | ||
streamFinishEventFired = true; | ||
streamFinishEventFired = true; | ||
}); | ||
}); | ||
}); | ||
}); // finish event | ||
} | ||
); | ||
}, | ||
function blobstream2(callback) { | ||
var lobEndEventFired = false; | ||
var lobDataEventFired = false; | ||
setTimeout( function(){ | ||
lobDataEventFired.should.equal(true, "lob does not call 'data' event!"); | ||
lobEndEventFired.should.equal(true, "lob does not call 'end' event!"); | ||
callback(); | ||
}, 500); | ||
}); // finish event | ||
} | ||
); | ||
}, | ||
function blobstream2(callback) { | ||
var lobEndEventFired = false; | ||
var lobDataEventFired = false; | ||
setTimeout( function(){ | ||
lobDataEventFired.should.equal(true, "lob does not call 'data' event!"); | ||
lobEndEventFired.should.equal(true, "lob does not call 'end' event!"); | ||
callback(); | ||
}, 2000); | ||
connection.execute( | ||
"SELECT content FROM oracledb_myblobs WHERE num = :n", | ||
{ n: 2 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
var blob = Buffer(0); | ||
var blobLength = 0; | ||
var lob = result.rows[0][0]; | ||
connection.execute( | ||
"SELECT content FROM oracledb_myblobs WHERE num = :n", | ||
{ n: 2 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
var blob = Buffer(0); | ||
var blobLength = 0; | ||
var lob = result.rows[0][0]; | ||
should.exist(lob); | ||
should.exist(lob); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
lob.on('data', function(chunk) { | ||
// console.log("lob.on 'data' event"); | ||
// console.log(' - got %d bytes of data', chunk.length); | ||
lobDataEventFired = true; | ||
blobLength = blobLength + chunk.length; | ||
blob = Buffer.concat([blob, chunk], blobLength); | ||
}); | ||
lob.on('end', function() { | ||
fs.readFile( inFileName, function(err, data) { | ||
should.not.exist(err); | ||
lobEndEventFired = true; | ||
data.length.should.be.exactly(blob.length); | ||
data.should.eql(blob); | ||
lob.on('data', function(chunk) { | ||
// console.log("lob.on 'data' event"); | ||
// console.log(' - got %d bytes of data', chunk.length); | ||
lobDataEventFired = true; | ||
blobLength = blobLength + chunk.length; | ||
blob = Buffer.concat([blob, chunk], blobLength); | ||
}); | ||
}); // end event | ||
lob.on('end', function() { | ||
fs.readFile( inFileName, function(err, data) { | ||
should.not.exist(err); | ||
lobEndEventFired = true; | ||
data.length.should.be.exactly(blob.length); | ||
data.should.eql(blob); | ||
}); | ||
}); // end event | ||
} | ||
); | ||
} | ||
], done); | ||
} | ||
); | ||
} | ||
], done); | ||
}) // 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); | ||
}) | ||
}) | ||
}) |
@@ -34,4 +34,6 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -41,3 +43,3 @@ var dbConfig = require('./dbConfig.js'); | ||
describe('22. dataTypeChar.js', function(){ | ||
var connection = false; | ||
if(dbConfig.externalAuth){ | ||
@@ -49,61 +51,62 @@ var credential = { externalAuth: true, connectString: dbConfig.connectString }; | ||
var tableName = "oracledb_datatype_char"; | ||
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 CHAR(2000) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var connection = null; | ||
var tableName = "oracledb_char"; | ||
var strLen = [100, 1000, 2000]; // char string length | ||
var strs = [ | ||
assist.createCharString(strLen[0]), | ||
assist.createCharString(strLen[1]), | ||
assist.createCharString(strLen[2]), | ||
]; | ||
before(function(done) { | ||
var strs = | ||
[ | ||
assist.createCharString(strLen[0]), | ||
assist.createCharString(strLen[1]), | ||
assist.createCharString(strLen[2]), | ||
]; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, strs, done); | ||
done(); | ||
}); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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); | ||
}) | ||
}) | ||
it('22.1 supports CHAR data', function(done) { | ||
assist.dataTypeSupport(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); | ||
}) | ||
}) | ||
it('22.2 resultSet stores CHAR data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, strs, done); | ||
}) | ||
it('22.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -39,3 +39,4 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
@@ -52,3 +53,4 @@ var fs = require('fs'); | ||
describe('40. dataTypeClob.js', function() { | ||
this.timeout(10000); | ||
if(dbConfig.externalAuth){ | ||
@@ -62,183 +64,172 @@ var credential = { externalAuth: true, connectString: dbConfig.connectString }; | ||
var tableName = "oracledb_myclobs"; | ||
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 CLOB " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
before(function(done) { | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
conn.execute( | ||
sqlCreate, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
done(); | ||
} | ||
); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
done(); | ||
}); | ||
} | ||
); | ||
after('release connection', function(done) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
it('40.1 processes null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
describe('40.1 testing CLOB data type', function() { | ||
before('create table', function(done) { | ||
assist.createTable(connection, tableName, done); | ||
}) | ||
it('40.2 stores CLOB value correctly', function(done) { | ||
connection.should.be.ok; | ||
async.series([ | ||
function clobinsert1(callback) { | ||
var streamEndEventFired = false; | ||
setTimeout( function() { | ||
streamEndEventFired.should.equal(true, "inStream does not call 'end' event!") | ||
callback(); | ||
}, 500); | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
}) | ||
connection.execute( | ||
"INSERT INTO oracledb_myclobs (num, content) VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv", | ||
{ n: 1, lobbv: {type: oracledb.CLOB, dir: oracledb.BIND_OUT} }, | ||
{ autoCommit: false }, // a transaction needs to span the INSERT and pipe() | ||
function(err, result) { | ||
should.not.exist(err); | ||
(result.rowsAffected).should.be.exactly(1); | ||
(result.outBinds.lobbv.length).should.be.exactly(1); | ||
it('40.1.1 stores CLOB value correctly', function(done) { | ||
connection.should.be.ok; | ||
async.series([ | ||
function clobinsert1(callback) { | ||
var streamEndEventFired = false; | ||
setTimeout( function() { | ||
streamEndEventFired.should.equal(true, "inStream does not call 'end' event!") | ||
callback(); | ||
}, 2000); | ||
var inStream = fs.createReadStream(inFileName); | ||
var lob = result.outBinds.lobbv[0]; | ||
connection.execute( | ||
"INSERT INTO oracledb_myclobs (num, content) VALUES (:n, EMPTY_CLOB()) RETURNING content INTO :lobbv", | ||
{ n: 1, lobbv: {type: oracledb.CLOB, dir: oracledb.BIND_OUT} }, | ||
{ autoCommit: false }, // a transaction needs to span the INSERT and pipe() | ||
function(err, result) { | ||
should.not.exist(err); | ||
(result.rowsAffected).should.be.exactly(1); | ||
(result.outBinds.lobbv.length).should.be.exactly(1); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'error' event"); | ||
}); | ||
var inStream = fs.createReadStream(inFileName); | ||
var lob = result.outBinds.lobbv[0]; | ||
inStream.on('error', function(err) { | ||
should.not.exist(err, "inStream.on 'end' event"); | ||
}); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'error' event"); | ||
}); | ||
inStream.on('end', function() { | ||
streamEndEventFired = true; | ||
// now commit updates | ||
connection.commit( function(err) { | ||
should.not.exist(err); | ||
inStream.on('error', function(err) { | ||
should.not.exist(err, "inStream.on 'end' event"); | ||
}); | ||
}); | ||
inStream.pipe(lob); // copies the text to the CLOB | ||
} | ||
); | ||
}, | ||
function clobstream1(callback) { | ||
var streamFinishEventFired = false; | ||
setTimeout( function() { | ||
streamFinishEventFired.should.equal(true, "stream does not call 'Finish' Event!"); | ||
callback(); | ||
}, 500); | ||
connection.execute( | ||
"SELECT content FROM oracledb_myclobs WHERE num = :n", | ||
{ n: 1 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
inStream.on('end', function() { | ||
streamEndEventFired = true; | ||
// now commit updates | ||
connection.commit( function(err) { | ||
should.not.exist(err); | ||
}); | ||
}); | ||
inStream.pipe(lob); // copies the text to the CLOB | ||
} | ||
); | ||
}, | ||
function clobstream1(callback) { | ||
var streamFinishEventFired = false; | ||
setTimeout( function() { | ||
streamFinishEventFired.should.equal(true, "stream does not call 'Finish' Event!"); | ||
callback(); | ||
}, 2000); | ||
var lob = result.rows[0][0]; | ||
should.exist(lob); | ||
lob.setEncoding('utf8'); | ||
connection.execute( | ||
"SELECT content FROM oracledb_myclobs WHERE num = :n", | ||
{ n: 1 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
var lob = result.rows[0][0]; | ||
should.exist(lob); | ||
lob.setEncoding('utf8'); | ||
var outStream = fs.createWriteStream(outFileName); | ||
outStream.on('error', function(err) { | ||
should.not.exist(err, "outStream.on 'end' event"); | ||
}); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
lob.pipe(outStream); | ||
var outStream = fs.createWriteStream(outFileName); | ||
outStream.on('error', function(err) { | ||
should.not.exist(err, "outStream.on 'end' event"); | ||
}); | ||
outStream.on('finish', function() { | ||
fs.readFile( inFileName, { encoding: 'utf8' }, function(err, originalData) { | ||
should.not.exist(err); | ||
lob.pipe(outStream); | ||
outStream.on('finish', function() { | ||
fs.readFile( outFileName, { encoding: 'utf8' }, function(err, generatedData) { | ||
fs.readFile( inFileName, { encoding: 'utf8' }, function(err, originalData) { | ||
should.not.exist(err); | ||
originalData.should.equal(generatedData); | ||
fs.readFile( outFileName, { encoding: 'utf8' }, function(err, generatedData) { | ||
should.not.exist(err); | ||
originalData.should.equal(generatedData); | ||
streamFinishEventFired = true; | ||
streamFinishEventFired = true; | ||
}); | ||
}); | ||
}); | ||
}) | ||
} | ||
); | ||
}, | ||
function clobstream2(callback) { | ||
var lobEndEventFired = false; | ||
var lobDataEventFired = false; | ||
setTimeout( function(){ | ||
lobDataEventFired.should.equal(true, "lob does not call 'data' event!"); | ||
lobEndEventFired.should.equal(true, "lob does not call 'end' event!"); | ||
callback(); | ||
}, 500); | ||
}) | ||
} | ||
); | ||
}, | ||
function clobstream2(callback) { | ||
var lobEndEventFired = false; | ||
var lobDataEventFired = false; | ||
setTimeout( function(){ | ||
lobDataEventFired.should.equal(true, "lob does not call 'data' event!"); | ||
lobEndEventFired.should.equal(true, "lob does not call 'end' event!"); | ||
callback(); | ||
}, 2000); | ||
connection.execute( | ||
"SELECT content FROM oracledb_myclobs WHERE num = :n", | ||
{ n: 1 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
connection.execute( | ||
"SELECT content FROM oracledb_myclobs WHERE num = :n", | ||
{ n: 1 }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
var clob = ''; | ||
var lob = result.rows[0][0]; | ||
should.exist(lob); | ||
lob.setEncoding('utf8'); // set the encoding so we get a 'string' not a 'buffer' | ||
lob.on('data', function(chunk) { | ||
// console.log("lob.on 'data' event"); | ||
// console.log(' - got %d bytes of data', chunk.length); | ||
lobDataEventFired = true; | ||
clob += chunk; | ||
}); | ||
var clob = ''; | ||
var lob = result.rows[0][0]; | ||
should.exist(lob); | ||
lob.setEncoding('utf8'); // set the encoding so we get a 'string' not a 'buffer' | ||
lob.on('data', function(chunk) { | ||
// console.log("lob.on 'data' event"); | ||
// console.log(' - got %d bytes of data', chunk.length); | ||
lobDataEventFired = true; | ||
clob += chunk; | ||
}); | ||
lob.on('end', function() { | ||
fs.readFile( inFileName, { encoding: 'utf8' }, function(err, data) { | ||
should.not.exist(err); | ||
lobEndEventFired = true; | ||
data.length.should.be.exactly(clob.length); | ||
data.should.equal(clob); | ||
lob.on('end', function() { | ||
fs.readFile( inFileName, { encoding: 'utf8' }, function(err, data) { | ||
should.not.exist(err); | ||
lobEndEventFired = true; | ||
data.length.should.be.exactly(clob.length); | ||
data.should.equal(clob); | ||
}); | ||
}); | ||
}); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
} | ||
); | ||
} | ||
], done); | ||
lob.on('error', function(err) { | ||
should.not.exist(err, "lob.on 'end' event"); | ||
}); | ||
} | ||
); | ||
} | ||
], done); // async | ||
}) // 40.1.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); | ||
}) | ||
}) | ||
}) | ||
}) |
@@ -34,4 +34,7 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var async = require('async'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -42,3 +45,3 @@ var dbConfig = require('./dbConfig.js'); | ||
if(dbConfig.externalAuth){ | ||
if(dbConfig.externalAuth) { | ||
var credential = { externalAuth: true, connectString: dbConfig.connectString }; | ||
@@ -49,62 +52,100 @@ } else { | ||
var connection = false; | ||
var tableName = "oracledb_datatype_date"; | ||
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 DATE " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var dates = [ | ||
new Date(-100000000), | ||
new Date(0), | ||
new Date(10000000000), | ||
new Date(100000000000) | ||
]; | ||
before(function(done) { | ||
var connection = null; | ||
var tableName = "oracledb_date"; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, dates, done); | ||
done(); | ||
}); | ||
}) | ||
after('release connection', function(done) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
} | ||
); | ||
} | ||
); | ||
}) | ||
it('32.1.1 works well with SELECT query', function(done) { | ||
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 | ||
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); | ||
}) | ||
}) | ||
it('32.1 supports DATE data type', function(done) { | ||
assist.dataTypeSupport(connection, tableName, dates, done); | ||
}) | ||
it('32.2 resultSet stores DATE data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, dates, done); | ||
}) | ||
it('32.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
describe('32.3 insert SQL Date data', function(done) { | ||
var dates = assist.DATE_STRINGS; | ||
before(function(done) { | ||
assist.setUp4sql(connection, tableName, dates, done); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
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) { | ||
var bv = dates.indexOf(date); | ||
connection.execute( | ||
"SELECT num, TO_CHAR(content, 'DD-MM-YYYY') AS TS_DATA FROM " + tableName + " WHERE num = :no", | ||
{ no: bv }, | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows); | ||
(result.rows[0].TS_DATA).should.equal(assist.content.dates[bv]); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
}) // end of 32.3 suite | ||
}) |
@@ -34,4 +34,6 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -48,69 +50,55 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_float"; | ||
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 FLOAT " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var numbers = [ | ||
1, | ||
0, | ||
8, | ||
-8, | ||
123456789, | ||
-123456789, | ||
9876.54321, | ||
-9876.54321, | ||
0.01234, | ||
-0.01234, | ||
123456789.0123, | ||
-123456789.0123 | ||
]; | ||
var connection = null; | ||
var tableName = "oracledb_float"; | ||
var numbers = assist.data.numbers; | ||
before(function(done) { | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, numbers, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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); | ||
}) | ||
}) | ||
it('28.1 supports FLOAT data type', function(done) { | ||
assist.dataTypeSupport(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); | ||
}) | ||
}) | ||
it('28.2 resultSet stores FLOAT data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, numbers, done); | ||
}) | ||
it('28.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -34,4 +34,6 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -48,69 +50,56 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_float"; | ||
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 FLOAT(90) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var numbers = [ | ||
1, | ||
0, | ||
8, | ||
-8, | ||
123456789, | ||
-123456789, | ||
9876.54321, | ||
-9876.54321, | ||
0.01234, | ||
-0.01234, | ||
123456789.0123, | ||
-123456789.0123 | ||
]; | ||
before(function(done) { | ||
var connection = null; | ||
var tableName = "oracledb_float2"; | ||
var numbers = assist.data.numbers; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, numbers, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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); | ||
}) | ||
}) | ||
it('29.1 supports FLOAT(p) data type', function(done) { | ||
assist.dataTypeSupport(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); | ||
}) | ||
}) | ||
it('29.2 resultSet stores FLOAT(p) data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, numbers, done); | ||
}) | ||
it('29.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -31,7 +31,9 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
* 21 - 50 are reserved for data type supporting tests | ||
* 51 - are for other tests | ||
* 51 onwards are for other tests | ||
* | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -48,22 +50,4 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_nchar"; | ||
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 NCHAR(1000) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var connection = null; | ||
var tableName = "oracledb_nchar"; | ||
@@ -74,35 +58,53 @@ var strLen = [10, 100, 500, 1000]; | ||
strs[i] = assist.createCharString(strLen[i]); | ||
before(function(done) { | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, strs, done); | ||
done(); | ||
}); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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); | ||
}) | ||
}) | ||
it('23.1 supports NCHAR data type', function(done) { | ||
assist.dataTypeSupport(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); | ||
}) | ||
}) | ||
it('23.2 resultSet supports NCHAR data type', function(done) { | ||
assist.resultSetSupport(connection, tableName, strs, done); | ||
}) | ||
it('23.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -34,4 +34,6 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -48,70 +50,57 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_number"; | ||
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 NUMBER " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var numbers = [ | ||
1, | ||
0, | ||
8, | ||
-8, | ||
1234, | ||
-1234, | ||
9876.54321, | ||
-9876.54321, | ||
0.01234, | ||
-0.01234, | ||
0.00000123, | ||
-0.00000123 | ||
]; | ||
var connection = null; | ||
var tableName = "oracledb_number"; | ||
var numbers = assist.data.numbers; | ||
before(function(done) { | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, numbers, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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); | ||
}) | ||
}) | ||
it('26.1 supports NUMBER data type', function(done) { | ||
assist.dataTypeSupport(connection, tableName, numbers, done); | ||
}) | ||
it('26.2 resultSet stores NUMBER data correctly', function(done) { | ||
assist.resultSetSupport(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); | ||
}) | ||
}) | ||
it('26.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -34,2 +34,3 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
@@ -50,119 +51,105 @@ var oracledb = require('oracledb'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_number2"; | ||
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 NUMBER(9, 5) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var numbers = [ | ||
1, | ||
0, | ||
8, | ||
-8, | ||
1234, | ||
-1234, | ||
9876.54321, | ||
-9876.54321, | ||
0.01234, | ||
-0.01234, | ||
0.00000123 | ||
]; | ||
before(function(done) { | ||
var connection = null; | ||
var tableName = "oracledb_number2"; | ||
var numbers = assist.data.numbers; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, numbers, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
} | ||
); | ||
}) | ||
it('27.1 supports NUMBER(p, s) data type', function(done) { | ||
connection.should.be.ok; | ||
connection.execute( | ||
"SELECT * FROM " + tableName, | ||
[], | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result); | ||
for(var j = 0; j < numbers.length; j++) { | ||
if(numbers[result.rows[j].NUM] == 0.00000123) | ||
result.rows[j].CONTENT.should.be.exactly(0); | ||
else | ||
result.rows[j].CONTENT.should.be.exactly(numbers[result.rows[j].NUM]); | ||
} | ||
done(); | ||
} | ||
); | ||
}) | ||
it('27.2 resultSet stores NUMBER(p, s) data correctly', function(done) { | ||
connection.should.be.ok; | ||
var numRows = 3; // number of rows to return from each call to getRows() | ||
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); | ||
} | ||
); | ||
function fetchRowsFromRS(rs) { | ||
rs.getRows(numRows, function(err, rows) { | ||
should.not.exist(err); | ||
if(rows.length > 0) { | ||
for(var i = 0; i < rows.length; i++) { | ||
if(numbers[rows[i].NUM] == 0.00000123) | ||
rows[i].CONTENT.should.be.exactly(0); | ||
else | ||
rows[i].CONTENT.should.be.exactly(numbers[rows[i].NUM]); | ||
); | ||
}) | ||
it('27.1.1 SELECT query', function(done) { | ||
connection.should.be.ok; | ||
connection.execute( | ||
"SELECT * FROM " + tableName, | ||
[], | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result); | ||
for(var j = 0; j < numbers.length; j++) { | ||
if(Math.abs( numbers[result.rows[j].NUM] ) == 0.00000123) | ||
result.rows[j].CONTENT.should.be.exactly(0); | ||
else | ||
result.rows[j].CONTENT.should.be.exactly(numbers[result.rows[j].NUM]); | ||
} | ||
return fetchRowsFromRS(rs); | ||
} else if(rows.length == 0) { | ||
rs.close(function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
} else { | ||
var lengthLessThanZero = true; | ||
should.not.exist(lengthLessThanZero); | ||
done(); | ||
} | ||
}); | ||
} | ||
); | ||
}) // 27.1.1 | ||
it('27.1.2 resultSet stores NUMBER(p, s) data correctly', function(done) { | ||
connection.should.be.ok; | ||
var numRows = 3; // number of rows to return from each call to getRows() | ||
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); | ||
} | ||
); | ||
function fetchRowsFromRS(rs) { | ||
rs.getRows(numRows, function(err, rows) { | ||
should.not.exist(err); | ||
if(rows.length > 0) { | ||
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 | ||
rows[i].CONTENT.should.be.exactly(numbers[rows[i].NUM]); | ||
} | ||
return fetchRowsFromRS(rs); | ||
} else if(rows.length == 0) { | ||
rs.close(function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
} else { | ||
var lengthLessThanZero = true; | ||
should.not.exist(lengthLessThanZero); | ||
done(); | ||
} | ||
}); | ||
} | ||
}) | ||
}) // 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); | ||
}) | ||
}) | ||
it('27.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -34,4 +34,6 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -48,22 +50,4 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_nvarchar2"; | ||
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 NVARCHAR2(2000) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var connection = null; | ||
var tableName = "oracledb_nvarchar2"; | ||
@@ -75,34 +59,52 @@ var strLen = [10 ,100, 1000, 2000]; // char string length | ||
before(function(done) { | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, strs, done); | ||
done(); | ||
}); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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); | ||
}) | ||
}) | ||
it('25.1 supports NVARCHAR2 data in various lengths', function(done) { | ||
assist.dataTypeSupport(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); | ||
}) | ||
}) | ||
it('25.2 resultSet stores NVARCHAR2 data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, strs, done); | ||
}) | ||
it('25.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -37,6 +37,8 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict" | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var async = require('async'); | ||
var assist = require('./dataTypeAssist.js'); | ||
var dbConfig = require('./dbConfig.js'); | ||
@@ -52,78 +54,69 @@ | ||
var connection = false; | ||
before(function(done) { | ||
var connection = null; | ||
var tableName = "oracledb_rowid"; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
done(); | ||
done(); | ||
}); | ||
}) | ||
after(function(done) { | ||
connection.release(function(err) { | ||
if(err) { console.error(err.message); return; } | ||
done(); | ||
after('release connection', function(done) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
it('39.1 supports ROWID data type', function(done) { | ||
connection.should.be.ok; | ||
var createTable = | ||
"BEGIN \ | ||
DECLARE \ | ||
e_table_exists EXCEPTION; \ | ||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \ | ||
BEGIN \ | ||
EXECUTE IMMEDIATE ('DROP TABLE oracledb_row'); \ | ||
EXCEPTION \ | ||
WHEN e_table_exists \ | ||
THEN NULL; \ | ||
END; \ | ||
EXECUTE IMMEDIATE (' \ | ||
CREATE TABLE oracledb_row ( \ | ||
ID NUMBER, \ | ||
RID ROWID \ | ||
) \ | ||
'); \ | ||
EXECUTE IMMEDIATE (' \ | ||
INSERT INTO oracledb_row(ID) VALUES(1) \ | ||
'); \ | ||
EXECUTE IMMEDIATE (' \ | ||
UPDATE oracledb_row T SET RID = T.ROWID \ | ||
'); \ | ||
END; "; | ||
async.series([ | ||
function(callback) { | ||
connection.execute( | ||
createTable, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
"SELECT * FROM oracledb_row", | ||
[], | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.exist(err); | ||
err.message.should.startWith('NJS-010:'); // unsupported data type in select list | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
"DROP TABLE oracledb_row", | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
} | ||
], done); | ||
describe('39.1 testing ROWID data type', function() { | ||
before(function(done) { | ||
async.series([ | ||
function makeTable(callback) { | ||
assist.createTable(connection, tableName, done); | ||
}, | ||
function insertOneRow(callback) { | ||
connection.execute( | ||
"INSERT INTO " + tableName + "(num) VALUES(1)", | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function fillRowid(callback) { | ||
connection.execute( | ||
"UPDATE " + tableName + " T SET content = T.ROWID", | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
} | ||
], done); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
}) | ||
it('39.1.1 is still unsupported data type', function(done) { | ||
connection.execute( | ||
"SELECT * FROM " + tableName, | ||
function(err, result) { | ||
should.exist(err); | ||
err.message.should.startWith('NJS-010:'); // unsupported data type in select list | ||
done(); | ||
} | ||
); | ||
}) | ||
}) | ||
}) |
@@ -34,2 +34,3 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
@@ -50,61 +51,100 @@ var oracledb = require('oracledb'); | ||
var connection = false; | ||
var tableName = "oracledb_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 " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var timestamps = [ | ||
new Date(-100000000), | ||
new Date(0), | ||
new Date(10000000000), | ||
new Date(100000000000) | ||
]; | ||
before(function(done) { | ||
var connection = null; | ||
var tableName = "oracledb_timestamp1"; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, timestamps, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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 | ||
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); | ||
}) | ||
}) | ||
it('33.1 supports TIMESTAMP data type', function(done) { | ||
assist.dataTypeSupport(connection, tableName, timestamps, done); | ||
}) | ||
it('33.2 resultSet stores TIMESTAMP data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, timestamps, done); | ||
}) | ||
it('33.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(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, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
}) // 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) { | ||
var bv = timestamps.indexOf(timestamp); | ||
connection.execute( | ||
"SELECT num, TO_CHAR(content, 'DD-MM-YYYY HH24:MI:SS.FF') AS TS_DATA FROM " + tableName + " WHERE num = :no", | ||
{ no: bv }, | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows); | ||
(result.rows[0].TS_DATA).should.equal(assist.content.timestamps1[bv]); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
}) // end of 33.3 suite | ||
}) |
@@ -34,4 +34,7 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var async = require('async'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -48,61 +51,99 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_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(5) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var timestamps = [ | ||
new Date(-100000000), | ||
new Date(0), | ||
new Date(10000000000), | ||
new Date(100000000000) | ||
]; | ||
before(function(done) { | ||
var connection = null; | ||
var tableName = "oracledb_timestamp2"; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, timestamps, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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 | ||
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); | ||
}) | ||
}) | ||
it('34.1 supports TIMESTAMP(p) data type', function(done) { | ||
assist.dataTypeSupport(connection, tableName, timestamps, done); | ||
}) | ||
it('34.2 resultSet stores TIMESTAMP data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, timestamps, done); | ||
}) | ||
it('34.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
describe('34.3 testing database TIMESTAMP(p)', function(done) { | ||
var timestamps = assist.TIMESTAMP_STRINGS; | ||
before(function(done) { | ||
assist.setUp4sql(connection, tableName, timestamps, done); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
}) // 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) { | ||
var bv = timestamps.indexOf(timestamp); | ||
connection.execute( | ||
"SELECT num, TO_CHAR(content, 'DD-MM-YYYY HH24:MI:SS.FF') AS TS_DATA FROM " + tableName + " WHERE num = :no", | ||
{ no: bv }, | ||
{ outFormat: oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows); | ||
(result.rows[0].TS_DATA).should.equal(assist.content.timestamps2[bv]); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
}) // end of 34.3 suite | ||
}) |
@@ -37,2 +37,3 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
@@ -132,7 +133,3 @@ var oracledb = require('oracledb'); | ||
err.message.should.startWith('NJS-010:'); // unsupported data type in select list | ||
/* | ||
console.log(result); | ||
for(var j = 0; j < timestamps.length; j++) | ||
result.rows[j].CONTENT.toUTCString().should.eql(timestamps[result.rows[j].NUM].toUTCString()); | ||
*/ | ||
done(); | ||
@@ -139,0 +136,0 @@ } |
@@ -37,2 +37,3 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
@@ -39,0 +40,0 @@ var oracledb = require('oracledb'); |
@@ -34,4 +34,7 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var async = require('async'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -49,59 +52,103 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_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 LOCAL TIME ZONE " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var timestamps = [ | ||
new Date(-100000000), | ||
new Date(0), | ||
new Date(10000000000), | ||
new Date(100000000000) | ||
]; | ||
before(function(done) { | ||
var tableName = "oracledb_timestamp5"; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, timestamps, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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 | ||
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); | ||
}) | ||
}) | ||
it('37.1 supports TIMESTAMP WITH LOCAL TIME ZONE data type', function(done) { | ||
assist.dataTypeSupport(connection, tableName, timestamps, done); | ||
}) | ||
it('37.2 resultSet stores TIMESTAMP WITH LOCAL TIME ZONE data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, timestamps, done); | ||
}) | ||
it('37.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
describe('37.3 testing TIMESTAMP WITH LOCAL TIME ZONE', function() { | ||
var timestamps = assist.TIMESTAMP_TZ_STRINGS; | ||
before(function(done) { | ||
assist.setUp4sql(connection, tableName, timestamps, done); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
}) // 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 " | ||
+ tableName + " WHERE num = :no"; | ||
async.forEach(timestamps, function(timestamp, cb) { | ||
var bv = timestamps.indexOf(timestamp); | ||
connection.execute( | ||
sql, | ||
{ no: bv }, | ||
{ | ||
outFormat: oracledb.OBJECT | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows); | ||
(result.rows[0].TS_DATA).should.equal(assist.content.timestamps5[bv]); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
}) // end of 37.3 suite | ||
}) |
@@ -37,4 +37,7 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var async = require('async'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -52,60 +55,102 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_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 (9) WITH LOCAL TIME ZONE " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var timestamps = [ | ||
new Date(-100000000), | ||
new Date(0), | ||
new Date(10000000000), | ||
new Date(100000000000) | ||
]; | ||
before(function(done) { | ||
var tableName = "oracledb_timestamp6"; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, timestamps, done); | ||
done(); | ||
}); | ||
}) | ||
after( function(done){ | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
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, | ||
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 | ||
it('38.1 supports TIMESTAMP(9) WITH LOCAL TIME ZONE data type', function(done) { | ||
assist.dataTypeSupport(connection, tableName, timestamps, done); | ||
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); | ||
}) | ||
}) | ||
it('38.2 resultSet stores TIMESTAMP(9) WITH LOCAL TIME ZONE data correctly', function(done) { | ||
assist.resultSetSupport(connection, tableName, timestamps, done); | ||
}) | ||
it('38.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
describe('38.3 testing TIMESTAMP WITH LOCAL TIME ZONE', function() { | ||
var timestamps = assist.TIMESTAMP_TZ_STRINGS; | ||
before(function(done) { | ||
assist.setUp4sql(connection, tableName, timestamps, done); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
}) // 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 " | ||
+ tableName + " WHERE num = :no"; | ||
async.forEach(timestamps, function(timestamp, cb) { | ||
var bv = timestamps.indexOf(timestamp); | ||
connection.execute( | ||
sql, | ||
{ no: bv }, | ||
{ | ||
outFormat: oracledb.OBJECT | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows); | ||
(result.rows[0].TS_DATA).should.equal(assist.content.timestamps6[bv]); | ||
cb(); | ||
} | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
}) // end of 38.3 suite | ||
}) |
@@ -34,4 +34,6 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
*****************************************************************************/ | ||
"use strict"; | ||
var oracledb = require('oracledb'); | ||
var should = require('should'); | ||
var assist = require('./dataTypeAssist.js'); | ||
@@ -48,22 +50,4 @@ var dbConfig = require('./dbConfig.js'); | ||
var connection = false; | ||
var tableName = "oracledb_datatype_varchar2"; | ||
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 VARCHAR2(4000) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
var connection = null; | ||
var tableName = "oracledb_varchar2"; | ||
@@ -75,34 +59,52 @@ var strLen = [10 ,100, 1000, 2000, 3000, 4000]; // char string length | ||
before(function(done) { | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
if(err) { console.error(err.message); return; } | ||
should.not.exist(err); | ||
connection = conn; | ||
assist.setup(connection, tableName, sqlCreate, strs, done); | ||
done(); | ||
}); | ||
}) | ||
after(function(done) { | ||
connection.execute( | ||
"DROP table " + tableName, | ||
function(err) { | ||
if(err) { console.error(err.message); return; } | ||
connection.release( function(err) { | ||
if(err) { console.error(err.message); return; } | ||
done(); | ||
}); | ||
} | ||
); | ||
after('release connection', function(done) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
it('24.1 supports VARCHAR2 data in various lengths', function(done) { | ||
assist.dataTypeSupport(connection, tableName, strs, 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, | ||
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); | ||
}) | ||
}) | ||
it('24.2 resultSet stores VARCHAR2 data correctly', function(done) { | ||
assist.resultSetSupport(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); | ||
}) | ||
}) | ||
it('24.3 stores null value correctly', function(done) { | ||
assist.nullValueSupport(connection, tableName, done); | ||
}) | ||
}) |
@@ -149,3 +149,3 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
it('6.1.3 INSERT statement with small maxSize restriction', function(done) { | ||
it.skip('6.1.3 INSERT statement with small maxSize restriction', function(done) { | ||
connection.should.be.ok; | ||
@@ -152,0 +152,0 @@ connection.execute( |
@@ -37,225 +37,238 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
var should = require ( 'should' ); | ||
var async = require ( 'async' ); | ||
var async = require('async'); | ||
var dbConfig = require ( './dbConfig.js' ); | ||
describe ('56. fetchAs.js', | ||
function () | ||
{ | ||
if (dbConfig.externalAuth ) | ||
{ | ||
var credential = { externalAuth : true, | ||
connectString : dbConfig.connectString | ||
}; | ||
} | ||
else | ||
{ | ||
var credential = dbConfig; | ||
} | ||
describe('56. fetchAs.js', function() { | ||
if(dbConfig.externalAuth){ | ||
var credential = { externalAuth: true, connectString: dbConfig.connectString }; | ||
} else { | ||
var credential = dbConfig; | ||
} | ||
var connection = null; | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
should.not.exist(err); | ||
connection = conn; | ||
done(); | ||
}); | ||
}) | ||
var connection = false; | ||
/* preparation work before test case(s). */ | ||
before ( | ||
function ( done ) | ||
after('release connection, reset fetchAsString property', function(done) { | ||
oracledb.fetchAsString = []; | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
it('56.1 Fetch DATE column values as STRING - by-Column name', function(done) { | ||
connection.execute( | ||
"SELECT TO_DATE('2005-01-06', 'YYYY-DD-MM') AS TS_DATE FROM DUAL", | ||
[], | ||
{ | ||
oracledb.getConnection ( credential, | ||
function ( err, conn ) | ||
{ | ||
if ( err ) | ||
{ | ||
console.error ( err.message ); | ||
return; | ||
} | ||
connection = conn; | ||
done (); | ||
} | ||
); | ||
outFormat: oracledb.OBJECT, | ||
fetchInfo : { "TS_DATE": { type : oracledb.STRING } } | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows[0]); | ||
result.rows[0].TS_DATE.should.be.a.String; | ||
done(); | ||
} | ||
); | ||
}) | ||
/* clean up after test case(s) */ | ||
after ( | ||
function ( done ) | ||
it('56.2 Fetch DATE, NUMBER column values STRING - by Column-name', function(done) { | ||
connection.execute( | ||
"SELECT 1234567 AS TS_NUM, TO_TIMESTAMP('1999-12-01 11:10:01.00123', 'YYYY-MM-DD HH:MI:SS.FF') AS TS_DATE FROM DUAL", | ||
[], | ||
{ | ||
connection.release ( | ||
function ( err ) | ||
{ | ||
oracledb.fetchAsString = [] ; | ||
if ( err ) | ||
{ | ||
console.error ( err.message ); | ||
return; | ||
} | ||
done (); | ||
} | ||
); | ||
outFormat: oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"TS_DATE" : { type : oracledb.STRING }, | ||
"TS_NUM" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows[0]); | ||
result.rows[0].TS_DATE.should.be.a.String; | ||
result.rows[0].TS_NUM.should.be.a.String; | ||
Number(result.rows[0].TS_NUM).should.equal(1234567); | ||
done(); | ||
} | ||
); | ||
}) | ||
/* Fetch DATE column values as STRING - by-Column name */ | ||
it ('56.1 FetchAs - DATE type as STRING', | ||
function ( done ) | ||
it('56.3 Fetch DATE, NUMBER as STRING by-time configuration and by-name', function(done) { | ||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ]; | ||
connection.execute( | ||
"SELECT 1234567 AS TS_NUM, TO_TIMESTAMP('1999-12-01 11:10:01.00123', 'YYYY-MM-DD HH:MI:SS.FF') AS TS_DATE FROM DUAL", | ||
[], | ||
{ | ||
connection.should.be.ok; | ||
connection.execute ( | ||
"SELECT FIRST_NAME, LAST_NAME, HIRE_DATE FROM EMPLOYEES", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
fetchInfo : { "HIRE_DATE" : { type : oracledb.STRING } } | ||
}, | ||
function ( err, result ) | ||
{ | ||
should.not.exist ( err ) ; | ||
done (); | ||
} | ||
); | ||
outFormat: oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"TS_DATE" : { type : oracledb.STRING }, | ||
"TS_NUM" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows[0]); | ||
result.rows[0].TS_DATE.should.be.a.String; | ||
result.rows[0].TS_NUM.should.be.a.String; | ||
Number(result.rows[0].TS_NUM).should.equal(1234567); | ||
done(); | ||
} | ||
); | ||
}) | ||
/* Fetch DATE, NUMBER column values STRING - by Column-name */ | ||
it ('56.2 FetchAs NUMBER & DATE type as STRING', | ||
function ( done ) | ||
it('56.4 Fetch DATE, NUMBER column as STRING by-type and override at execute time', function(done) { | ||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ]; | ||
connection.execute( | ||
"SELECT 1234567 AS TS_NUM, TO_TIMESTAMP('1999-12-01 11:10:01.00123', 'YYYY-MM-DD HH:MI:SS.FF') AS TS_DATE FROM DUAL", | ||
[], | ||
{ | ||
connection.should.be.ok; | ||
connection.execute ( | ||
"SELECT employee_id as SEMPID, employee_id, " + | ||
"hire_date as SHDATE, hire_date FROM EMPLOYEES", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"SEMPID" : { type : oracledb.STRING }, | ||
"SHDATE" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function ( err, result ) | ||
{ | ||
should.not.exist ( err ) ; | ||
done (); | ||
} | ||
); | ||
outFormat: oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"TS_DATE" : { type : oracledb.DEFAULT }, | ||
"TS_NUM" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows[0]); | ||
result.rows[0].TS_DATE.should.be.an.Object; | ||
result.rows[0].TS_NUM.should.be.a.String; | ||
Number(result.rows[0].TS_NUM).should.equal(1234567); | ||
done(); | ||
} | ||
); | ||
/* Fetch DATE, NUMBER as STRING by-time configuration and by-name */ | ||
it ('56.3 FetchAs Oracledb property by-type', | ||
function ( done ) | ||
{ | ||
connection.should.be.ok; | ||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ]; | ||
connection.execute ( | ||
"SELECT employee_id, first_name, last_name, hire_date " + | ||
"FROM EMPLOYEES", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"HIRE_DATE" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function ( err, result ) | ||
{ | ||
should.not.exist ( err ) ; | ||
done (); | ||
} | ||
); | ||
}) | ||
it('56.5 Fetch ROWID column values STRING - non-ResultSet', function(done) { | ||
connection.execute( | ||
"SELECT ROWID from DUAL", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"ROWID" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows[0].TS_DATA); | ||
result.rows[0].ROWID.should.be.a.String; | ||
done(); | ||
} | ||
); | ||
}) | ||
/* | ||
* Fetch DATE, NUMBER column as STRING by-type and override | ||
* HIRE_DATE to use default (from metadata type). | ||
*/ | ||
it ('56.4 FetchAs override oracledb by-type (for DATE) at execute time', | ||
function ( done ) | ||
{ | ||
connection.should.be.ok; | ||
oracledb.fetchAsString = [ oracledb.DATE, oracledb.NUMBER ]; | ||
connection.execute ( | ||
"SELECT employee_id, first_name, last_name, hire_date " + | ||
"FROM EMPLOYEES", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"HIRE_DATE" : { type : oracledb.DEFAULT }, | ||
"EMPLOYEE_ID" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function ( err, result ) | ||
{ | ||
should.not.exist ( err ) ; | ||
done (); | ||
} | ||
); | ||
it('56.6 Fetch ROWID column values STRING - ResultSet', function(done) { | ||
connection.execute( | ||
"SELECT ROWID from DUAL", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
resultSet : true, | ||
fetchInfo : | ||
{ | ||
"ROWID" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
result.resultSet.getRow( function(err, row) { | ||
should.not.exist(err); | ||
// console.log(row); | ||
row.ROWID.should.be.a.String; | ||
result.resultSet.close( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}); | ||
} | ||
); | ||
}) | ||
/* | ||
* The maximum safe integer in JavaScript is (2^53 - 1). | ||
* The minimum safe integer in JavaScript is (-(2^53 - 1)). | ||
* Numbers out of above range will be rounded. | ||
* The last element is out of Oracle database standard Number range. It will be rounded by database. | ||
*/ | ||
var numStrs = | ||
[ | ||
'17249138680355831', | ||
'-17249138680355831', | ||
'0.17249138680355831', | ||
'-0.17249138680355831', | ||
'0.1724913868035583123456789123456789123456' | ||
]; | ||
/* Fetch ROWID column values STRING - non-ResultSet */ | ||
it ('56.5 FetchInfo ROWID column values STRING non-ResultSet', | ||
function ( done ) | ||
var numResults = | ||
[ | ||
'17249138680355831', | ||
'-17249138680355831', | ||
'.17249138680355831', | ||
'-.17249138680355831', | ||
'.172491386803558312345678912345678912346' | ||
]; | ||
it('56.7 large numbers with fetchInfo', function(done) { | ||
async.forEach(numStrs, function(element, callback) { | ||
connection.execute( | ||
"SELECT TO_NUMBER( " + element + " ) AS TS_NUM FROM DUAL", | ||
[], | ||
{ | ||
connection.should.be.ok; | ||
connection.execute ( | ||
"SELECT ROWID from DUAL", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"ROWID" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function ( err, result ) | ||
{ | ||
should.not.exist ( err ) ; | ||
done (); | ||
} | ||
); | ||
outFormat : oracledb.OBJECT, | ||
fetchInfo : | ||
{ | ||
"TS_NUM" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
result.rows[0].TS_NUM.should.be.a.String; | ||
(result.rows[0].TS_NUM).should.eql(numResults[numStrs.indexOf(element)]); | ||
callback(); | ||
} | ||
); | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
/* Fetch ROWID column values STRING - ResultSet */ | ||
it ('56.6 FetchInfo ROWID column values STRING ResultSet', | ||
function ( done ) | ||
{ | ||
connection.should.be.ok; | ||
connection.execute ( | ||
"SELECT ROWID from DUAL", | ||
[], | ||
{ | ||
outFormat : oracledb.OBJECT, | ||
resultSet : true, | ||
fetchInfo : | ||
{ | ||
"ROWID" : { type : oracledb.STRING } | ||
} | ||
}, | ||
function ( err, result ) | ||
{ | ||
should.not.exist ( err ) ; | ||
done (); | ||
} | ||
); | ||
it('56.8 large numbers with setting fetchAsString property', function(done) { | ||
oracledb.fetchAsString = [ oracledb.NUMBER ]; | ||
async.forEach(numStrs, function(element, callback) { | ||
connection.execute( | ||
"SELECT TO_NUMBER( " + element + " ) AS TS_NUM FROM DUAL", | ||
[], | ||
{ outFormat : oracledb.OBJECT }, | ||
function(err, result) { | ||
should.not.exist(err); | ||
// console.log(result.rows[0].TS_NUM); | ||
result.rows[0].TS_NUM.should.be.a.String; | ||
(result.rows[0].TS_NUM).should.eql(numResults[numStrs.indexOf(element)]); | ||
callback(); | ||
} | ||
); | ||
} | ||
); | ||
); | ||
}, function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
}) |
@@ -206,10 +206,16 @@ 1. connection.js | ||
22. dataTypeChar.js | ||
22.1 supports CHAR data | ||
22.2 resultSet stores CHAR data correctly | ||
22.3 stores null value correctly | ||
22.1 testing CHAR data in various lengths | ||
22.1.1 works well with SELECT query | ||
22.1.2 works well with result set | ||
22.1.3 works well with REF Cursor | ||
22.2 stores null value correctly | ||
22.2.1 testing Null, Empty string and Undefined | ||
23. dataTypeNchar.js | ||
23.1 supports NCHAR data type | ||
23.2 resultSet supports NCHAR data type | ||
23.3 stores null value correctly | ||
23.1 testing NCHAR data in various lengths | ||
23.1.1 SELECT query | ||
23.1.2 resultSet stores NCHAR data correctly | ||
23.1.3 works well with REF Cursor | ||
23.2 stores null value correctly | ||
23.2.1 testing Null, Empty string and Undefined | ||
@@ -220,75 +226,142 @@ 24. dataTypeVarchar2.js | ||
24.3 stores null value correctly | ||
24. dataTypeVarchar2.js | ||
24.1 testing VARCHAR2 data in various lengths | ||
24.1.1 SELECT query | ||
24.1.2 resultSet stores VARCHAR2 data correctly | ||
24.1.3 works well with REF Cursor | ||
24.2 stores null value correctly | ||
24.2.1 testing Null, Empty string and Undefined | ||
25. dataTypeNvarchar2.js | ||
25.1 supports NVARCHAR2 data in various lengths | ||
25.2 resultSet stores NVARCHAR2 data correctly | ||
25.3 stores null value correctly | ||
25.1 testing NVARCHAR2 data in various lengths | ||
25.1.1 SELECT query | ||
25.1.2 resultSet stores NVARCHAR2 data correctly | ||
25.1.3 works well with REF Cursor | ||
25.2 stores null value correctly | ||
25.2.1 testing Null, Empty string and Undefined | ||
26. dataTypeNumber.js | ||
26.1 supports NUMBER data type | ||
26.2 resultSet stores NUMBER data correctly | ||
26.3 stores null value correctly | ||
26.1 testing NUMBER data | ||
26.1.1 SELECT query | ||
26.1.2 resultSet stores NUMBER data correctly | ||
26.1.3 works well with REF Cursor | ||
26.2 stores null value correctly | ||
26.2.1 testing Null, Empty string and Undefined | ||
27. dataTypeNumber2.js | ||
27.1 supports NUMBER(p, s) data type | ||
27.2 resultSet stores NUMBER(p, s) data correctly | ||
27.3 stores null value correctly | ||
27.1 testing NUMBER(p, s) data | ||
27.1.1 SELECT query | ||
27.1.2 resultSet stores NUMBER(p, s) data correctly | ||
27.2 stores null value correctly | ||
27.2.1 testing Null, Empty string and Undefined | ||
28. dataTypeFloat.js | ||
28.1 supports FLOAT data type | ||
28.2 resultSet stores FLOAT data correctly | ||
28.3 stores null value correctly | ||
28.1 testing FLOAT data type | ||
28.1.1 works well with SELECT query | ||
28.1.2 works well with result set | ||
28.1.3 works well with REF Cursor | ||
28.2 stores null value correctly | ||
28.2.1 testing Null, Empty string and Undefined | ||
29. dataTypeFloat2.js | ||
29.1 supports FLOAT(p) data type | ||
29.2 resultSet stores FLOAT(p) data correctly | ||
29.3 stores null value correctly | ||
29.1 testing FLOAT(p) data type | ||
29.1.1 works well with SELECT query | ||
29.1.2 works well with result set | ||
29.1.3 works well with REF Cursor | ||
29.2 stores null value correctly | ||
29.2.1 testing Null, Empty string and Undefined | ||
30. dataTypeBinaryFloat.js | ||
- supports BINARY_FLOAT data type | ||
30.1 testing BINARY_FLOAT data | ||
- 30.1.1 works well with SELECT query | ||
- 30.1.2 works well with result set | ||
- 30.1.3 works well with REF Cursor | ||
30.2 stores null value correctly | ||
30.2.1 testing Null, Empty string and Undefined | ||
31. dataTypeBinaryDouble.js | ||
- supports BINARY_DOUBLE data type | ||
31.1 testing BINARY_DOUBLE data | ||
- 31.1.1 works well with SELECT query | ||
- 31.1.2 works well with result set | ||
- 31.1.3 works well with REF Cursor | ||
31.2 stores null value correctly | ||
31.2.1 testing Null, Empty string and Undefined | ||
32. dataTypeDate.js | ||
32.1 supports DATE data type | ||
32.2 resultSet stores DATE data correctly | ||
32.3 stores null value correctly | ||
32.1 Testing JavaScript Date data | ||
32.1.1 works well with SELECT query | ||
32.1.2 works well with result set | ||
32.1.3 works well with REF Cursor | ||
32.2 stores null value correctly | ||
32.2.1 testing Null, Empty string and Undefined | ||
32.3 insert SQL Date data | ||
32.3.1 SELECT query - original data | ||
32.3.2 SELECT query - formatted data for comparison | ||
33. dataTypeTimestamp1.js | ||
33.1 supports TIMESTAMP data type | ||
33.2 resultSet stores TIMESTAMP data correctly | ||
33.3 stores null value correctly | ||
33.1 Testing JavaScript Date with database TIMESTAMP | ||
33.1.1 works well with SELECT query | ||
33.1.2 works well with result set | ||
33.1.3 works well with REF Cursor | ||
33.2 stores null value correctly | ||
33.2.1 testing Null, Empty string and Undefined | ||
33.3 testing TIMESTAMP without TIME ZONE | ||
32.3.1 SELECT query - original data | ||
33.3.2 SELECT query - formatted data for comparison | ||
34. dataTypeTimestamp2.js | ||
34.1 supports TIMESTAMP(p) data type | ||
34.2 resultSet stores TIMESTAMP data correctly | ||
34.3 stores null value correctly | ||
34.1 Testing JavaScript Date with database TIMESTAMP(p) | ||
34.1.1 works well with SELECT query | ||
34.1.2 works well with result set | ||
34.1.3 works well with REF Cursor | ||
34.2 sotres null value correctly | ||
34.2.1 testing Null, Empty string and Undefined | ||
34.3 testing database TIMESTAMP(p) | ||
34.3.1 SELECT query - original data | ||
34.3.2 SELECT query - formatted data for comparison | ||
35. dataTypeTimestamp3.js | ||
supports TIMESTAMP WITH TIME ZONE data type | ||
supports TIMESTAMP WITH TIME ZONE data type | ||
36. dataTypeTimestamp4.js | ||
supports TIMESTAMP WITH TIME ZONE data type | ||
supports TIMESTAMP WITH TIME ZONE data type | ||
37. dataTypeTimestamp5.js | ||
37.1 supports TIMESTAMP WITH LOCAL TIME ZONE data type | ||
37.2 resultSet stores TIMESTAMP WITH LOCAL TIME ZONE data correctly | ||
37.3 stores null value correctly | ||
37.1 Testing JavaScript Date with database TIMESTAMP WITH LOCAL TIME ZONE | ||
37.1.1 works well with SELECT query | ||
37.1.2 works well with result set | ||
37.1.3 works well with REF Cursor | ||
37.2 stores null value correctly | ||
37.2.1 testing Null, Empty string and Undefined | ||
37.3 testing TIMESTAMP WITH LOCAL TIME ZONE | ||
37.3.1 SELECT query - original data | ||
37.3.2 SELECT query - formatted data for comparison | ||
38. dataTypeTimestamp6.js | ||
38.1 supports TIMESTAMP(9) WITH LOCAL TIME ZONE data type | ||
38.2 resultSet stores TIMESTAMP(9) WITH LOCAL TIME ZONE data correctly | ||
38.3 stores null value correctly | ||
38.1 Testing JavaScript Date with database TIMESTAMP(9) WITH LOCAL TIME ZON | ||
38.1.1 works well with SELECT query | ||
38.1.2 works well with result set | ||
38.1.3 works well with REF Cursor | ||
38.2 stores null value correctly | ||
38.2.1 testing Null, Empty string and Undefined | ||
38.3 testing TIMESTAMP WITH LOCAL TIME ZONE | ||
38.3.1 SELECT query - original data | ||
38.3.2 SELECT query - formatted data for comparison | ||
39. dataTypeRowid.js | ||
39.1 supports ROWID data type | ||
39.1 testing ROWID data type | ||
39.1.1 is still unsupported data type | ||
40. dataTypeClob.js | ||
40.1 processes null value correctly | ||
40.2 stores CLOB value correctly | ||
40.1 testing CLOB data type | ||
40.1.1 stores CLOB value correctly | ||
40.2 stores null value correctly | ||
40.2.1 testing Null, Empty string and Undefined | ||
41. dataTypeBlob | ||
41.1 processes null value correctly | ||
41.2 stores BLOB value correctly | ||
41.1 testing BLOB data type | ||
41.1.1 stores BLOB value correctly | ||
41.2 stores null value correctly | ||
41.2.1 testing Null, Empty string and Undefined | ||
@@ -332,3 +405,9 @@ 51. accessTerminatedPoolAttributes.js | ||
55.10.1 | ||
55.11 deals with unsupported database with result set | ||
55.11.1 RAW data type | ||
55.11.2 ROWID date type | ||
55.12 bind a cursor BIND_INOUT | ||
- 55.12.1 should work | ||
56. fetchAs.js | ||
@@ -335,0 +414,0 @@ 56.1 FetchAs - DATE type as STRING |
@@ -49,120 +49,23 @@ /* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */ | ||
var connection = false; | ||
var createTable = | ||
"BEGIN \ | ||
DECLARE \ | ||
e_table_exists EXCEPTION; \ | ||
PRAGMA EXCEPTION_INIT(e_table_exists, -00942); \ | ||
BEGIN \ | ||
EXECUTE IMMEDIATE ('DROP TABLE oracledb_employees'); \ | ||
EXCEPTION \ | ||
WHEN e_table_exists \ | ||
THEN NULL; \ | ||
END; \ | ||
EXECUTE IMMEDIATE (' \ | ||
CREATE TABLE oracledb_employees ( \ | ||
employees_id NUMBER, \ | ||
employees_name VARCHAR2(20) \ | ||
) \ | ||
'); \ | ||
END; "; | ||
var rowsAmount = 300; | ||
var insertRows = | ||
"DECLARE \ | ||
x NUMBER := 0; \ | ||
n VARCHAR2(20); \ | ||
BEGIN \ | ||
FOR i IN 1..300 LOOP \ | ||
x := x + 1; \ | ||
n := 'staff ' || x; \ | ||
INSERT INTO oracledb_employees VALUES (x, n); \ | ||
END LOOP; \ | ||
END; "; | ||
var proc = | ||
"CREATE OR REPLACE PROCEDURE get_emp_rs (p_in IN NUMBER, p_out OUT SYS_REFCURSOR) \ | ||
AS \ | ||
BEGIN \ | ||
OPEN p_out FOR \ | ||
SELECT * FROM oracledb_employees \ | ||
WHERE employees_id > p_in; \ | ||
END; "; | ||
var connection = null; | ||
var tableName = "oracledb_employees"; | ||
var rowsAmount = 300; | ||
beforeEach(function(done) { | ||
async.series([ | ||
function(callback) { | ||
oracledb.getConnection( | ||
credential, | ||
function(err, conn) { | ||
connection = conn; | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.should.be.ok; | ||
connection.execute( | ||
createTable, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
insertRows, | ||
[], | ||
{ autoCommit: true }, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
proc, | ||
[], | ||
{ autoCommit: true }, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
} | ||
], done); | ||
before('get one connection', function(done) { | ||
oracledb.getConnection(credential, function(err, conn) { | ||
should.not.exist(err); | ||
connection = conn; | ||
done(); | ||
}); | ||
}) | ||
afterEach(function(done) { | ||
async.series([ | ||
function(callback) { | ||
connection.execute( | ||
'DROP TABLE oracledb_employees', | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
'DROP PROCEDURE get_emp_rs', | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
}); | ||
} | ||
], done); | ||
after('release connection', function(done) { | ||
connection.release( function(err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}) | ||
describe('55.1 query a RDBMS function', function() { | ||
it('55.1.1 LPAD function', function(done) { | ||
@@ -196,5 +99,13 @@ connection.should.be.ok; | ||
}) | ||
}) | ||
}) // 55.1 | ||
describe('55.2 binding variables', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
it('55.2.1 query with one binding variable', function(done) { | ||
@@ -234,2 +145,10 @@ connection.should.be.ok; | ||
describe('55.3 alternating getRow() & getRows() function', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
it('55.3.1 result set', function(done) { | ||
@@ -349,4 +268,24 @@ connection.should.be.ok; | ||
describe('55.4 release connection before close resultSet', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
beforeEach(function(done) { | ||
oracledb.getConnection( | ||
credential, | ||
function(err, conn) { | ||
should.not.exist(err); | ||
conn2 = conn; | ||
done(); | ||
} | ||
); | ||
}) | ||
var conn2 = false; | ||
function fetchRowFromRS(rs, cb) { | ||
rs.getRow(function(err, row) { | ||
@@ -368,13 +307,2 @@ if(row) { | ||
beforeEach(function(done) { | ||
oracledb.getConnection( | ||
credential, | ||
function(err, conn) { | ||
should.not.exist(err); | ||
conn2 = conn; | ||
done(); | ||
} | ||
); | ||
}) | ||
it('55.4.1 result set', function(done) { | ||
@@ -411,2 +339,10 @@ conn2.should.be.ok; | ||
describe('55.5 the content of resultSet should be consistent', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
it('55.5.1 (1) get RS (2) modify data in that table and commit (3) check RS', function(done) { | ||
@@ -466,2 +402,10 @@ connection.should.be.ok; | ||
describe('55.6 access resultSet simultaneously', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
var numRows = 10; // number of rows to return from each call to getRows() | ||
@@ -572,2 +516,10 @@ | ||
describe('55.7 getting multiple resultSets', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
var numRows = 10; // number of rows to return from each call to getRows() | ||
@@ -672,2 +624,10 @@ | ||
describe('55.8 Negative - resultSet is only for query statement', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
it('55.8.1 resultSet cannot be returned for non-query statements', function(done) { | ||
@@ -691,2 +651,10 @@ connection.should.be.ok; | ||
describe('55.9 test querying a PL/SQL function', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
it('55.9.1 ', function(done) { | ||
@@ -753,2 +721,10 @@ var proc = | ||
describe('55.10 calls getRows() once and then close RS before getting more rows', function() { | ||
before(function(done){ | ||
setUp(connection, tableName, done); | ||
}) | ||
after(function(done) { | ||
clearUp(connection, tableName, done); | ||
}) | ||
it('55.10.1 ', function(done) { | ||
@@ -843,2 +819,256 @@ connection.should.be.ok; | ||
describe.skip('55.12 bind a cursor BIND_INOUT', function() { | ||
it('55.12.1 should work', function(done) { | ||
var proc = | ||
"CREATE OR REPLACE PROCEDURE get_emp_rs_inout (p_in IN NUMBER, p_out IN OUT SYS_REFCURSOR) \ | ||
AS \ | ||
BEGIN \ | ||
OPEN p_out FOR \ | ||
SELECT * FROM oracledb_employees \ | ||
WHERE employees_id > p_in; \ | ||
END; "; | ||
async.series([ | ||
function(callback) { | ||
connection.execute( | ||
proc, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
"BEGIN get_emp_rs_inout(:in, :out); END;", | ||
{ | ||
in: 200, | ||
out: { type: oracledb.CURSOR, dir: oracledb.BIND_INOUT } | ||
}, | ||
function(err, result) { | ||
should.not.exist(err); | ||
console.log(result); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
"DROP PROCEDURE get_emp_rs_inout", | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
} | ||
], done); | ||
}) | ||
}) // 55.12 | ||
describe('55.13 Invalid Ref Cursor', function() { | ||
var proc = | ||
"CREATE OR REPLACE PROCEDURE get_invalid_refcur ( p OUT SYS_REFCURSOR) " + | ||
" AS " + | ||
" BEGIN " + | ||
" NULL; " + | ||
" END;" | ||
before(function(done){ | ||
async.series([ | ||
function(callback) { | ||
setUp(connection, tableName, callback); | ||
}, | ||
function(callback) { | ||
connection.execute( | ||
proc, | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
} | ||
], done); | ||
}) | ||
after(function(done) { | ||
async.series([ | ||
function(callback) { | ||
connection.execute( | ||
"DROP PROCEDURE get_invalid_refcur", | ||
function(err) { | ||
should.not.exist(err); | ||
callback(); | ||
} | ||
); | ||
}, | ||
function(callback) { | ||
clearUp(connection, tableName, done); | ||
} | ||
], done); | ||
}) | ||
it('55.13.1 ', function (done ) { | ||
connection.should.be.ok; | ||
connection.execute ( | ||
"BEGIN get_invalid_refcur ( :p ); END; ", | ||
{ | ||
p : { type : oracledb.CURSOR, dir : oracledb.BIND_OUT } | ||
}, | ||
function ( err, result) { | ||
should.not.exist ( err ); | ||
fetchRowFromRS2 (result.outBinds.out, done); | ||
} | ||
); | ||
function fetchRowFromRS2 (rs, cb ) { | ||
if ( rs ) { | ||
rs.getRow ( function ( err, row ) { | ||
should.not.exist ( err ) ; | ||
if ( row ) { | ||
return fetchRowFromRS (rs, cb ); | ||
} else { | ||
rs.close(function(err) { | ||
should.not.exist(err); | ||
cb(); | ||
}); | ||
} | ||
}); | ||
} else { | ||
cb(); | ||
} | ||
} | ||
}) // 55.13.1 | ||
}) // 55.13 | ||
}) | ||
/********************* Helper functions *************************/ | ||
function setUp(connection, tableName, done) | ||
{ | ||
async.series([ | ||
function(callback) { | ||
createTable(connection, tableName, callback); | ||
}, | ||
function(callback) { | ||
insertData(connection, tableName, callback); | ||
}, | ||
function(callback) { | ||
createProc1(connection, tableName, callback); | ||
} | ||
], done); | ||
} | ||
function clearUp(connection, tableName, done) | ||
{ | ||
async.series([ | ||
function(callback) { | ||
dropProc1(connection, callback); | ||
}, | ||
function(callback) { | ||
dropTable(connection, tableName, callback); | ||
} | ||
], done); | ||
} | ||
function createTable(connection, tableName, done) | ||
{ | ||
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 +" ( " + | ||
" employees_id NUMBER(10), " + | ||
" employee_name VARCHAR2(20) " + | ||
" )" + | ||
" '); " + | ||
"END; "; | ||
connection.execute( | ||
sqlCreate, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
} | ||
function dropTable(connection, tableName, done) | ||
{ | ||
connection.execute( | ||
'DROP TABLE ' + tableName, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
} | ||
function insertData(connection, tableName, done) | ||
{ | ||
var sqlInsert = | ||
"DECLARE " + | ||
" x NUMBER := 0; " + | ||
" n VARCHAR2(20); " + | ||
"BEGIN " + | ||
" FOR i IN 1..300 LOOP " + | ||
" x := x + 1; " + | ||
" n := 'staff ' || x; " + | ||
" INSERT INTO " + tableName + " VALUES (x, n); " + | ||
" END LOOP; " + | ||
"END; "; | ||
connection.execute( | ||
sqlInsert, | ||
[], | ||
{ autoCommit: true }, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
} | ||
function createProc1(connection, tableName, done) | ||
{ | ||
var sqlProc = | ||
"CREATE OR REPLACE PROCEDURE get_emp_rs (p_in IN NUMBER, p_out OUT SYS_REFCURSOR) " + | ||
" AS " + | ||
" BEGIN " + | ||
" OPEN p_out FOR " + | ||
" SELECT * FROM " + tableName + " WHERE employees_id > p_in; " + | ||
" END; "; | ||
connection.execute( | ||
sqlProc, | ||
[], | ||
{ autoCommit: true }, | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
} | ||
function dropProc1(connection, done) | ||
{ | ||
connection.execute( | ||
'DROP PROCEDURE get_emp_rs', | ||
function(err) { | ||
should.not.exist(err); | ||
done(); | ||
} | ||
); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
838332
11158
124