Skip to content

Commit 911f301

Browse files
committed
Test and Documentation updates for 6.3 features
1 parent d2cd299 commit 911f301

File tree

9 files changed

+522
-18
lines changed

9 files changed

+522
-18
lines changed

doc/src/api_manual/connection.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,32 @@ The properties of a *Connection* object are listed below.
342342
value is *False*, then the specified connection does not have an active
343343
transaction.
344344

345+
.. attribute:: connection.warning
346+
347+
.. versionadded:: 6.3
348+
349+
This read-only property provides an :ref:`error <errorobj>` object that
350+
gives information about any database warnings (such as password being in
351+
the grace period) that were generated during
352+
:meth:`connection establishment <oracledb.getConnection()>` (both
353+
standalone connections and pooled connections). This attribute is present
354+
if a warning is thrown by the database but the operation is otherwise
355+
completed successfully. The connection will be usable despite the warning.
356+
357+
For :ref:`standalone connections <standaloneconnection>`, the error object
358+
returned by ``connection.warning`` will be present for the lifetime of the
359+
connection.
360+
361+
For :ref:`pooled connections <connpooling>`, the error object returned by
362+
``connection.warning`` will be cleared when a connection is released to
363+
the pool using :meth:`connection.close()`.
364+
365+
In node-oracledb Thick mode, warnings may be generated during pool
366+
creation itself. These warnings will be placed on the new connections
367+
created by the pool, provided no warnings were generated by the individual
368+
connection creations, in which case those connection warnings will be
369+
returned.
370+
345371
.. _connectionmethods:
346372

347373
Connection Methods
@@ -1120,6 +1146,14 @@ Connection Methods
11201146
This property is a number. For `DML <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-2E008D4A-F6FD-4F34-9071-7E10419CA24D>`__ statements this contains the number of rows affected, for example the number of rows inserted. For non-DML statements such as queries and PL/SQL statements, ``rowsAffected`` is undefined.
11211147

11221148
Due to Node.js type limitations, the largest value shown will be 232 - 1, even if more rows were affected. Larger values will wrap.
1149+
* - ``warning``
1150+
- .. _execwarning:
1151+
1152+
This property provides an :ref:`error <errorobj>` object that gives information about any database warnings (such as PL/SQL compilation warnings) that were generated during the last call to :meth:`connection.execute()`.
1153+
1154+
See :ref:`plsqlcompwarnings` for more information.
1155+
1156+
.. versionadded:: 6.3
11231157

11241158
.. method:: connection.executeMany()
11251159

@@ -1365,6 +1399,15 @@ Connection Methods
13651399
It is only present if a DML statement was executed.
13661400

13671401
Due to Node.js type limitations, the largest value shown will be 232 - 1, even if more rows were affected. Larger values will wrap.
1402+
* - ``warning``
1403+
- Object
1404+
- .. _execmanywarning:
1405+
1406+
This property provides an :ref:`error <errorobj>` object that gives information about any database warnings (such as PL/SQL compilation warnings) that were generated during the last call to :meth:`connection.executeMany()`.
1407+
1408+
See :ref:`plsqlcompwarnings` for more information.
1409+
1410+
.. versionadded:: 6.3
13681411

13691412
.. method:: connection.getDbObjectClass()
13701413

