Add tests for fetching TIMESTAMP as String
This commit is contained in:
parent
cde153a8be
commit
c058308e7b
|
@ -56,7 +56,7 @@ assist.allDataTypeNames =
|
||||||
"nodb_timestamp1" : "TIMESTAMP",
|
"nodb_timestamp1" : "TIMESTAMP",
|
||||||
"nodb_timestamp2" : "TIMESTAMP(5)",
|
"nodb_timestamp2" : "TIMESTAMP(5)",
|
||||||
"nodb_timestamp3" : "TIMESTAMP WITH TIME ZONE",
|
"nodb_timestamp3" : "TIMESTAMP WITH TIME ZONE",
|
||||||
"nodb_timestamp4" : "TIMESTAMP (2) WITH TIME ZONE",
|
"nodb_timestamp4" : "TIMESTAMP (4) WITH TIME ZONE",
|
||||||
"nodb_timestamp5" : "TIMESTAMP WITH LOCAL TIME ZONE",
|
"nodb_timestamp5" : "TIMESTAMP WITH LOCAL TIME ZONE",
|
||||||
"nodb_timestamp6" : "TIMESTAMP (9) WITH LOCAL TIME ZONE",
|
"nodb_timestamp6" : "TIMESTAMP (9) WITH LOCAL TIME ZONE",
|
||||||
"nodb_rowid" : "ROWID",
|
"nodb_rowid" : "ROWID",
|
||||||
|
@ -225,7 +225,31 @@ assist.TIMESTAMP_STRINGS =
|
||||||
];
|
];
|
||||||
|
|
||||||
// for TIMESTAMP WITH TIME ZONE
|
// for TIMESTAMP WITH TIME ZONE
|
||||||
assist.TIMESTAMP_TZ_STRINGS =
|
assist.TIMESTAMP_TZ_STRINGS_1 =
|
||||||
|
[
|
||||||
|
"TO_TIMESTAMP_TZ('2005-01-06 11:00:00.1 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')",
|
||||||
|
"TO_TIMESTAMP_TZ('2005-09-01 11:00:00.1 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')",
|
||||||
|
"TO_TIMESTAMP_TZ('2005-08-05 11:00:00.1 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')",
|
||||||
|
"TO_TIMESTAMP_TZ('07-05-1998 11:00:00.1 -8:00', 'MM-DD-YYYY HH:MI:SS.FF TZH:TZM')",
|
||||||
|
"TO_TIMESTAMP_TZ('07-05-1998 11:00:00.123 -8:00', 'DD-MM-YYYY HH:MI:SS.FF TZH:TZM')",
|
||||||
|
"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.123456189 -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')",
|
||||||
|
"TO_TIMESTAMP_TZ('10-Sep-02 14:10:10.123000 -8:00', 'DD-Mon-RR HH24:MI:SS.FF TZH:TZM')"
|
||||||
|
];
|
||||||
|
|
||||||
|
// for TIMESTAMP WITH TIME ZONE
|
||||||
|
assist.TIMESTAMP_TZ_STRINGS_2 =
|
||||||
[
|
[
|
||||||
"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.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.12 -8:00', 'YYYY-MM-DD HH:MI:SS.FF TZH:TZM')",
|
||||||
|
@ -298,6 +322,50 @@ assist.content =
|
||||||
'01-12-1999 11:00:00.12346',
|
'01-12-1999 11:00:00.12346',
|
||||||
'10-09-2002 14:10:10.12300'
|
'10-09-2002 14:10:10.12300'
|
||||||
],
|
],
|
||||||
|
timestamps3:
|
||||||
|
[
|
||||||
|
'06-01-2005 11:00:00.100000 -08:00',
|
||||||
|
'01-09-2005 11:00:00.100000 -08:00',
|
||||||
|
'05-08-2005 11:00:00.100000 -08:00',
|
||||||
|
'05-07-1998 11:00:00.100000 -08:00',
|
||||||
|
'07-05-1998 11:00:00.123000 -08:00',
|
||||||
|
'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.123456 -08:00',
|
||||||
|
'01-12-1999 11:00:00.000000 -08:00',
|
||||||
|
'10-09-2002 14:10:10.123000 -08:00'
|
||||||
|
],
|
||||||
|
timestamps4:
|
||||||
|
[
|
||||||
|
'06-01-2005 11:00:00.1000 -08:00',
|
||||||
|
'01-09-2005 11:00:00.1000 -08:00',
|
||||||
|
'05-08-2005 11:00:00.1000 -08:00',
|
||||||
|
'05-07-1998 11:00:00.1000 -08:00',
|
||||||
|
'07-05-1998 11:00:00.1230 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1000 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1200 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1230 -08:00',
|
||||||
|
'01-12-1999 11:00:00.0123 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1234 -08:00',
|
||||||
|
'01-12-1999 11:00:00.0012 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1235 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1235 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1235 -08:00',
|
||||||
|
'01-12-1999 11:20:02.0000 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1235 -08:00',
|
||||||
|
'01-12-1999 11:00:00.1235 -08:00',
|
||||||
|
'01-12-1999 11:00:00.0000 -08:00',
|
||||||
|
'10-09-2002 14:10:10.1230 -08:00'
|
||||||
|
],
|
||||||
timestamps5:
|
timestamps5:
|
||||||
[
|
[
|
||||||
'01-12-1999 11:00:00.100000 -08:00',
|
'01-12-1999 11:00:00.100000 -08:00',
|
||||||
|
@ -329,6 +397,94 @@ assist.content =
|
||||||
'01-12-1999 11:00:00.123456780 -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.123456789 -08:00',
|
||||||
'01-12-1999 11:00:00.000000000 -08:00'
|
'01-12-1999 11:00:00.000000000 -08:00'
|
||||||
|
],
|
||||||
|
timestamp_1_1:
|
||||||
|
[
|
||||||
|
[ '2005-06-01 00:00:00.000000' ],
|
||||||
|
[ '2005-09-01 00:00:00.000000' ],
|
||||||
|
[ '2005-08-05 00:00:00.000000' ],
|
||||||
|
[ '1998-07-05 00:00:00.000000' ],
|
||||||
|
[ '1998-05-07 00:00:00.000000' ],
|
||||||
|
[ '2005-09-01 07:05:19.000000' ],
|
||||||
|
[ '1999-12-01 11:00:00.100000' ],
|
||||||
|
[ '1999-12-01 11:00:00.120000' ],
|
||||||
|
[ '1999-12-01 11:00:00.123000' ],
|
||||||
|
[ '1999-12-01 11:01:10.012300' ],
|
||||||
|
[ '1999-12-01 11:00:00.123400' ],
|
||||||
|
[ '1999-12-01 11:00:00.001230' ],
|
||||||
|
[ '1999-12-01 11:00:00.123450' ],
|
||||||
|
[ '1999-12-01 11:00:00.123456' ],
|
||||||
|
[ '1999-12-01 11:00:00.123457' ],
|
||||||
|
[ '1999-12-01 11:02:20.000012' ],
|
||||||
|
[ '1999-12-01 11:00:00.123457' ],
|
||||||
|
[ '1999-12-01 11:00:00.123457' ],
|
||||||
|
[ '2002-09-10 14:10:10.123000' ]
|
||||||
|
],
|
||||||
|
timestamp_1_2:
|
||||||
|
[
|
||||||
|
{ CONTENT: '2005-06-01 00:00:00.000000' },
|
||||||
|
{ CONTENT: '2005-09-01 00:00:00.000000' },
|
||||||
|
{ CONTENT: '2005-08-05 00:00:00.000000' },
|
||||||
|
{ CONTENT: '1998-07-05 00:00:00.000000' },
|
||||||
|
{ CONTENT: '1998-05-07 00:00:00.000000' },
|
||||||
|
{ CONTENT: '2005-09-01 07:05:19.000000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.100000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.120000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:01:10.012300' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123400' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.001230' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123450' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123456' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123457' },
|
||||||
|
{ CONTENT: '1999-12-01 11:02:20.000012' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123457' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123457' },
|
||||||
|
{ CONTENT: '2002-09-10 14:10:10.123000' }
|
||||||
|
],
|
||||||
|
timestamp_3_1:
|
||||||
|
[
|
||||||
|
[ '2005-01-06 11:00:00.100000' ],
|
||||||
|
[ '2005-09-01 11:00:00.100000' ],
|
||||||
|
[ '2005-08-05 11:00:00.100000' ],
|
||||||
|
[ '1998-07-05 11:00:00.100000' ],
|
||||||
|
[ '1998-05-07 11:00:00.123000' ],
|
||||||
|
[ '1999-12-01 11:00:00.100000' ],
|
||||||
|
[ '1999-12-01 11:00:00.120000' ],
|
||||||
|
[ '1999-12-01 11:00:00.123000' ],
|
||||||
|
[ '1999-12-01 11:00:00.012300' ],
|
||||||
|
[ '1999-12-01 11:00:00.123400' ],
|
||||||
|
[ '1999-12-01 11:00:00.001230' ],
|
||||||
|
[ '1999-12-01 11:00:00.123450' ],
|
||||||
|
[ '1999-12-01 11:00:00.123456' ],
|
||||||
|
[ '1999-12-01 11:00:00.123457' ],
|
||||||
|
[ '1999-12-01 11:20:02.000012' ],
|
||||||
|
[ '1999-12-01 11:00:00.123457' ],
|
||||||
|
[ '1999-12-01 11:00:00.123456' ],
|
||||||
|
[ '1999-12-01 11:00:00.000000' ],
|
||||||
|
[ '2002-09-10 14:10:10.123000' ]
|
||||||
|
],
|
||||||
|
timestamp_3_2:
|
||||||
|
[
|
||||||
|
{ CONTENT: '2005-01-06 11:00:00.100000' },
|
||||||
|
{ CONTENT: '2005-09-01 11:00:00.100000' },
|
||||||
|
{ CONTENT: '2005-08-05 11:00:00.100000' },
|
||||||
|
{ CONTENT: '1998-07-05 11:00:00.100000' },
|
||||||
|
{ CONTENT: '1998-05-07 11:00:00.123000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.100000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.120000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123000' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.012300' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123400' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.001230' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123450' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123456' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123457' },
|
||||||
|
{ CONTENT: '1999-12-01 11:20:02.000012' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123457' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.123456' },
|
||||||
|
{ CONTENT: '1999-12-01 11:00:00.000000' },
|
||||||
|
{ CONTENT: '2002-09-10 14:10:10.123000' }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,509 @@
|
||||||
|
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* You may not use the identified files except in compliance with the Apache
|
||||||
|
* License, Version 2.0 (the "License.")
|
||||||
|
*
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
*
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
|
||||||
|
* See LICENSE.md for relevant licenses.
|
||||||
|
*
|
||||||
|
* NAME
|
||||||
|
* 19. fetchTimestampAsString.js
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
* Fetch Oracle TIMESTAMP types as String data
|
||||||
|
*
|
||||||
|
* NUMBERING RULE
|
||||||
|
* Test numbers follow this numbering rule:
|
||||||
|
* 1 - 20 are reserved for basic functional tests
|
||||||
|
* 21 - 50 are reserved for data type supporting tests
|
||||||
|
* 51 onwards are for other tests
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var oracledb = require('oracledb');
|
||||||
|
var async = require('async');
|
||||||
|
var should = require('should');
|
||||||
|
var dbConfig = require('./dbconfig.js');
|
||||||
|
var assist = require('./dataTypeAssist.js');
|
||||||
|
|
||||||
|
describe('19. fetchTimestampAsString.js', function() {
|
||||||
|
var connection = null;
|
||||||
|
before(function(done) {
|
||||||
|
async.series([
|
||||||
|
function(cb) {
|
||||||
|
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||||
|
should.not.exist(err);
|
||||||
|
connection = conn;
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function(cb) {
|
||||||
|
connection.execute(
|
||||||
|
"alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS.FF'",
|
||||||
|
function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
function(cb) {
|
||||||
|
connection.execute(
|
||||||
|
"alter session set nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS.FF'",
|
||||||
|
function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
], done);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function(done) {
|
||||||
|
oracledb.fetchAsString = [];
|
||||||
|
connection.release(function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('19.1 TIMESTAMP',function() {
|
||||||
|
var tableName = "nodb_timestamp1";
|
||||||
|
var inData = assist.TIMESTAMP_STRINGS;
|
||||||
|
|
||||||
|
before(function(done) {
|
||||||
|
assist.setUp4sql(connection, tableName, inData, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function(done) {
|
||||||
|
oracledb.fetchAsString = [];
|
||||||
|
connection.execute(
|
||||||
|
"DROP table " + tableName + " PURGE",
|
||||||
|
function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}); // after
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
oracledb.fetchAsString = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.1 fetchInfo option', function(done) {
|
||||||
|
var ref = assist.content.timestamp_1_1;
|
||||||
|
test1(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.2 fetchInfo option, outFormat is OBJECT', function(done) {
|
||||||
|
var ref = assist.content.timestamp_1_2;
|
||||||
|
test2(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.3 fetchInfo option, enables resultSet', function(done) {
|
||||||
|
var ref = assist.content.timestamp_1_1;
|
||||||
|
test3(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.4 fetchInfo option, resultSet and OBJECT outFormat', function(done) {
|
||||||
|
var ref = assist.content.timestamp_1_2;
|
||||||
|
test4(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.5 fetchAsString property', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_1_1;
|
||||||
|
test5(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.6 fetchAsString property and OBJECT outFormat', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_1_2;
|
||||||
|
test6(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.7 fetchAsString property, resultSet', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_1_1;
|
||||||
|
test7(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.1.8 fetchAsString property, resultSet and OBJECT outFormat', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_1_2;
|
||||||
|
test8(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
}); // 19.1
|
||||||
|
|
||||||
|
describe('19.2 TIMESTAMP WITH TIME ZONE', function() {
|
||||||
|
|
||||||
|
var tableName = "nodb_timestamp3";
|
||||||
|
var inData = assist.TIMESTAMP_TZ_STRINGS_1;
|
||||||
|
|
||||||
|
before(function(done) {
|
||||||
|
assist.setUp4sql(connection, tableName, inData, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function(done) {
|
||||||
|
oracledb.fetchAsString = [];
|
||||||
|
connection.execute(
|
||||||
|
"DROP table " + tableName + " PURGE",
|
||||||
|
function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}); // after
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
oracledb.fetchAsString = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.1 fetchInfo option', function(done) {
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test1(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.2 fetchInfo option, outFormat is OBJECT', function(done) {
|
||||||
|
var ref = assist.content.timestamp_3_2;
|
||||||
|
test2(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.3 fetchInfo option, enables resultSet', function(done) {
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test3(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.4 fetchInfo option, resultSet and OBJECT outFormat', function(done) {
|
||||||
|
var ref = assist.content.timestamp_3_2;
|
||||||
|
test4(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.5 fetchAsString property', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test5(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.6 fetchAsString property and OBJECT outFormat', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_3_2;
|
||||||
|
test6(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.7 fetchAsString property, resultSet', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test7(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.2.8 fetchAsString property, resultSet and OBJECT outFormat', function(done) {
|
||||||
|
oracledb.fetchAsString = [ oracledb.DATE ];
|
||||||
|
var ref = assist.content.timestamp_3_2;
|
||||||
|
test8(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
}); // 19.2
|
||||||
|
|
||||||
|
describe('19.3 testing maxRows setttings and queryStream() to fetch as string', function() {
|
||||||
|
var tableName = "nodb_timestamp3";
|
||||||
|
var inData = assist.TIMESTAMP_TZ_STRINGS_1;
|
||||||
|
var defaultLimit = oracledb.maxRows;
|
||||||
|
|
||||||
|
before(function(done) {
|
||||||
|
should.strictEqual(defaultLimit, 100);
|
||||||
|
assist.setUp4sql(connection, tableName, inData, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(function(done) {
|
||||||
|
oracledb.fetchAsString = [];
|
||||||
|
connection.execute(
|
||||||
|
"DROP table " + tableName + " PURGE",
|
||||||
|
function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}); // after
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
should.strictEqual(oracledb.maxRows, defaultLimit);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
oracledb.maxRows = defaultLimit;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.3.1 works well when setting oracledb.maxRows > actual number of rows', function(done) {
|
||||||
|
oracledb.maxRows = inData.length * 2;
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test1(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.3.2 maxRows = actual num of rows', function(done) {
|
||||||
|
oracledb.maxRows = inData.length;
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test1(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.3.3 works when oracledb.maxRows < actual number of rows', function(done) {
|
||||||
|
var half = Math.floor(inData.length / 2);
|
||||||
|
oracledb.maxRows = half;
|
||||||
|
var ref = assist.content.timestamp_3_1.slice(0, half);
|
||||||
|
test1(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.3.4 uses queryStream() and maxRows > actual number of rows', function(done) {
|
||||||
|
oracledb.maxRows = inData.length * 2;
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test9(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.3.5 uses queryStream() and maxRows = actual number of rows', function(done) {
|
||||||
|
oracledb.maxRows = inData.length;
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test9(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('19.3.6 maxRows < actual rows. maxRows does not restrict queryStream()', function(done) {
|
||||||
|
var half = Math.floor(inData.length / 2);
|
||||||
|
oracledb.maxRows = half;
|
||||||
|
var ref = assist.content.timestamp_3_1;
|
||||||
|
test9(tableName, ref, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}); // 19.3
|
||||||
|
|
||||||
|
function test9(table, want, callback) {
|
||||||
|
var sql = "select content from " + table + " order by num";
|
||||||
|
var stream = connection.queryStream(
|
||||||
|
sql,
|
||||||
|
[],
|
||||||
|
{ fetchInfo: { "CONTENT": { type: oracledb.STRING } } }
|
||||||
|
);
|
||||||
|
|
||||||
|
var result = [];
|
||||||
|
stream.on('data', function(data) {
|
||||||
|
should.exist(data);
|
||||||
|
result.push(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
stream.on('end', function() {
|
||||||
|
should.deepEqual(result, want);
|
||||||
|
setTimeout(callback, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetchInfo option
|
||||||
|
function test1(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
[],
|
||||||
|
{ fetchInfo: { "CONTENT": { type: oracledb.STRING } } },
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.deepEqual(result.rows, want);
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetchInfo option, outFormat is OBJECT
|
||||||
|
function test2(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
outFormat: oracledb.OBJECT,
|
||||||
|
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||||
|
},
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.deepEqual(result.rows, want);
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetchInfo option, resultSet
|
||||||
|
function test3(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
resultSet: true,
|
||||||
|
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||||
|
},
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
fetchRowFromRS(result.resultSet);
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
function fetchRowFromRS(rs) {
|
||||||
|
rs.getRow(function(err, row) {
|
||||||
|
should.not.exist(err);
|
||||||
|
if(row) {
|
||||||
|
should.deepEqual(row, want[count]);
|
||||||
|
count++;
|
||||||
|
return fetchRowFromRS(rs);
|
||||||
|
} else {
|
||||||
|
rs.close(function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} // end of fetchRowFromRS
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test4(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
outFormat: oracledb.OBJECT,
|
||||||
|
resultSet: true,
|
||||||
|
fetchInfo: { "CONTENT": { type: oracledb.STRING } }
|
||||||
|
},
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
fetchRowFromRS(result.resultSet);
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
function fetchRowFromRS(rs) {
|
||||||
|
rs.getRow(function(err, row) {
|
||||||
|
should.not.exist(err);
|
||||||
|
if(row) {
|
||||||
|
should.deepEqual(row, want[count]);
|
||||||
|
count++;
|
||||||
|
return fetchRowFromRS(rs);
|
||||||
|
} else {
|
||||||
|
rs.close(function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} // end of fetchRowFromRS
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test5(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.deepEqual(result.rows, want);
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test6(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
[],
|
||||||
|
{ outFormat: oracledb.OBJECT },
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.deepEqual(result.rows, want);
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test7(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
resultSet: true
|
||||||
|
},
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
fetchRowFromRS(result.resultSet);
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
function fetchRowFromRS(rs) {
|
||||||
|
rs.getRow(function(err, row) {
|
||||||
|
should.not.exist(err);
|
||||||
|
if(row) {
|
||||||
|
should.deepEqual(row, want[count]);
|
||||||
|
count++;
|
||||||
|
return fetchRowFromRS(rs);
|
||||||
|
} else {
|
||||||
|
rs.close(function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} // end of fetchRowFromRS
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test8(table, want, callback) {
|
||||||
|
connection.execute(
|
||||||
|
"select content from " + table + " order by num",
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
resultSet: true,
|
||||||
|
outFormat: oracledb.OBJECT
|
||||||
|
},
|
||||||
|
function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
fetchRowFromRS(result.resultSet);
|
||||||
|
var count = 0;
|
||||||
|
|
||||||
|
function fetchRowFromRS(rs) {
|
||||||
|
rs.getRow(function(err, row) {
|
||||||
|
should.not.exist(err);
|
||||||
|
if(row) {
|
||||||
|
should.deepEqual(row, want[count]);
|
||||||
|
count++;
|
||||||
|
return fetchRowFromRS(rs);
|
||||||
|
} else {
|
||||||
|
rs.close(function(err) {
|
||||||
|
should.not.exist(err);
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} // end of fetchRowFromRS
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -420,6 +420,31 @@ Overview of node-oracledb functional tests
|
||||||
18.2 jsTypes maps correctly
|
18.2 jsTypes maps correctly
|
||||||
18.3 binding contants maps correctly
|
18.3 binding contants maps correctly
|
||||||
|
|
||||||
|
19. fetchTimestampAsString.js
|
||||||
|
19.1 TIMESTAMP
|
||||||
|
19.1.1 fetchInfo option
|
||||||
|
19.1.2 fetchInfo option, outFormat is OBJECT
|
||||||
|
19.1.3 fetchInfo option, enables resultSet
|
||||||
|
19.1.4 fetchInfo option, resultSet and OBJECT outFormat
|
||||||
|
19.1.5 fetchAsString property
|
||||||
|
19.1.6 fetchAsString property and OBJECT outFormat
|
||||||
|
19.1.7 fetchAsString property, resultSet
|
||||||
|
19.1.8 fetchAsString property, resultSet and OBJECT outFormat
|
||||||
|
19.2 TIMESTAMP WITH TIME ZONE
|
||||||
|
19.2.1 fetchInfo option
|
||||||
|
19.2.2 fetchInfo option, outFormat is OBJECT
|
||||||
|
19.2.3 fetchInfo option, enables resultSet
|
||||||
|
19.2.4 fetchInfo option, resultSet and OBJECT outFormat
|
||||||
|
19.2.5 fetchAsString property
|
||||||
|
19.2.6 fetchAsString property and OBJECT outFormat
|
||||||
|
19.2.7 fetchAsString property, resultSet
|
||||||
|
19.3 testing maxRows setttings and queryStream() to fetch as string
|
||||||
|
19.3.1 works well when setting oracledb.maxRows > actual number of rows
|
||||||
|
19.3.2 maxRows = actual num of rows
|
||||||
|
19.3.3 works when oracledb.maxRows < actual number of rows
|
||||||
|
19.3.4 uses queryStream() and maxRows > actual number of rows
|
||||||
|
19.3.5 uses queryStream() and maxRows = actual number of rows
|
||||||
|
19.3.6 maxRows < actual rows. maxRows does not restrict queryStream()
|
||||||
|
|
||||||
21. dataTypeAssist.js
|
21. dataTypeAssist.js
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ test/resultsetToStream.js
|
||||||
test/promises.js
|
test/promises.js
|
||||||
test/extendedMetaData.js
|
test/extendedMetaData.js
|
||||||
test/constants.js
|
test/constants.js
|
||||||
|
test/fetchTimestampAsString.js
|
||||||
test/dataTypeAssist.js
|
test/dataTypeAssist.js
|
||||||
test/dataTypeChar.js
|
test/dataTypeChar.js
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue