Improved Bind Support and test cases

This commit is contained in:
Sharad Chandran R 2023-05-23 22:46:59 +05:30
parent 4d7c311d2b
commit 2ae50488ef
4 changed files with 94 additions and 20 deletions

View File

@ -39,7 +39,7 @@ const thinUtil = require("./util.js");
// the dollar sign and the pound sign.
// 5. Non-quoted binds cannot be Oracle Database Reserved Names
// (Server handles this case and returns an appropriate error)
const BIND_PATTERN = /(?<=\:)\s*("[^\"]*"|([a-zA-Z]|[^\x20-\x7F])([\w\$#]|[^\x20-\x7F\$#])*|\d+)/g;
const BIND_PATTERN = /(?<=\:)\s*("[^\"]*"|(([a-zA-Z]|[^\u0020-\u007F\s])([\w\$#]|[^\u0020-\u007F\s\$#])*|\d+))/g;
// pattern used for detecting a DML returning clause; bind variables in the
// first group are input variables; bind variables in the second group are

View File

@ -232,8 +232,6 @@ describe('224. booleanBind.js', function() {
}); // 224.6
it('224.7 IN bind array with boolean data', async function() {
if (oracledb.thin)
this.skip();
const cls = await conn.getDbObjectClass(`${pkgName}.UDT_BOOLEANLIST`);
const arr = new cls([true, false, true, true, false, true, false, true]);
const binds = {
@ -246,8 +244,6 @@ describe('224. booleanBind.js', function() {
}); // 224.7
it('224.8 OUT bind array with boolean data', async function() {
if (oracledb.thin)
this.skip();
const cls = await conn.getDbObjectClass(`${pkgName}.UDT_BOOLEANLIST`);
const arr = new cls([true, false, true, true, false, true, false, true]);
const binds = {
@ -260,8 +256,6 @@ describe('224. booleanBind.js', function() {
}); // 224.8
it('224.9 INOUT bind record with boolean data', async function() {
if (oracledb.thin)
this.skip();
const cls = await conn.getDbObjectClass(`${pkgName}.UDT_DEMORECORD`);
const obj = new cls();
obj.NUMBERVALUE = 6;

View File

@ -289,5 +289,85 @@ describe('162. getStmtInfo.js', function() {
let info = await conn.getStatementInfo(sql);
assert.deepStrictEqual(info.bindNames, [element]);
}));
}); // 162.2
}); // 162.27
it('162.28 PL/SQL block bindname following newline character', async function() {
const sql = `
-- COMMENTS
select :object_name_in as object_name,
'COMMENT' as object_type,
:schema_name_in as schema_name
from dual
union all
-- REF CONSTRAINTS
select constraint_name,
'REF_CONSTRAINT',
owner
from all_constraints
where owner = :schema_name_in
and table_name = :object_name_in
and constraint_type = 'R'
union all
-- RLS CONTEXTS
select :object_name_in as object_name,
'RLS_CONTEXT' as object_type,
:schema_name_in as schema_name
from dual
union all
-- RLS GROUP
select :object_name_in as object_name,
'RLS_GROUP' as object_type,
:schema_name_in as schema_name
from dual
union all
-- RLS POLICY
select :object_name_in as object_name,
'RLS_POLICY' as object_type,
:schema_name_in as schema_name
from dual
union all
-- CONSTRAINTS
select constraint_name,
'CONSTRAINT',
owner
from all_constraints
where owner = :schema_name_in
and table_name = :object_name_in
and constraint_type != 'R'
union all
-- INDEXES
select index_name,
'INDEX',
owner
from all_indexes
where table_owner = :schema_name_in
and table_name = :object_name_in
union all
-- TRIGGERS
select trigger_name,
'TRIGGER',
owner
from all_triggers
where table_owner = :schema_name_in
and table_name = :object_name_in
and base_object_type = 'TABLE'
union all
-- OBJECTS GRANTS AS GRANTOR
select :object_name_in,
'OBJECT_GRANT_AS_GRANTOR',
:schema_name_in
from dual`;
const connection = await oracledb.getConnection(dbConfig);
const info = await connection.getStatementInfo(sql);
assert.deepStrictEqual(info.bindNames, ['OBJECT_NAME_IN', 'SCHEMA_NAME_IN']);
await connection.close();
}); // 162.28
});

View File

@ -483,7 +483,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class
{StudentClassId : scid,
class @link {ClassId: clsid, Name:name}
class {ClassId: clsid, Name:name}
}
}`;
await connection.execute(query);
@ -498,7 +498,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class @INSERT @UPDATE @DELETE
{StudentClassId : scid,
class @link @CHECK {ClassId: clsid, Name:name}
class @CHECK {ClassId: clsid, Name:name}
}
}`;
await connection.execute(query);
@ -513,7 +513,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class @INSERT @UPDATE @DELETE
{StudentClassId : scid,
@unnest class @link @CHECK {ClassId: clsid, Name:name}
@unnest class @CHECK {ClassId: clsid, Name:name}
}
}`;
await assert.rejects(
@ -572,7 +572,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class
{StudentClassId : scid,
class @link {ClassId: clsid, Names:name}
class {ClassId: clsid, Names:name}
}
}`;
@ -588,7 +588,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class
{StudentClassId : scid,
class @link {ClassId: clsid, Names:name}
class {ClassId: clsid, Names:name}
}
}`;
@ -607,7 +607,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class
{StudentClassId : scid,
class @link {ClassId: clsid, Names:name}
class {ClassId: clsid, Names:name}
}
}`;
@ -626,7 +626,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class
{StudentClassId : scid,
class @link {ClassId: clsid, Names:name}
class {ClassId: clsid, Names:name}
}
}`;
@ -642,7 +642,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class
{StudentClassId : scid,
class @link {ClassId: clsid, Names:name}
class {ClassId: clsid, Names:name}
}
}`;
@ -662,7 +662,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class @INSERT @UPDATE @DELETE
{StudentClassId : scid,
class @link {ClassId: clsid, Names:name}
class {ClassId: clsid, Names:name}
}
}`;
@ -681,7 +681,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName: name,
student_class @INSERT @UPDATE @DELETE
{StudentClassId : scid,
class @link {ClassId: clsid, Names:name}
class {ClassId: clsid, Names:name}
}
}`;
await assert.rejects(
@ -707,7 +707,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName:name,
student_class @INSERT @UPDATE @DELETE
{StudentClassId:scid,
class @link @CHECK {ClassId:clsid, Name:name}
class @CHECK {ClassId:clsid, Name:name}
}
}'
, dbms_sql.native);
@ -729,7 +729,7 @@ describe('272. jsonDualityView1.js', function() {
StudentName:name,
student_class @INSERT @UPDATE @DELETE
{StudentClassId:scid,
class @link @CHECK {ClassId:clsid, Name:name}
class @CHECK {ClassId:clsid, Name:name}
}
}';
END;`;