doc/src/release_notes.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ node-oracledb `v6.3.0 <https://github.com/oracle/node-oracledb/compare/v6.2.0...
1313
Common Changes
1414
++++++++++++++
1515

16-
#) Added a ``warning`` property to the ``result`` object for database
17-
warnings (such as PL/SQL compilation warnings) generated by calls to
18-
:meth:`connection.execute()` or :meth:`connection.executeMany()`.
19-
20-
#) Added property :attr:`connection.warning` for warnings (such as the
21-
password being in the grace period) generated during connection.
16+
#) Added a :ref:`warning <execwarning>` property to the
17+
:ref:`result <resultobject>` object for database warnings (such as PL/SQL
18+
compilation warnings) that are generated by calls to
19+
:meth:`connection.execute()`. Also, added the
20+
:ref:`warning <execmanywarning>` property to the
21+
:ref:`result <resultobjproperties>` object of
22+
:meth:`connection.executeMany()`.
23+
24+
#) Added a :attr:`connection.warning` property for warnings (such as the
25+
password being in the grace period) that are generated during connection.
2226

2327
#) VARCHAR2 and LOB columns which contain JSON, and have the "IS JSON" check
2428
constraint enabled, can now be fetched in the same way as columns of type

doc/src/user_guide/migrate.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,65 @@
44
Upgrading to the Latest node-oracledb Releases
55
**********************************************
66

7+
.. _upgradev62v63:
8+
9+
Upgrading from node-oracledb 6.2 to 6.3
10+
=======================================
11+
12+
- Review the :ref:`releasenotes` and take advantage of new features.
13+
14+
- Using the new :ref:`warning <execwarning>` property of the
15+
:ref:`result object <resultobject>` in :meth:`connection.execute()`, your
16+
application can manually check for database warnings such as
17+
:ref:`plsqlcompwarnings`. Also, you can use the new
18+
:ref:`warning <execmanywarning>` property in the
19+
:ref:`result object <resultobjproperties>` of
20+
:meth:`connection.executeMany()` to check for similar warnings.
21+
22+
- The new :attr:`connection.warning` property can be used to check for
23+
warnings that are generated during connection such as the password being in
24+
the grace period.
25+
26+
- By setting the new :attr:`oracledb.future.oldJsonColumnAsObj` property to
27+
*true*, you can fetch the VARCHAR2 and LOB columns which contain JSON in the
28+
same way as :ref:`columns of type JSON <json21fetch>`. See
29+
:ref:`json12ctype` for more information. In a future version of
30+
node-oracledb, the setting of this attribute will no longer be required
31+
since this will become the default behavior.
32+
33+
- With the new :ref:`oracledb.DB_TYPE_XMLTYPE <oracledbconstantsdbtype>`
34+
constant, you can now represent data of type ``SYS.XMLTYPE`` in the
35+
``fetchType`` and ``dbType`` :ref:`metadata <execmetadata>` information
36+
attributes.
37+
38+
- node-oracledb now supports using Azure and Oracle Cloud Infrastructure (OCI)
39+
Software Development Kits (SDKs) to generate
40+
:ref:`authentication tokens <tokenbasedauthentication>`.
41+
42+
- With the new connection properties :attr:`connection.dbDomain`,
43+
:attr:`connection.dbName`, :attr:`connection.maxOpenCursors`,
44+
:attr:`connection.serviceName` and :attr:`connection.transactionInProgress`,
45+
you can identify the database domain name, database instance name, maximum
46+
number of cursors that can be opened per connection, database service name,
47+
and status of any ongoing transactions on the connection respectively.
48+
49+
- The new :ref:`metadata <execmetadata>` information attribute ``isJson``
50+
indicates whether the fetched column contains JSON data.
51+
52+
- The new :ref:`metadata <execmetadata>` information attributes
53+
``annotations``, ``domainName``, and ``domainSchema`` identifies the
54+
`annotations <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=
55+
GUID-1AC16117-BBB6-4435-8794-2B99F8F68052>`__ object, the name of the
56+
`SQL domain <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=
57+
GUID-17D3A9C6-D993-4E94-BF6B-CACA56581F41>`_, and the schema name of the
58+
`SQL domain <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=
59+
GUID-17D3A9C6-D993-4E94-BF6B-CACA56581F41>`__ associated with the fetched
60+
column. Annotations and SQL domains are supported from Oracle Database 23c
61+
onwards. For node-oracledb Thick mode, Oracle Client 23c is also required.
62+
63+
- In node-oracledb Thin mode, ``SYS.XMLTYPE`` data can now be
64+
:ref:`fetched as strings <xmltype>`.
65+
766
.. _upgradev61v62:
867

968
Upgrading from node-oracledb 6.1 to 6.2

doc/src/user_guide/plsql_execution.rst

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,27 @@ tree/main/examples/plsqlproc.js>`__ and `plsqlfunc.js
446446
PL/SQL Compilation Warnings
447447
---------------------------
448448

449-
When creating PL/SQL procedures and functions in node-oracledb,
450-
compilation warnings must be manually checked for. This can be done by
451-
querying ``USER_ERRORS`` like:
449+
When creating PL/SQL procedures and functions (or creating types) in
450+
node-oracledb using SQL statements, the statement might succeed without
451+
throwing an error, but there may be additional informational messages. (These
452+
messages are sometimes known in Oracle as "success with info" messages). Your
453+
application can manually check for these messages using the
454+
:ref:`warning <execwarning>` property of the
455+
:ref:`result object <resultobject>` in :meth:`connection.execute()` or
456+
:meth:`connection.executemany()`. A subsequent query from a table like
457+
``USER_ERRORS`` will show more details. For example:
452458

453459
.. code-block:: javascript
454460
455-
await connection.execute(
461+
const result = await connection.execute(
456462
`CREATE OR REPLACE PROCEDURE badproc AS
457463
BEGIN
458464
INVALID
459465
END;`);
460466
467+
if (result.warning && result.warning.code == "NJS-700")
468+
console.log(result.warning.message)
469+
461470
const r = await connection.execute(
462471
`SELECT line, position, text
463472
FROM user_errors
@@ -471,8 +480,20 @@ querying ``USER_ERRORS`` like:
471480
console.error('at line', r.rows[0].LINE, 'position', r.rows[0].POSITION);
472481
}
473482
474-
Output is like::
483+
In node-oracledb Thin mode, the output would be::
484+
485+
NJS-700: creation succeeded with compilation errors
486+
PLS-00103: Encountered the symbol "END" when expecting one of the following:
487+
488+
:= . ( @ % ;
489+
The symbol ";" was substituted for "END" to continue.
490+
491+
at line 4 position 8
492+
493+
In node-oracledb Thick mode, the output would be::
475494

495+
NJS-700: creation succeeded with compilation errors
496+
ORA-24344: success with compilation error
476497
PLS-00103: Encountered the symbol "END" when expecting one of the following:
477498

478499
:= . ( @ % ;

test/dbObject4.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const dbConfig = require('./dbconfig.js');
3737
const testsUtil = require('./testsUtil.js');
3838

3939
describe('203. dbObject4.js', () => {
40-
let conn;
40+
let conn, testCount = 0;
4141
const TYPE = 'NODB_TYP_OBJ_4';
4242
const TABLE = 'NODB_TAB_OBJ4';
4343

@@ -106,7 +106,13 @@ describe('203. dbObject4.js', () => {
106106
await conn.close();
107107
}); // after()
108108

109-
it('203.1 insert an object with LTZ type attribute', async () => {
109+
it('203.1 insert an object with LTZ type attribute', async function() {
110+
/*
111+
* The Oracle Instant Client version should be 19.20 or greater as there is a
112+
* bug in setting the timezone with the lower Oracle Instant Client versions.
113+
*/
114+
const isRunnable = await testsUtil.checkPrerequisites(1920000000, undefined);
115+
if (!isRunnable) this.skip();
110116
const seq = 101;
111117
let sql = `INSERT INTO ${TABLE} VALUES (:1, :2)`;
112118

@@ -129,6 +135,7 @@ describe('203. dbObject4.js', () => {
129135
assert.strictEqual(result.rows[0][1]['ENTRY'].getTime(), date1.getTime());
130136
assert.strictEqual(result.rows[0][1]['EXIT'].getTime(), date2.getTime());
131137
assert.strictEqual(result.rows[0][0], seq);
138+
testCount++;
132139
}); // 203.1
133140

134141
it('203.2 insert null value for LTZ type attribute', async () => {
@@ -152,6 +159,7 @@ describe('203. dbObject4.js', () => {
152159
assert.strictEqual(result.rows[0][1]['ENTRY'], null);
153160
assert.strictEqual(result.rows[0][1]['EXIT'], null);
154161
assert.strictEqual(result.rows[0][0], seq);
162+
testCount++;
155163
}); // 203.2
156164

157165
it('203.3 insert undefined value for LTZ type attribute', async () => {
@@ -175,6 +183,7 @@ describe('203. dbObject4.js', () => {
175183
assert.strictEqual(result.rows[0][1]['ENTRY'], null);
176184
assert.strictEqual(result.rows[0][1]['EXIT'], null);
177185
assert.strictEqual(result.rows[0][0], seq);
186+
testCount++;
178187
}); // 203.3
179188

180189
it('203.4 insert an empty JSON', async () => {
@@ -193,6 +202,7 @@ describe('203. dbObject4.js', () => {
193202

194203
assert.strictEqual(result.rows[0][1]['ENTRY'], null);
195204
assert.strictEqual(result.rows[0][1]['EXIT'], null);
205+
testCount++;
196206
}); // 203.4
197207

198208
it('203.5 call procedure with 2 OUT binds of DbObject', async function() {
@@ -207,11 +217,11 @@ describe('203. dbObject4.js', () => {
207217
);
208218

209219
let resultSet = await result.outBinds.p_cur1.getRows();
210-
assert.equal(resultSet.length, 4);
220+
assert.equal(resultSet.length, testCount);
211221
result.outBinds.p_cur1.close();
212222

213223
resultSet = await result.outBinds.p_cur2.getRows();
214-
assert.equal(resultSet.length, 4);
224+
assert.equal(resultSet.length, testCount);
215225
result.outBinds.p_cur2.close();
216226
}); // 203.5;
217227

0 commit comments

Comments
 (0)