Skip to content

Commit 00a25dc

Browse files
committed
Allow an empty object for fetchInfo
1 parent 5ce0b10 commit 00a25dc

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

src/njsConnection.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,15 +1074,12 @@ bool njsConnection::ProcessOptions(Nan::NAN_METHOD_ARGS_TYPE args,
10741074
if (!val->IsUndefined() && !val->IsNull()) {
10751075
Local<Object> jsFetchInfo = val->ToObject();
10761076
Local<Array> keys = jsFetchInfo->GetOwnPropertyNames();
1077-
if (keys->Length() == 0) {
1078-
baton->error = njsMessages::Get(errEmptyArrayForFetchAs, index);
1079-
return false;
1080-
}
10811077
baton->numFetchInfo = keys->Length();
1082-
baton->fetchInfo = new njsFetchInfo[baton->numFetchInfo];
1078+
if (baton->numFetchInfo > 0)
1079+
baton->fetchInfo = new njsFetchInfo[baton->numFetchInfo];
10831080
for (uint32_t i = 0; i < baton->numFetchInfo; i++) {
1084-
Local<String> temp = Nan::Get (keys,
1085-
i).ToLocalChecked ().As<String>();
1081+
Local<String> temp =
1082+
Nan::Get(keys, i).ToLocalChecked().As<String>();
10861083

10871084
v8::String::Utf8Value utf8str(temp->ToString());
10881085
baton->fetchInfo[i].name = std::string(*utf8str,

src/njsMessages.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static const char *errMsg[] = {
5555
"NJS-017: concurrent operations on ResultSet are not allowed", // errBusyResultSet
5656
"NJS-018: invalid ResultSet", // errInvalidResultSet
5757
"NJS-019: ResultSet cannot be returned for non-query statements", // errInvalidNonQueryExecution
58-
"NJS-020: empty array was specified to fetch values as string", // errEmptyArrayForFetchAs
5958
"NJS-021: invalid type for conversion specified", // errInvalidTypeForConversion
6059
"NJS-022: invalid Lob", // errInvalidLob
6160
"NJS-023: concurrent operations on LOB are not allowed", // errBusyLob

src/njsMessages.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ typedef enum {
5858
errBusyResultSet,
5959
errInvalidResultSet,
6060
errInvalidNonQueryExecution,
61-
errEmptyArrayForFetchAs,
6261
errInvalidTypeForConversion,
6362
errInvalidLob,
6463
errBusyLob,

test/fetchAs.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,12 @@ describe('56. fetchAs.js', function() {
372372
"select sysdate as ts_date from dual",
373373
{ },
374374
{
375-
fetchInfo: { }
375+
fetchInfo: {}
376376
},
377377
function(err, result) {
378-
should.exist(err);
379-
should.strictEqual(
380-
err.message,
381-
'NJS-020: empty array was specified to fetch values as string'
382-
);
383-
should.not.exist(result);
378+
should.not.exist(err);
379+
should.exist(result);
380+
(result.rows[0][0]).should.be.a.Date();
384381
done();
385382
}
386383
);

0 commit comments

Comments
 (0)