Skip to content

Commit 7c44fb5

Browse files
committed
Fixed regression with getStatementInfo() metadata
1 parent c2b7572 commit 7c44fb5

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
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 v4.0.1 (DD MON YYYY)
44

5+
- Fixed a regression with missing `metaData` from `connection.getStatementInfo()`
6+
57
- Fixed passing DbObjects and JavaScript objects as the `payload` attribute for
68
AQ message enqueues when using an object queue.
79

src/njsConnection.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,12 +1759,24 @@ static bool njsConnection_getStatementInfoAsync(njsBaton *baton)
17591759
static bool njsConnection_getStatementInfoPostAsync(njsBaton *baton,
17601760
napi_env env, napi_value *args)
17611761
{
1762-
napi_value result, bindNames, temp;
1762+
napi_value result, bindNames, metadata, temp;
17631763
uint32_t i;
17641764

17651765
// create object for the result
17661766
NJS_CHECK_NAPI(env, napi_create_object(env, &result))
17671767

1768+
// add metadata (queries only)
1769+
if (baton->queryVars) {
1770+
if (!njsVariable_initForQueryJS(baton->queryVars, baton->numQueryVars,
1771+
env, baton))
1772+
return false;
1773+
if (!njsVariable_getMetadataMany(baton->queryVars, baton->numQueryVars,
1774+
env, baton->extendedMetaData, &metadata))
1775+
return false;
1776+
NJS_CHECK_NAPI(env, napi_set_named_property(env, result, "metaData",
1777+
metadata))
1778+
}
1779+
17681780
// add array for the bind names
17691781
NJS_CHECK_NAPI(env, napi_create_array_with_length(env, baton->numBindNames,
17701782
&bindNames))

test/getStmtInfo.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,20 @@ describe('162. getStmtInfo.js', function() {
8585
sql,
8686
function(err, info) {
8787
should.not.exist(err);
88-
should.exist(info);
89-
should.deepEqual(info.bindNames, []);
90-
should.strictEqual(info.statementType, oracledb.STMT_TYPE_SELECT);
88+
should.deepEqual(info,
89+
{ bindNames: [], statementType: oracledb.STMT_TYPE_SELECT,
90+
metaData: [
91+
{
92+
dbType: oracledb.DB_TYPE_NUMBER,
93+
dbTypeName: "NUMBER",
94+
fetchType: oracledb.DB_TYPE_NUMBER,
95+
name: "COL",
96+
nullable: true,
97+
precision: 0,
98+
scale: -127
99+
}
100+
]
101+
});
91102
done();
92103
}
93104
);
@@ -517,4 +528,4 @@ describe('162. getStmtInfo.js', function() {
517528
);
518529
});
519530

520-
});
531+
});

0 commit comments

Comments
 (0)