Skip to content

Commit ea431d3

Browse files
committed
More test and documentation updates for Oracle Database 23ai
1 parent bf5e698 commit ea431d3

File tree

11 files changed

+480
-167
lines changed

11 files changed

+480
-167
lines changed

doc/src/release_notes.rst

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ node-oracledb `v6.5.0 <https://github.com/oracle/node-oracledb/compare/v6.4.0...
1313
Common Changes
1414
++++++++++++++
1515

16-
#) Incorporate changes to use end of data request flag set with data packets
16+
#) Incorporated changes to use end of data request flag set with data packets
1717
available in Oracle Database 23c to improve handling of the async reads.
1818

1919
#) Added class :ref:`oracledb.JsonId <jsonid>` to represent JSON ID values
20-
returned by SODA in Oracle Database 23.4 and higher in the ``_id``
20+
returned by SODA in Oracle Database 23.4 and later in the ``_id``
2121
attribute of documents stored in native collections.
2222

2323
#) Added support for an Oracle Database 23c JSON feature allowing for field
@@ -26,27 +26,31 @@ Common Changes
2626
#) Added support for an Oracle Database 23c JSON feature improving JSON
2727
storage usage.
2828

29-
#) Updated error thrown during pool reconfiguration from `ORA-24413` to
30-
`NJS-007` when poolMax is 0.
29+
#) Updated the error thrown during pool reconfiguration from ``ORA-24413`` to
30+
``NJS-007`` when ``poolMax`` is *0*.
3131

32-
#) Throw `NJS-092` error if `poolMin` > `poolMax` during pool
33-
reconfiguration.
32+
#) Error ``NJS-092`` is now thrown during
33+
:meth:`pool reconfiguration <pool.reconfigure()>` if the ``poolMin`` value is
34+
greater than the ``poolMax`` value.
3435

35-
#) Added support for binding BigInt values. BigInts like ``123n`` can
36-
be passed to ``connection.execute()``, ``connection.executeMany()``.
36+
#) Added support for :ref:`binding BigInt values <binddatatypenotes>`.
37+
BigInts such as ``123n`` can be passed to :meth:`connection.execute()` and
38+
:meth:`connection.executeMany()`.
3739
See `PR #1572 <https://github.com/oracle/node-oracledb/pull/1572>`__
3840
(Slawomir Osoba).
3941

4042
Thin Mode Changes
4143
++++++++++++++++++
44+
4245
#) Updated the ClientInfo terminal parameter to remove the hardcoded value.
4346
See `Issue #1662 <https://github.com/oracle/node-oracledb/issues/1662>`__.
4447

4548
#) Fixed issue with connecting to Oracle Database, when the full path of
46-
the Node.js executable contains certain non-standard characters like '(' and ')'.
49+
the Node.js executable contains certain non-standard characters such as
50+
'(' and ')'.
4751
See `Issue #1664 <https://github.com/oracle/node-oracledb/issues/1664>`__.
4852

49-
#) Added support for easy connect string entries in tnsnames.ora
53+
#) Added support for easy connect string entries in tnsnames.ora.
5054
See `Issue #1644 <https://github.com/oracle/node-oracledb/issues/1644>`__.
5155

5256
#) Added support for Oracle Database 23c feature that can improve the
@@ -61,22 +65,23 @@ Thin Mode Changes
6165
errors were raised.
6266
See `Issue #1652 <https://github.com/oracle/node-oracledb/issues/1652>`__.
6367

64-
#) Added support for pool reconfiguration.
68+
#) Added support for :meth:`pool reconfiguration <pool.reconfigure()>`.
6569

6670
#) Added support for Oracle Database 23c
67-
:ref:`Implicit Connection Pooling <implicitpool>` in DRCP and PRCP.
71+
:ref:`Implicit Connection Pooling <implicitpool>` in Database Resident
72+
Connection Pooling (DRCP) and Proxy Resident Connection Pooling (PRCP).
6873

69-
#) Added support for usage with extension of Array.prototype methods
74+
#) Added support for usage with extension of Array.prototype methods.
7075
See `Issue #1653 <https://github.com/oracle/node-oracledb/issues/1653>`__.
7176

7277
#) Fixed bug which threw an error due to the presence of duplicate cursors
73-
with DRCP.
78+
with :ref:`DRCP <drcp>`.
7479

