Skip to content

Commit 2ae5048

Browse files
committed
Improved Bind Support and test cases
1 parent 4d7c311 commit 2ae5048

File tree

4 files changed

+94
-20
lines changed

4 files changed

+94
-20
lines changed

lib/thin/statement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const thinUtil = require("./util.js");
3939
// the dollar sign and the pound sign.
4040
// 5. Non-quoted binds cannot be Oracle Database Reserved Names
4141
// (Server handles this case and returns an appropriate error)
42-
const BIND_PATTERN = /(?<=\:)\s*("[^\"]*"|([a-zA-Z]|[^\x20-\x7F])([\w\$#]|[^\x20-\x7F\$#])*|\d+)/g;
42+
const BIND_PATTERN = /(?<=\:)\s*("[^\"]*"|(([a-zA-Z]|[^\u0020-\u007F\s])([\w\$#]|[^\u0020-\u007F\s\$#])*|\d+))/g;
4343

4444
// pattern used for detecting a DML returning clause; bind variables in the
4545
// first group are input variables; bind variables in the second group are

test/booleanBind.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ describe('224. booleanBind.js', function() {
232232
}); // 224.6
233233

234234
it('224.7 IN bind array with boolean data', async function() {
235-
if (oracledb.thin)
236-
this.skip();
237235
const cls = await conn.getDbObjectClass(`${pkgName}.UDT_BOOLEANLIST`);
238236
const arr = new cls([true, false, true, true, false, true, false, true]);
239237
const binds = {
@@ -246,8 +244,6 @@ describe('224. booleanBind.js', function() {
246244
}); // 224.7
247245

248246
it('224.8 OUT bind array with boolean data', async function() {
249-
if (oracledb.thin)
250-
this.skip();
251247
const cls = await conn.getDbObjectClass(`${pkgName}.UDT_BOOLEANLIST`);
252248
const arr = new cls([true, false, true, true, false, true, false, true]);
253249
const binds = {
@@ -260,8 +256,6 @@ describe('224. booleanBind.js', function() {
260256
}); // 224.8
261257

262258
it('224.9 INOUT bind record with boolean data', async function() {
263-
if (oracledb.thin)
264-
this.skip();
265259
const cls = await conn.getDbObjectClass(`${pkgName}.UDT_DEMORECORD`);
266260
const obj = new cls();
267261
obj.NUMBERVALUE = 6;

test/getStmtInfo.js

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,85 @@ describe('162. getStmtInfo.js', function() {
289289
let info = await conn.getStatementInfo(sql);
290290
assert.deepStrictEqual(info.bindNames, [element]);
291291
}));
292-
}); // 162.2
292+
}); // 162.27
293+
294+
it('162.28 PL/SQL block bindname following newline character', async function() {
295+
const sql = `
296+
-- COMMENTS
297+
select :object_name_in as object_name,
298+
'COMMENT' as object_type,
299+
:schema_name_in as schema_name
300+
from dual
301+
union all
302+
303+
-- REF CONSTRAINTS
304+
select constraint_name,
305+
'REF_CONSTRAINT',
306+
owner
307+
from all_constraints
308+
where owner = :schema_name_in
309+
and table_name = :object_name_in
310+
and constraint_type = 'R'
311+
union all
312+
313+
-- RLS CONTEXTS
314+
select :object_name_in as object_name,
315+
'RLS_CONTEXT' as object_type,
316+
:schema_name_in as schema_name
317+
from dual
318+
union all
319+
320+
-- RLS GROUP
321+
select :object_name_in as object_name,
322+
'RLS_GROUP' as object_type,
323+
:schema_name_in as schema_name
324+
from dual
325+
union all
326+
327+
-- RLS POLICY
328+
select :object_name_in as object_name,
329+
'RLS_POLICY' as object_type,
330+
:schema_name_in as schema_name
331+
from dual
332+
union all
333+
334+
-- CONSTRAINTS
335+
select constraint_name,
336+
'CONSTRAINT',
337+
owner
338+
from all_constraints
339+
where owner = :schema_name_in
340+
and table_name = :object_name_in
341+
and constraint_type != 'R'
342+
union all
343+
344+
-- INDEXES
345+
select index_name,
346+
'INDEX',
347+
owner
348+
from all_indexes
349+
where table_owner = :schema_name_in
350+
and table_name = :object_name_in
351+
union all
352+
353+
-- TRIGGERS
354+
select trigger_name,
355+
'TRIGGER',
356+
owner
357+
from all_triggers
358+
where table_owner = :schema_name_in
359+
and table_name = :object_name_in
360+
and base_object_type = 'TABLE'
361+
union all
362+
363+
-- OBJECTS GRANTS AS GRANTOR
364+
select :object_name_in,
365+
'OBJECT_GRANT_AS_GRANTOR',
366+
:schema_name_in
367+
from dual`;
368+
const connection = await oracledb.getConnection(dbConfig);
369+
const info = await connection.getStatementInfo(sql);
370+
assert.deepStrictEqual(info.bindNames, ['OBJECT_NAME_IN', 'SCHEMA_NAME_IN']);
371+
await connection.close();
372+
}); // 162.28
293373
});

test/jsonDualityViews1.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ describe('272. jsonDualityView1.js', function() {
483483
StudentName: name,
484484
student_class
485485
{StudentClassId : scid,
486-
class @link {ClassId: clsid, Name:name}
486+
class {ClassId: clsid, Name:name}
487487
}
488488
}`;
489489
await connection.execute(query);
@@ -498,7 +498,7 @@ describe('272. jsonDualityView1.js', function() {
498498
StudentName: name,
499499
student_class @INSERT @UPDATE @DELETE
500500
{StudentClassId : scid,
501-
class @link @CHECK {ClassId: clsid, Name:name}
501+
class @CHECK {ClassId: clsid, Name:name}
502502
}
503503
}`;
504504
await connection.execute(query);
@@ -513,7 +513,7 @@ describe('272. jsonDualityView1.js', function() {
513513
StudentName: name,
514514
student_class @INSERT @UPDATE @DELETE
515515
{StudentClassId : scid,
516-
@unnest class @link @CHECK {ClassId: clsid, Name:name}
516+
@unnest class @CHECK {ClassId: clsid, Name:name}
517517
}
518518
}`;
519519
await assert.rejects(
@@ -572,7 +572,7 @@ describe('272. jsonDualityView1.js', function() {
572572
StudentName: name,
573573
student_class
574574
{StudentClassId : scid,
575-
class @link {ClassId: clsid, Names:name}
575+
class {ClassId: clsid, Names:name}
576576
}
577577
}`;
578578

@@ -588,7 +588,7 @@ describe('272. jsonDualityView1.js', function() {
588588
StudentName: name,
589589
student_class
590590
{StudentClassId : scid,
591-
class @link {ClassId: clsid, Names:name}
591+
class {ClassId: clsid, Names:name}
592592
}
593593
}`;
594594

@@ -607,7 +607,7 @@ describe('272. jsonDualityView1.js', function() {
607607
StudentName: name,
608608
student_class
609609
{StudentClassId : scid,
610-
class @link {ClassId: clsid, Names:name}
610+
class {ClassId: clsid, Names:name}
611611
}
612612
}`;
613613

@@ -626,7 +626,7 @@ describe('272. jsonDualityView1.js', function() {
626626
StudentName: name,
627627
student_class
628628
{StudentClassId : scid,
629-
class @link {ClassId: clsid, Names:name}
629+
class {ClassId: clsid, Names:name}
630630
}
631631
}`;
632632

@@ -642,7 +642,7 @@ describe('272. jsonDualityView1.js', function() {
642642
StudentName: name,
643643
student_class
644644
{StudentClassId : scid,
645-
class @link {ClassId: clsid, Names:name}
645+
class {ClassId: clsid, Names:name}
646646
}
647647
}`;
648648

@@ -662,7 +662,7 @@ describe('272. jsonDualityView1.js', function() {
662662
StudentName: name,
663663
student_class @INSERT @UPDATE @DELETE
664664
{StudentClassId : scid,
665-
class @link {ClassId: clsid, Names:name}
665+
class {ClassId: clsid, Names:name}
666666
}
667667
}`;
668668

@@ -681,7 +681,7 @@ describe('272. jsonDualityView1.js', function() {
681681
StudentName: name,
682682
student_class @INSERT @UPDATE @DELETE
683683
{StudentClassId : scid,
684-
class @link {ClassId: clsid, Names:name}
684+
class {ClassId: clsid, Names:name}
685685
}
686686
}`;
687687
await assert.rejects(
@@ -707,7 +707,7 @@ describe('272. jsonDualityView1.js', function() {
707707
StudentName:name,
708708
student_class @INSERT @UPDATE @DELETE
709709
{StudentClassId:scid,
710-
class @link @CHECK {ClassId:clsid, Name:name}
710+
class @CHECK {ClassId:clsid, Name:name}
711711
}
712712
}'
713713
, dbms_sql.native);
@@ -729,7 +729,7 @@ describe('272. jsonDualityView1.js', function() {
729729
StudentName:name,
730730
student_class @INSERT @UPDATE @DELETE
731731
{StudentClassId:scid,
732-
class @link @CHECK {ClassId:clsid, Name:name}
732+
class @CHECK {ClassId:clsid, Name:name}
733733
}
734734
}';
735735
END;`;

0 commit comments

Comments
 (0)