Skip to content

Commit 3199498

Browse files
committed
Keep the method name in internally bound functions
1 parent 1734c4d commit 3199498

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
**This release is under development and information may be incomplete**
66

7+
- Added code to keep the method name in internally bound functions.
8+
PR #1466 (Slawomir Osoba)
9+
710
- Added code to handle multiple out-binds with ([DbObject](https://oracle.github.io/node-oracledb/doc/api.html#dbobjectclass)) correctly, earlier only
811
the first one was processed and was resulting in a crash.
912
([Issue #1464](https://github.com/oracle/node-oracledb/issues/1464))

lib/util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module.exports.checkArgCount = checkArgCount;
170170
// is resolved or rejected and the callback invoked; otherwise, the function is
171171
// called unchanged and a promise is returned
172172
function callbackify(func) {
173-
return function() {
173+
const wrapper = function() {
174174

175175
// if last argument is not a function, simply invoke the function as usual
176176
// and a promise will be returned
@@ -186,6 +186,10 @@ function callbackify(func) {
186186
}, cb);
187187

188188
};
189+
if (func.name) {
190+
Object.defineProperty(wrapper, 'name', { value: func.name });
191+
}
192+
return wrapper;
189193
}
190194

191195
module.exports.callbackify = callbackify;

test/list.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5299,3 +5299,7 @@ oracledb.OUT_FORMAT_OBJECT and resultSet = true
52995299

53005300
262. dbObjectOutBind.js
53015301
262.1 call procedure with 2 OUT binds of DbObject
5302+
5303+
5304+
264. methodName.js
5305+
264.1 check for methodName getConnection

test/methodName.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* Copyright (c) 2022, Oracle and/or its affiliates. */
2+
3+
/******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* NAME
19+
* 264. methodName.js
20+
*
21+
* DESCRIPTION
22+
* Test to verify the code to keep the method name in internally bound
23+
* functions.
24+
*
25+
* Note: These tests uses additional file test/testMethodName.js which is
26+
* spawned and the output is compared.
27+
*
28+
*****************************************************************************/
29+
'use strict';
30+
31+
const oracledb = require('oracledb');
32+
const assert = require('assert');
33+
34+
describe('264. methodName.js', () => {
35+
36+
it('264.1 check for methodName getConnection', function() {
37+
assert.equal(oracledb.getConnection.name, 'bound getConnection');
38+
});
39+
40+
});

test/opts/.mocharc.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,5 @@ spec:
248248
- test/tpc.js
249249
- test/tpcResume.js
250250
- test/connHealthy.js
251-
- test/dbObjectOutBind.js
251+
- test/dbObjectOutBind.js
252+
- test/methodName.js

0 commit comments

Comments
 (0)