Skip to content

Commit a9c6749

Browse files
committed
Changed Connection write-only attributes to allow console.log()
1 parent 9be4fae commit a9c6749

File tree

6 files changed

+52
-28
lines changed

6 files changed

+52
-28
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## node-oracledb v1.2.0 (DD Mon YYYY)
44

5+
- Changed write-only attributes to allow console.log() on Connection objects. Note the attribute values will show as null; refer to the documentation.
6+
57
- Remove non-portable memory allocation for queries that return NULL.
68

79
- Added check to make sure maxRows is greater than zero for non-ResultSet queries.

doc/api.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,11 @@ writeonly String action
955955
```
956956

957957
The [action](https://docs.oracle.com/database/121/LNOCI/oci08sca.htm#sthref1434)
958-
attribute for end-to-end application tracing. This is a write-only property.
958+
attribute for end-to-end application tracing.
959959

960-
See [End-to-end Tracing, Mid-tier Authentication, and Auditing](#endtoend).
960+
This is a write-only property. Displaying a Connection object will
961+
show a value of `null` for this attribute. See
962+
[End-to-end Tracing, Mid-tier Authentication, and Auditing](#endtoend).
961963

962964
#### <a name="propconnclientid"></a> 4.1.2 clientId
963965

@@ -969,9 +971,10 @@ The [client
969971
identifier](https://docs.oracle.com/database/121/LNOCI/oci08sca.htm#sthref1414)
970972
for end-to-end application tracing, use with mid-tier authentication,
971973
and with [Virtual Private Databases](http://docs.oracle.com/database/121/CNCPT/cmntopc.htm#CNCPT62345).
972-
This is a write-only property.
973974

974-
See [End-to-end Tracing, Mid-tier Authentication, and Auditing](#endtoend).
975+
This is a write-only property. Displaying a Connection object will
976+
show a value of `null` for this attribute. See
977+
[End-to-end Tracing, Mid-tier Authentication, and Auditing](#endtoend).
975978

976979
#### <a name="propconnmodule"></a> 4.1.3 module
977980

@@ -980,9 +983,11 @@ writeonly String module
980983
```
981984

