Skip to content

Commit 586e71c

Browse files
committed
populate isOson metadata
1 parent c71f5d5 commit 586e71c

File tree

8 files changed

+55
-1
lines changed

8 files changed

+55
-1
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ node-oracledb `v6.4.0 <https://github.com/oracle/node-oracledb/compare/v6.3.0...
1313
Common Changes
1414
++++++++++++++
1515

16+
#) Added new extended :ref:`metadata <execmetadata>` information attribute
17+
``isOson`` for a fetched column.
18+
1619
#) Added :attr:`oracledb.poolPingTimeout` and :attr:`pool.poolPingTimeout`
1720
to limit the :meth:`connection.ping()` call time.
1821
`Issue #1626 <https://github.com/oracle/node-oracledb/issues/1626>`__.

lib/thin/protocol/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ module.exports = {
680680

681681
// UDS flags
682682
TNS_UDS_FLAGS_IS_JSON: 0x00000100,
683+
TNS_UDS_FLAGS_IS_OSON: 0x00000800,
683684

684685
// other constants
685686
TNS_MAX_SHORT_LENGTH: 252,

lib/thin/protocol/messages/withData.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ class MessageWithData extends Message {
223223
nullable: nullable
224224
};
225225
fetchInfo.isJson = Boolean(udsFlags & constants.TNS_UDS_FLAGS_IS_JSON);
226+
fetchInfo.isOson = Boolean(udsFlags & constants.TNS_UDS_FLAGS_IS_OSON);
226227
if (buf.caps.ttcFieldVersion >= constants.TNS_CCAP_FIELD_VERSION_23_1) {
227228
numBytes = buf.readUB4();
228229
if (numBytes > 0) {

src/njsModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ struct njsBaton {
428428
bool sodaMetadataCache;
429429
bool keepInStmtCache;
430430
bool isJson;
431+
bool isOson;
431432

432433
// LOB buffer (requires free only if string was used)
433434
uint64_t bufferSize;
@@ -640,6 +641,7 @@ struct njsVariable {
640641
bool isArray;
641642
bool isNullable;
642643
bool isJson;
644+
bool isOson;
643645
const char *domainSchema;
644646
size_t domainSchemaLength;
645647
const char *domainName;

src/njsVariable.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ bool njsVariable_getMetadataOne(njsVariable *var, napi_env env,
275275
NJS_CHECK_NAPI(env, napi_set_named_property(env, *metadata, "isJson",
276276
temp))
277277

278+
// store isOson
279+
NJS_CHECK_NAPI(env, napi_get_boolean(env, var->isOson, &temp))
280+
NJS_CHECK_NAPI(env, napi_set_named_property(env, *metadata, "isOson",
281+
temp))
282+
278283
// store domainSchema
279284
if (var->domainSchemaLength) {
280285
NJS_CHECK_NAPI(env, napi_create_string_utf8(env, var->domainSchema,
@@ -486,6 +491,7 @@ bool njsVariable_initForQuery(njsVariable *vars, uint32_t numVars,
486491
if (queryInfo.typeInfo.objectType)
487492
vars[i].dpiObjectTypeHandle = queryInfo.typeInfo.objectType;
488493
vars[i].isJson = queryInfo.typeInfo.isJson;
494+
vars[i].isOson = queryInfo.typeInfo.isOson;
489495
if (queryInfo.typeInfo.domainSchemaLength) {
490496
vars[i].domainSchemaLength = queryInfo.typeInfo.domainSchemaLength;
491497
vars[i].domainSchema = queryInfo.typeInfo.domainSchema;

test/dataTypeBlob.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const fs = require('fs');
4141
const assert = require('assert');
4242
const dbConfig = require('./dbconfig.js');
4343
const assist = require('./dataTypeAssist.js');
44+
const testsUtil = require(`./testsUtil.js`);
4445

4546
const inFileName = 'test/fuzzydinosaur.jpg'; // contains the image to be inserted
4647
const outFileName = 'test/blobstreamout.jpg';
@@ -153,4 +154,42 @@ describe('41. dataTypeBlob.js', function() {
153154
});
154155
});
155156

157+
describe('41.3 OSON column metadata ', function() {
158+
let isRunnable = false;
159+
const TABLE = "nodb_myblobs_oson_col";
160+
const createTable = (`CREATE TABLE ${TABLE} (
161+
IntCol number(9) not null,
162+
OsonCol blob not null,
163+
blobCol blob not null,
164+
constraint TestOsonCols_ck_1 check (OsonCol is json format oson)
165+
)`
166+
);
167+
const plsql = testsUtil.sqlCreateTable(TABLE, createTable);
168+
169+
before('create table', async function() {
170+
if (testsUtil.getClientVersion() >= 2100000000 &&
171+
connection.oracleServerVersion >= 2100000000) {
172+
isRunnable = true;
173+
}
174+
175+
if (!isRunnable) {
176+
this.skip();
177+
}
178+
179+
await connection.execute(plsql);
180+
});
181+
182+
after(async function() {
183+
await connection.execute(testsUtil.sqlDropTable(TABLE));
184+
});
185+
186+
it('41.3.1 Verify isOson flag in column metadata', async function() {
187+
const result = await connection.execute(`select * from ${TABLE}`);
188+
assert.strictEqual(result.metaData[0].isOson, false);
189+
assert.strictEqual(result.metaData[1].isOson, true);
190+
assert.strictEqual(result.metaData[2].isOson, false);
191+
}); // 41.3.1
192+
193+
}); //41.3
194+
156195
});

test/list.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ Overview of node-oracledb functional tests
654654
41.1.2 BLOB getData()
655655
41.2 stores null value correctly
656656
41.2.1 testing Null, Empty string and Undefined
657+
41.3 OSON column metadata
658+
41.3.1 Verify isOson flag in column metadata
657659

658660
42. dataTypeRaw.js
659661
42.1 testing RAW data in various lengths

0 commit comments

Comments
 (0)