Skip to content

Commit 04af720

Browse files
committed
Added support for oracledb.edition
1 parent def6e90 commit 04af720

File tree

5 files changed

+71
-1
lines changed

5 files changed

+71
-1
lines changed

src/njsCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ class njsBaton {
251251
std::string newPassword;
252252
std::string connectString;
253253
std::string connClass;
254+
std::string edition;
254255
uint32_t poolMin;
255256
uint32_t poolMax;
256257
uint32_t poolIncrement;

src/njsOracle.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ njsOracledb::njsOracledb()
8282
poolTimeout = NJS_POOL_TIMEOUT;
8383
fetchArraySize = DPI_DEFAULT_FETCH_ARRAY_SIZE;
8484
connClass = "";
85+
edition = "";
8586
externalAuth = false;
8687
lobPrefetchSize = NJS_LOB_PREFETCH_SIZE;
8788
poolPingInterval = NJS_POOL_DEFAULT_PING_INTERVAL;
@@ -156,6 +157,9 @@ void njsOracledb::Init(Handle<Object> target)
156157
Nan::SetAccessor(temp->InstanceTemplate(),
157158
Nan::New<v8::String>("connectionClass").ToLocalChecked(),
158159
njsOracledb::GetConnectionClass, njsOracledb::SetConnectionClass);
160+
Nan::SetAccessor(temp->InstanceTemplate(),
161+
Nan::New<v8::String>("edition").ToLocalChecked(),
162+
njsOracledb::GetEdition, njsOracledb::SetEdition);
159163
Nan::SetAccessor(temp->InstanceTemplate(),
160164
Nan::New<v8::String>("externalAuth").ToLocalChecked(),
161165
njsOracledb::GetExternalAuth, njsOracledb::SetExternalAuth);
@@ -604,6 +608,32 @@ NAN_SETTER(njsOracledb::SetConnectionClass)
604608
"connectionClass");
605609
}
606610

611+
//-----------------------------------------------------------------------------
612+
// njsOracledb::GetEdition()
613+
// Get accessor of "edition" property.
614+
//-----------------------------------------------------------------------------
615+
NAN_GETTER(njsOracledb::GetEdition)
616+
{
617+
njsOracledb *oracledb = (njsOracledb*) ValidateGetter(info);
618+
if (!oracledb)
619+
return;
620+
Local<String> value =
621+
Nan::New<v8::String>(oracledb->edition).ToLocalChecked();
622+
info.GetReturnValue().Set(value);
623+
}
624+
625+
//-----------------------------------------------------------------------------
626+
// njsOracledb::SetEdition()
627+
// Set accessor of "edition" property.
628+
//-----------------------------------------------------------------------------
629+
NAN_SETTER(njsOracledb::SetEdition)
630+
{
631+
njsOracledb *oracledb = (njsOracledb*) ValidateSetter(info);
632+
if (oracledb)
633+
oracledb->SetPropString(value, &oracledb->edition,
634+
"edition");
635+
}
636+
607637