7580
Thick Mode Changes
7681
+++++++++++++++++++
7782

78-
#) Fixed an issue with privileges that prevented the startup() function from
79-
bringing up the database.
83+
#) Fixed an issue with privileges that prevented the
84+
:meth:`oracledb.startup()` method from bringing up the database.
8085

8186
#) Tightened code to avoid possible unexpected runtime errors during token
8287
callback.
@@ -86,7 +91,7 @@ Thick Mode Changes
8691

8792
#) Fixed the bug which inserted the invalid value `~` into the database
8893
if an unacceptable out-of-bounds number is bound to a DML statement. Now,
89-
numbers like 1.0e+128, -1e128, etc. will throw an error
94+
numbers such as 1.0e+128, -1e128, and so on will throw an error
9095
``NJS-115: value cannot be represented as an Oracle Database number``.
9196
Additionally, this fix resolves the issue related to JS numbers with
9297
precisions where `2.3` is returned as `2.300003`.

test/callTimeout.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,16 @@ describe('222. callTimeout.js', function() {
157157
const result = await conn.execute(`SELECT (1+2) AS SUM FROM DUAL`);
158158
assert.strictEqual(3, result.rows[0][0]);
159159
});
160+
161+
it('222.9 get the callTimeout value', async () => {
162+
const TIME_OUT = 10;
163+
const DB_OP_TIME = 2;
164+
165+
//set the callTimeout
166+
conn.callTimeout = TIME_OUT * 1000; // milliseconds
167+
168+
// get and assert the set callTimeout
169+
assert.strictEqual(conn.callTimeout, TIME_OUT * 1000);
170+
await conn.execute(`BEGIN DBMS_SESSION.SLEEP(:sleepsec); END;`, [DB_OP_TIME]);
171+
});
160172
});

test/invalidNumber.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,20 @@
3434
const oracledb = require('oracledb');
3535
const assert = require('assert');
3636
const dbConfig = require('./dbconfig.js');
37+
const testsUtil = require('./testsUtil.js');
3738

3839
describe('299. invalidNumber.js', function() {
3940
let conn;
41+
let tableName = 'nodb_num';
4042

4143
before(async function() {
4244
conn = await oracledb.getConnection(dbConfig);
43-
await conn.execute('CREATE TABLE nodb_num(id NUMBER)');
45+
const sql = `CREATE TABLE ${tableName}(id NUMBER)`;
46+
await testsUtil.createTable(conn, tableName, sql);
4447
});
4548

4649
after(async function() {
47-
await conn.execute('DROP TABLE nodb_num PURGE');
50+
await testsUtil.dropTable(conn, tableName);
4851
await conn.close();
4952
});
5053

@@ -56,6 +59,6 @@ describe('299. invalidNumber.js', function() {
5659
async () => await conn.execute(sql, binds),
5760
/NJS-115:/
5861
);
59-
}); //299.1
62+
}); // 299.1
6063

6164
});

test/list.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,6 +4675,7 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
46754675
222.6 callTimeout is a String
46764676
222.7 The callTimeout value applies not to the sum of all round-trips
46774677
222.8 The callTimeout value applies to each round-trip individually
4678+
222.9 get the callTimeout value
46784679

46794680
223. accessPropertiesOnClosedObjects.js
46804681
223.1 access properties of closed Connection object
@@ -5265,6 +5266,8 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
52655266
259.2.5 negative - missing formatId in XID
52665267
259.2.6 negative missing globalTxnId in XID
52675268
259.2.7 negative missing branchQualifier in XID
5269+
259.2.8 negative tpcForget after tpcPrepare
5270+
259.2.9 negative tpcForget without tpcPrepare
52685271
259.3 TPC Functions with no default values
52695272
259.3.1 test tpcBegin, tpcPrepare, tpcRollback
52705273
259.3.2 test tpcBegin, tpcPrepare, tpcCommit

test/nullColumnValues.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015, 2022, Oracle and/or its affiliates. */
1+
/* Copyright (c) 2015, 2024, Oracle and/or its affiliates. */
22

