Skip to content

Commit 6602843

Browse files
committed
Add package name attribute to DbObject class
1 parent 8705db5 commit 6602843

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Thin Mode Changes
3131
Thick Mode Changes
3232
++++++++++++++++++
3333

34+
#) Added ``packageName`` attribute to :ref:`DbObject Class<dbobjectclass>`.
35+
3436
#) Added new property :ref:`binaryDir <odbinitoracleclientattrsopts>` to the
3537
options passed to :meth:`~oracledb.initOracleClient()` which indicates the
3638
name of the directory that contains the node-oracledb :ref:`Thick mode

lib/dbObject.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,15 @@ class BaseDbObject {
319319
return this._objType.schema;
320320
}
321321

322+
//---------------------------------------------------------------------------
323+
// packageName
324+
//
325+
// Property for the packageName of the database object type.
326+
//---------------------------------------------------------------------------
327+
get packageName() {
328+
return this._objType.packageName;
329+
}
330+
322331
//---------------------------------------------------------------------------
323332
// setElement()
324333
//

src/njsDbObject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ NJS_NAPI_METHOD_IMPL_SYNC(njsDbObject_getPrevIndex, 1, &njsClassDefDbObject)
393393
bool njsDbObject_getSubClass(njsBaton *baton, dpiObjectType *objectTypeHandle,
394394
napi_env env, napi_value *cls, njsDbObjectType **objectType)
395395
{
396-
napi_value fn, args[2], callingObj;
396+
napi_value fn, args[3], callingObj;
397397
njsDbObjectType *tempObjectType;
398398
dpiObjectTypeInfo info;
399399

@@ -406,11 +406,13 @@ bool njsDbObject_getSubClass(njsBaton *baton, dpiObjectType *objectTypeHandle,
406406
info.schemaLength, &args[0]))
407407
NJS_CHECK_NAPI(env, napi_create_string_utf8(env, info.name,
408408
info.nameLength, &args[1]))
409+
NJS_CHECK_NAPI(env, napi_create_string_utf8(env, info.packageName,
410+
info.packageNameLength, &args[2]))
409411
NJS_CHECK_NAPI(env, napi_get_reference_value(env, baton->jsCallingObjRef,
410412
&callingObj))
411413
NJS_CHECK_NAPI(env, napi_get_named_property(env, callingObj,
412414
"_getDbObjectType", &fn))
413-
NJS_CHECK_NAPI(env, napi_call_function(env, callingObj, fn, 2, args, cls))
415+
NJS_CHECK_NAPI(env, napi_call_function(env, callingObj, fn, 3, args, cls))
414416

415417
// if it has already been wrapped, it has been fully populated and there is
416418
// no need to do anything further

test/dbObject12.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ describe('211. dbObject12.js', function() {
8989

9090
// Using the constructor to create an object
9191
const obj1 = new RecTypeClass({ NAME: 'Ship', POS: 12 });
92+
assert.strictEqual(obj1.packageName, PKG);
93+
9294
let binds = {
9395
inbv: obj1,
9496
outbv: { type: RecTypeClass, dir: oracledb.BIND_OUT }
9597
};
9698
const result1 = await conn.execute(CALL, binds);
9799
let out = result1.outBinds.outbv;
100+
const expect = `[object ${dbConfig.user.toUpperCase()}.${PKG}.${TYPE}]`;
101+
assert.strictEqual(out.toString(), expect);
98102
assert.strictEqual(out.NAME, obj1.NAME);
99103
assert.strictEqual(out.POS, (obj1.POS * 2));
100104

0 commit comments

Comments
 (0)