Skip to content

Commit

Permalink
Add package name attribute to DbObject class
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadraju committed Sep 22, 2023
1 parent 8705db5 commit 6602843
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Thin Mode Changes
Thick Mode Changes
++++++++++++++++++

#) Added ``packageName`` attribute to :ref:`DbObject Class<dbobjectclass>`.

#) Added new property :ref:`binaryDir <odbinitoracleclientattrsopts>` to the
options passed to :meth:`~oracledb.initOracleClient()` which indicates the
name of the directory that contains the node-oracledb :ref:`Thick mode
Expand Down
9 changes: 9 additions & 0 deletions lib/dbObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ class BaseDbObject {
return this._objType.schema;
}

//---------------------------------------------------------------------------
// packageName
//
// Property for the packageName of the database object type.
//---------------------------------------------------------------------------
get packageName() {
return this._objType.packageName;
}

//---------------------------------------------------------------------------
// setElement()
//
Expand Down
6 changes: 4 additions & 2 deletions src/njsDbObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ NJS_NAPI_METHOD_IMPL_SYNC(njsDbObject_getPrevIndex, 1, &njsClassDefDbObject)
bool njsDbObject_getSubClass(njsBaton *baton, dpiObjectType *objectTypeHandle,
napi_env env, napi_value *cls, njsDbObjectType **objectType)
{
napi_value fn, args[2], callingObj;
napi_value fn, args[3], callingObj;
njsDbObjectType *tempObjectType;
dpiObjectTypeInfo info;

Expand All @@ -406,11 +406,13 @@ bool njsDbObject_getSubClass(njsBaton *baton, dpiObjectType *objectTypeHandle,
info.schemaLength, &args[0]))
NJS_CHECK_NAPI(env, napi_create_string_utf8(env, info.name,
info.nameLength, &args[1]))
NJS_CHECK_NAPI(env, napi_create_string_utf8(env, info.packageName,
info.packageNameLength, &args[2]))
NJS_CHECK_NAPI(env, napi_get_reference_value(env, baton->jsCallingObjRef,
&callingObj))
NJS_CHECK_NAPI(env, napi_get_named_property(env, callingObj,
"_getDbObjectType", &fn))
NJS_CHECK_NAPI(env, napi_call_function(env, callingObj, fn, 2, args, cls))
NJS_CHECK_NAPI(env, napi_call_function(env, callingObj, fn, 3, args, cls))

// if it has already been wrapped, it has been fully populated and there is
// no need to do anything further
Expand Down
4 changes: 4 additions & 0 deletions test/dbObject12.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ describe('211. dbObject12.js', function() {

// Using the constructor to create an object
const obj1 = new RecTypeClass({ NAME: 'Ship', POS: 12 });
assert.strictEqual(obj1.packageName, PKG);

let binds = {
inbv: obj1,
outbv: { type: RecTypeClass, dir: oracledb.BIND_OUT }
};
const result1 = await conn.execute(CALL, binds);
let out = result1.outBinds.outbv;
const expect = `[object ${dbConfig.user.toUpperCase()}.${PKG}.${TYPE}]`;
assert.strictEqual(out.toString(), expect);
assert.strictEqual(out.NAME, obj1.NAME);
assert.strictEqual(out.POS, (obj1.POS * 2));

Expand Down

0 comments on commit 6602843

Please sign in to comment.