33
/******************************************************************************
44
*
@@ -166,7 +166,7 @@ describe('10. nullColumnValues.js', function() {
166166

167167
await connection.execute(
168168
"UPDATE nodb_nullcol_dept SET department_name = :dname, \
169-
manager_id = :mid WHERE department_id = :did ",
169+
manager_id = :mid WHERE department_id = :did",
170170
{
171171
dname: '',
172172
mid: null,
@@ -177,7 +177,7 @@ describe('10. nullColumnValues.js', function() {
177177
"SELECT * FROM nodb_nullcol_dept WHERE department_id = :1",
178178
[50],
179179
{ resultSet: true });
180-
await fetchRowFromRS(result.resultSet);
180+
await fetchRowFromRS(result.resultSet);
181181

182182
async function fetchRowFromRS(rs) {
183183
let accessCount = 0;

test/passwordExpiryWarning.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2023, Oracle and/or its affiliates. */
1+
/* Copyright (c) 2023, 2024, Oracle and/or its affiliates. */
22

33
/******************************************************************************
44
*
@@ -71,14 +71,17 @@ describe('292. passwordExpiryWarning.js', function() {
7171
};
7272

7373
before(async function() {
74-
if (dbConfig.test.drcp) this.skip();
74+
if (!dbConfig.test.DBA_PRIVILEGE || dbConfig.test.drcp) this.skip();
75+
7576
const connAsDBA = await oracledb.getConnection(dbaCredential);
7677
await connAsDBA.execute(plsql);
7778
await testsUtil.sleep(2000);
7879
await connAsDBA.close();
7980
});
8081

8182
after(async function() {
83+
if (!dbConfig.test.DBA_PRIVILEGE || dbConfig.test.drcp) return;
84+
8285
const connAsDBA = await oracledb.getConnection(dbaCredential);
8386
await connAsDBA.execute (`ALTER USER ${userName} PROFILE DEFAULT`);
8487
await connAsDBA.execute (`DROP PROFILE SHORT_LIFE_PROFILE1`);

test/random.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
1+
/* Copyright (c) 2017, 2024, Oracle and/or its affiliates. */
22

33
/******************************************************************************
44
*
@@ -27,34 +27,34 @@
2727
*
2828
* DESCRIPTION
2929
* generate a random string which length is 'length', with specialStr
30-
* in it's head and tail
30+
* at its head and tail
3131
*
3232
*****************************************************************************/
3333
'use strict';
3434

35-
var random = exports;
35+
let random = exports;
3636
module.exports = random;
3737

3838
// generate a random string which length is 'length', with specialStr in it's head and tail
3939
random.getRandomString = function(length, specialStr) {
40-
var str = '';
41-
var strLength = length - specialStr.length * 2;
40+
let str = '';
41+
let strLength = length - specialStr.length * 2;
4242
for (; str.length < strLength; str += Math.random().toString(36).slice(2));
43-
str = str.substr(0, strLength);
43+
str = str.slice(0, strLength);
4444
str = specialStr + str + specialStr;
4545
return str;
4646
};
4747

4848
random.getRandomLengthString = function(length) {
49-
var str = '';
49+
let str = '';
5050
for (; str.length < length; str += Math.random().toString(36).slice(2));
51-
str = str.substr(0, length);
51+
str = str.slice(0, length);
5252
return str;
5353
};
5454

