Skip to content

Commit 86ce4d4

Browse files
committed
Accept an sql object as an input parameter for connection.execute() (Issue #1629)
1 parent cb47c06 commit 86ce4d4

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

doc/src/release_notes.rst

+12-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ node-oracledb `v6.4.0 <https://github.com/oracle/node-oracledb/compare/v6.3.0...
1313
Common Changes
1414
++++++++++++++
1515

16+
#) Accept an object as an input parameter for :meth:`connection.execute()`
17+
as per GitHub user request.
18+
See `Issue #1629 <https://github.com/oracle/node-oracledb/issues/1629>`__.
19+
This object is returned from the 3rd party ``sql-template-tag`` module and
20+
exposes statement and values properties to retrieve sql string
21+
and bind values.
22+
1623
#) Added new extended :ref:`metadata <execmetadata>` information attribute
1724
``isOson`` for a fetched column.
1825

@@ -44,14 +51,16 @@ Thin Mode Changes
4451
unless the number of batch errors is a multiple of 65536; instead,
4552
the number of batch errors returned is modulo 65536.
4653

47-
#) Updated pool functionality to scan and remove idle connections from
48-
beginning of free connection list. This will ensure removal of all idle
49-
connections present in free connection list.
54+
#) Updated connection pool to scan and remove idle connections from
55+
the beginning of the free connection list. This will ensure removal of all
56+
idle connections present in the free connection list.
5057
`Issue #1633 <https://github.com/oracle/node-oracledb/issues/1633>`__.
5158

5259
Thick Mode Changes
5360
++++++++++++++++++
5461

62+
#) Internal code and memory optimization changes for Advanced Queuing.
63+
5564
node-oracledb `v6.3.0 <https://github.com/oracle/node-oracledb/compare/v6.2.0...v6.3.0>`__ (21 Dec 2023)
5665
--------------------------------------------------------------------------------------------------------
5766

lib/connection.js

+18-7
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,24 @@ class Connection extends EventEmitter {
847847
let options = {};
848848

849849
// process arguments
850-
errors.assertArgCount(arguments, 1, 3);
851-
errors.assertParamValue(typeof sql === 'string', 1);
852-
if (arguments.length >= 2) {
853-
binds = await this._processExecuteBinds(a2);
854-
}
855-
if (arguments.length == 3) {
856-
options = this._verifyExecOpts(a3, false);
850+
if (nodbUtil.isObject(sql) && typeof sql.statement === 'string') {
851+
errors.assertArgCount(arguments, 1, 2);
852+
if (sql.values) {
853+
binds = await this._processExecuteBinds(sql.values);
854+
}
855+
sql = sql.statement;
856+
if (arguments.length == 2) {
857+
options = this._verifyExecOpts(a2, false);
858+
}
859+
} else {
860+
errors.assertArgCount(arguments, 1, 3);
861+
errors.assertParamValue(typeof sql === 'string', 1);
862+
if (arguments.length >= 2) {
863+
binds = await this._processExecuteBinds(a2);
864+
}
865+
if (arguments.length == 3) {
866+
options = this._verifyExecOpts(a3, false);
867+
}
857868
}
858869
this._addDefaultsToExecOpts(options);
859870
errors.assert(this._impl, errors.ERR_INVALID_CONNECTION);

0 commit comments

Comments
 (0)