608638
//-----------------------------------------------------------------------------
609639
// njsOracledb::GetExternalAuth()
@@ -898,9 +928,11 @@ NAN_METHOD(njsOracledb::GetConnection)
898928
baton->connectString);
899929
baton->GetStringFromJSON(connProps, "newPassword", 0, baton->newPassword);
900930
baton->connClass = oracledb->connClass;
931+
baton->edition = oracledb->edition;
901932
baton->stmtCacheSize = oracledb->stmtCacheSize;
902933
baton->externalAuth = oracledb->externalAuth;
903934
baton->events = oracledb->events;
935+
baton->GetStringFromJSON(connProps, "edition", 0, baton->edition);
904936
baton->GetUnsignedIntFromJSON(connProps, "stmtCacheSize", 0,
905937
&baton->stmtCacheSize);
906938
baton->GetUnsignedIntFromJSON(connProps, "privilege", 0,
@@ -935,12 +967,18 @@ void njsOracledb::Async_GetConnection(njsBaton *baton)
935967
params.connectionClass = baton->connClass.c_str();
936968
params.connectionClassLength = baton->connClass.length();
937969
}
970+
938971
if(!baton->newPassword.empty()) {
939972
params.newPassword = baton->newPassword.c_str();
940973
params.newPasswordLength = baton->newPassword.length();
941974
}
942975
if (!InitCommonCreateParams(baton, &commonParams))
943976
return;
977+
if (!baton->edition.empty()) {
978+
commonParams.edition = baton->edition.c_str();
979+
commonParams.editionLength = baton->edition.length();
980+
}
981+
944982
if (dpiConn_create(globalDPIContext, baton->user.c_str(),
945983
(uint32_t) baton->user.length(), baton->password.c_str(),
946984
(uint32_t) baton->password.length(), baton->connectString.c_str(),
@@ -1001,6 +1039,7 @@ NAN_METHOD(njsOracledb::CreatePool)
10011039
baton->poolPingInterval = oracledb->poolPingInterval;
10021040
baton->stmtCacheSize = oracledb->stmtCacheSize;
10031041
baton->externalAuth = oracledb->externalAuth;
1042+
baton->edition = oracledb->edition;
10041043
baton->events = oracledb->events;
10051044
baton->GetUnsignedIntFromJSON(poolProps, "poolMax", 0, &baton->poolMax);
10061045
baton->GetUnsignedIntFromJSON(poolProps, "poolMin", 0, &baton->poolMin);
@@ -1014,6 +1053,7 @@ NAN_METHOD(njsOracledb::CreatePool)
10141053
&baton->poolPingInterval);
10151054
baton->GetBoolFromJSON(poolProps, "externalAuth", 0, &baton->externalAuth);
10161055
baton->GetBoolFromJSON(poolProps, "events", 0, &baton->events);
1056+
baton->GetStringFromJSON(poolProps, "edition", 0, baton->edition);
10171057
baton->lobPrefetchSize = oracledb->lobPrefetchSize;
10181058
baton->jsOracledb.Reset(info.Holder());
10191059

@@ -1044,6 +1084,10 @@ void njsOracledb::Async_CreatePool(njsBaton *baton)
10441084
params.pingInterval = baton->poolPingInterval;
10451085
if (!InitCommonCreateParams(baton, &commonParams))
10461086
return;
1087+
if (!baton->edition.empty()) {
1088+
commonParams.edition = baton->edition.c_str();
1089+
commonParams.editionLength = baton->edition.length();
1090+
}
10471091
if (dpiPool_create(globalDPIContext, baton->user.c_str(),
10481092
(uint32_t) baton->user.length(), baton->password.c_str(),
10491093
(uint32_t) baton->password.length(), baton->connectString.c_str(),

src/njsOracle.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class njsOracledb: public njsCommon
159159
static NAN_GETTER(GetVersionString);
160160
static NAN_GETTER(GetVersionSuffix);
161161
static NAN_GETTER(GetConnectionClass);
162+
static NAN_GETTER(GetEdition);
162163
static NAN_GETTER(GetExternalAuth);
163164
static NAN_GETTER(GetFetchArraySize);
164165
static NAN_GETTER(GetFetchAsString);
@@ -183,6 +184,7 @@ class njsOracledb: public njsCommon
183184
static NAN_SETTER(SetVersionString);
184185
static NAN_SETTER(SetVersionSuffix);
185186
static NAN_SETTER(SetConnectionClass);
187+
static NAN_SETTER(SetEdition);
186188
static NAN_SETTER(SetExternalAuth);
187189
static NAN_SETTER(SetFetchArraySize);
188190
static NAN_SETTER(SetFetchAsString);
@@ -213,6 +215,7 @@ class njsOracledb: public njsCommon
213215
uint32_t poolTimeout;
214216

215217
std::string connClass;
218+
std::string edition;
216219
bool externalAuth;
217220
Nan::Persistent<Array> jsFetchAsStringTypes;
218221
Nan::Persistent<Array> jsFetchAsBufferTypes;

test/list.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ Overview of node-oracledb functional tests
928928
58.1.24 versionString (read-only)
929929
58.1.25 versionSuffix (read-only)
930930
58.1.26 oracleClientVersionString (read-only)
931+
58.1.27 edition
932+
58.1.28 Negative - edition
931933
58.2 Pool Class
932934
58.2.1 poolMin
933935
58.2.2 poolMax
@@ -4082,4 +4084,4 @@ Overview of node-oracledb functional tests
40824084
159. end2endTracing.js
40834085
159.1 set the end-to-end tracing attribute - module
40844086
159.2 set the tracing attribute - action
4085-
159.3 set the tracing attribure - clientId
4087+
159.3 set the tracing attribure - clientId

test/properties.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('58. properties.js', function() {
5858
defaultValues.stmtCacheSize = oracledb.stmtCacheSize;
5959
defaultValues.poolPingInterval = oracledb.poolPingInterval;
6060
defaultValues.fetchAsBuffer = oracledb.fetchAsBuffer;
61+
defaultValues.edition = oracledb.edition;
6162
});
6263

6364
after('restore the values', function() {
@@ -78,6 +79,7 @@ describe('58. properties.js', function() {
7879
oracledb.stmtCacheSize = defaultValues.stmtCacheSize;
7980
oracledb.poolPingInterval = defaultValues.poolPingInterval;
8081
oracledb.fetchAsBuffer = defaultValues.fetchAsBuffer;
82+
oracledb.edition = defaultValues.edition;
8183
});
8284

8385
it('58.1.1 poolMin', function() {
@@ -314,6 +316,24 @@ describe('58. properties.js', function() {
314316
);
315317
});
316318

319+
it('58.1.27 edition', function() {
320+
var t = oracledb.edition;
321+
oracledb.edition = 'foobar';
322+
var e = oracledb.edition;
323+
324+
should.equal(t, '');
325+
should.strictEqual(e, 'foobar');
326+
});
327+
328+
it('58.1.28 Negative - edition', function() {
329+
should.throws(
330+
function() {
331+
oracledb.edition = 123;
332+
},
333+
/NJS-004: invalid value for property edition/
334+
);
335+
});
336+
317337
}); // 58.1
318338

319339
describe('58.2 Pool Class', function() {

0 commit comments

Comments
 (0)