982985
The [module](https://docs.oracle.com/database/121/LNOCI/oci08sca.htm#sthref1433)
983-
attribute for end-to-end application tracing. This is a write-only property.
986+
attribute for end-to-end application tracing.
984987

985-
See [End-to-end Tracing, Mid-tier Authentication, and Auditing](#endtoend).
988+
This is a write-only property. Displaying a Connection object will
989+
show a value of `null` for this attribute. See
990+
[End-to-end Tracing, Mid-tier Authentication, and Auditing](#endtoend).
986991

987992
#### <a name="propconnstmtcachesize"></a> 4.1.4 stmtCacheSize
988993

@@ -3303,7 +3308,7 @@ own mid-tier authentication but connect to the database using the one
33033308
database schema. By setting `clientId` to the application's
33043309
authenticated username, the database is aware of who the actual end
33053310
user is. This can, for example, be used by Oracle
3306-
[Virtual Private Databases](http://docs.oracle.com/database/121/CNCPT/cmntopc.htm#CNCPT62345)
3311+
[Virtual Private Database](http://docs.oracle.com/database/121/CNCPT/cmntopc.htm#CNCPT62345)
33073312
policies to automatically restrict data access by that user.
33083313
33093314
Applications should set the properties because they can greatly help
@@ -3349,14 +3354,33 @@ The values can also be manually set by calling
33493354
[`DBMS_APPLICATION_INFO`](http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_appinf.htm#CHECEIEB)
33503355
procedures or
33513356
[`DBMS_SESSION.SET_IDENTIFIER`](http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_sessio.htm#SET_IDENTIFIER),
3352-
however these require explicit round-trips, reducing scalability.
3357+
however these cause explicit round-trips, reducing scalability.
3358+
3359+
In general, applications should be consistent about how, and when,
3360+
they set the end-to-end tracing attributes so that current values are
3361+
recorded by the database.
33533362
33543363
Idle connections released back to a connection pool will retain the
3355-
previous attribute values of that connection. This avoids the
3356-
overhead of a round-trip to reset the values. After calling
3357-
`pool.getConnection()`, the application should be consistent about
3358-
setting appropriate values to ensure any previous values are updated.
3359-
The Oracle design assumption is that pools are actively used and have
3360-
few idle connections. However, if desired, the application can set
3361-
the properties to empty strings and force a round-trip prior to
3362-
connection release. This reduces efficiency.
3364+
previous attribute values of that connection. This avoids the overhead
3365+
of a round-trip to reset the values. The Oracle design assumption is
3366+
that pools are actively used and have few idle connections. After
3367+
getting a connection from a pool, an application that uses end-to-end
3368+
tracing should set new values appropriately.
3369+
3370+
When a Connection object is displayed, such as with `console.log()`,
3371+
the end-to-end tracing attributes will show as `null` even if values
3372+
have been set and are being sent to the database. This is for
3373+
architectural, efficiency and consistency reasons. When an already
3374+
established connection is retrieved from a local pool, node-oracledb
3375+
is not able to efficiently retrieve values previously established in
3376+
the connection. The same occurs if the values are set by a call to
3377+
PL/SQL code - there is no efficient way for node-oracledb to know the
3378+
values have changed.
3379+
3380+
The attribute values are commonly useful to DBAs. However, if knowing
3381+
the current values is useful in an application, the application should
3382+
save the values as part of its application state whenever the
3383+
node-oracledb attributes are set. Applications can also find the
3384+
current values by querying the Oracle data dictionary or using PL/SQL
3385+
procedures such as `DBMS_APPLICATION_INFO.READ_MODULE()` with the
3386+
understanding that these require round-trips to the database.

src/njs/src/njsConnection.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ NAN_SETTER(Connection::SetStmtCacheSize)
225225
/*****************************************************************************/
226226
/*
227227
DESCRIPTION
228-
Get Accessor of clientId property - throws error
228+
Get Accessor of clientId property - This is write-only property,
229+
returning NULL for debugging purpose in case of read
229230
*/
230231
NAN_PROPERTY_GETTER(Connection::GetClientId)
231232
{
232-
connectionPropertyException(ObjectWrap::Unwrap<Connection>(args.Holder()), errWriteOnly, "clientId");
233-
NanReturnUndefined();
233+
NanReturnNull();
234234
}
235235

236236
/*****************************************************************************/
@@ -259,12 +259,12 @@ NAN_SETTER(Connection::SetClientId)
259259
/*****************************************************************************/
260260
/*
261261
DESCRIPTION
262-
Get Accessor of module property - throws error
262+
Get Accessor of module property - This is write-only property,
263+
returning NULL for debugging purpose in case of read
263264
*/
264265
NAN_PROPERTY_GETTER(Connection::GetModule)
265266
{
266-
connectionPropertyException(ObjectWrap::Unwrap<Connection>(args.Holder()), errWriteOnly, "module");
267-
NanReturnUndefined();
267+
NanReturnNull();
268268
}
269269

270270
/*****************************************************************************/
@@ -293,12 +293,12 @@ NAN_SETTER(Connection::SetModule)
293293
/*****************************************************************************/
294294
/*
295295
DESCRIPTION
296-
Get Accessor of action property - throws error
296+
Get Accessor of action property - This is write-only property,
297+
returning NULL for debugging purpose in case of read
297298
*/
298299
NAN_PROPERTY_GETTER(Connection::GetAction)
299300
{
300-
connectionPropertyException(ObjectWrap::Unwrap<Connection>(args.Holder()), errWriteOnly, "action");
301-
NanReturnUndefined();
301+
NanReturnNull();
302302
}
303303

304304
/*****************************************************************************/

src/njs/src/njsMessages.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ static const char *errMsg[] =
4949
"NJS-012: encountered invalid bind datatype in parameter %d",
5050
"NJS-013: invalid bind direction",
5151
"NJS-014: %s is a read-only property",
52-
"NJS-015: %s is a write-only property",
5352
"NJS-016: buffer is too small for OUT binds",
5453
"NJS-017: concurrent operations on resultSet are not allowed",
5554
"NJS-018: invalid result set",

src/njs/src/njsMessages.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ typedef enum
4848
errInvalidBindDataType,
4949
errInvalidBindDirection,
5050
errReadOnly,
51-
errWriteOnly,
5251
errInsufficientBufferForBinds,
5352
errBusyResultSet,
5453
errInvalidResultSet,

test/dmlReturning.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ describe('6. dmlReturning.js', function(){
334334
{ autoCommit: true },
335335
function(err, result) {
336336
should.not.exist(err);
337-
console.log(result);
337+
// console.log(result);
338338
result.outBinds.rid.should.eql([size]);
339339
result.outBinds.rname[0].length.should.be.exactly(size);
340340
done();

0 commit comments

Comments
 (0)