5555
random.getRandomNumArray = function(size) {
56-
var numbers = new Array(size);
57-
for (var i = 0; i < numbers.length; i++) {
56+
let numbers = new Array(size);
57+
for (let i = 0; i < numbers.length; i++) {
5858
numbers[i] = this.getRandomInt(1, 9999999);
5959
}
6060
return numbers;
@@ -67,7 +67,7 @@ random.getRandomInt = function(min, max) {
6767
};
6868

6969
random.getIntArray = function(N) {
70-
var arr = Array.apply(null, Array(N));
70+
let arr = Array.apply(null, Array(N));
7171
// The map() method creates a new array with the results of calling a provided function on every element in this array.
7272
// var new_array = arr.map(callback[, thisArg])
7373
// Parameters

test/soda1.js

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ describe('164. soda1.js', () => {
211211
await conn.close();
212212
}); // 164.9
213213

214-
it('164.10 the "examples/soda1.js" case', async () => {
214+
it('164.10 the "examples/soda1.js" case with autoCommit = true', async () => {
215+
oracledb.autoCommit = true;
215216
const conn = await oracledb.getConnection(dbConfig);
216217
// Create the parent object for SODA
217218
const soda = conn.getSodaDatabase();
@@ -274,7 +275,7 @@ describe('164. soda1.js', () => {
274275
// Count all documents
275276
const res1 = await collection.find().count();
276277
assert.strictEqual(res1.count, 4);
277-
278+
oracledb.autoCommit = false;
278279
// Remove documents with cities containing 'o'
279280
const res2 = await collection.find().filter({"address.city": {"$regex": ".*o.*"}}).remove();
280281
assert.strictEqual(res2.count, 2);
@@ -293,7 +294,89 @@ describe('164. soda1.js', () => {
293294
await conn.close();
294295
}); // 164.10
295296

296-
it('164.11 Negative: create collection with invalid metaData value', async () => {
297+
it('164.11 the "examples/soda1.js" case with no autocommit set up', async () => {
298+
const conn = await oracledb.getConnection(dbConfig);
299+
// Create the parent object for SODA
300+
const soda = conn.getSodaDatabase();
301+
302+
// Create a new SODA collection and index
303+
const collection = await soda.createCollection("soda_test_164_11");
304+
const indexSpec = {
305+
"name": "CITY_IDX",
306+
"fields": [
307+
{
308+
"path": "address.city",
309+
"datatype": "string",
310+
"order": "asc"
311+
}
312+
]
313+
};
314+
await collection.createIndex(indexSpec);
315+
316+
// Insert a document
317+
// A system generated key is created by default
318+
const content1 = { name: "Matilda", address: {city: "Melbourne"} };
319+
const doc1 = await collection.insertOneAndGet(content1);
320+
const myKey = doc1.key;
321+
assert(myKey);
322+
assert.strictEqual(typeof (myKey), "string");
323+
324+
// Fetch the document back
325+
const doc2 = await collection.find().key(myKey).getOne();
326+
const content2 = doc2.getContent(); // A JavaScript object
327+
testsUtil.removeID(content1);
328+
testsUtil.removeID(content2);
329+
assert.deepStrictEqual(content2, content1);
330+
331+
const content3 = testsUtil.removeID(doc2.getContentAsString()); // A JSON string
332+
333+
assert.strictEqual(JSON.stringify(content2), content3);
334+
335+
// Replace document contents
336+
const content4 = { name: "Matilda", address: {city: "Sydney"} };
337+
await collection.find().key(myKey).replaceOne(content4);
338+
339+
// Insert some more documents without caring about their keys
340+
const content5 = { name: "Venkat", address: {city: "Bengaluru"} };
341+
await collection.insertOne(content5);
342+
const content6 = { name: "May", address: {city: "London"} };
343+
await collection.insertOne(content6);
344+
const content7 = { name: "Sally-Ann", address: {city: "San Francisco"} };
345+
await collection.insertOne(content7);
346+
347+
// Find all documents with city names starting with 'S'
348+
const documents = await collection.find()
349+
.filter({"address.city": {"$like": "S%"}})
350+
.getDocuments();
351+
352+
for (let i = 0; i < documents.length; i++) {
353+
const content = documents[i].getContent();
354+
(['Sydney', 'San Francisco']).includes(content.address.city);
355+
}
356+
357+
// Count all documents
358+
const res1 = await collection.find().count();
359+
assert.strictEqual(res1.count, 4);
360+
361+
// Remove documents with cities containing 'o'
362+
const res2 = await collection.find().filter({"address.city": {"$regex": ".*o.*"}}).remove();
363+
assert.strictEqual(res2.count, 2);
364+
365+
// Count all documents
366+
const res3 = await collection.find().count();
367+
assert.strictEqual(res3.count, 2);
368+
369+
await collection.dropIndex("CITY_IDX");
370+
371+
// Commit changes
372+
await conn.commit();
373+
374+
const res = await collection.drop();
375+
assert.strictEqual(res.dropped, true);
376+
await conn.close();
377+
}); // 164.11
378+
379+
it('164.12 Negative: create collection with invalid metaData value', async () => {
297380
const conn = await oracledb.getConnection(dbConfig);
298381
const sd = conn.getSodaDatabase();
299382

@@ -306,6 +389,6 @@ describe('164. soda1.js', () => {
306389
);
307390

308391
await conn.close();
309-
}); // 164.11
392+
}); // 164.12
310393

311394
});

0 commit comments

Comments
 (0)