Skip to content

Commit 89952c5

Browse files
bugfix
Re Neil: /insert ignored when table is prefixed
1 parent 0138981 commit 89952c5

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

dist/quick-sql.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8410,15 +8410,16 @@ is
84108410
const n = this.inserts4tbl(t), l = this.orderedTableNodes();
84118411
let c = "";
84128412
for (let u = 0; u < l.length; u++) {
8413-
const b = n[l[u].parseName()];
8414-
b != null && (c += b);
8413+
const b = h.objPrefix() + l[u].parseName(), A = n[b];
8414+
A != null && (c += A);
84158415
}
84168416
return c;
84178417
}, this.inserts4tbl = function(t) {
84188418
let n = {};
84198419
if (h.optionEQvalue("inserts", !1))
84208420
return "";
8421-
let l = h.objPrefix() + this.parseName(), c = "", u = null, b = null;
8421+
const l = h.objPrefix() + this.parseName();
8422+
let c = "", u = null, b = null;
84228423
for (let M = 0; M < this.cardinality(); M++) {
84238424
let k = null;
84248425
if (t != null) {
@@ -8509,7 +8510,7 @@ is
85098510
}
85108511
}
85118512
c.lastIndexOf(`,
8512-
`) == c.length - 2 && (c = c.substr(0, c.length - 2) + `
8513+
`) == c.length - 2 && (c = c.substring(0, c.length - 2) + `
85138514
`), c += `);
85148515
`;
85158516
}

dist/quick-sql.umd.cjs

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

src/tree.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,8 @@ let tree = (function(){
14591459
const tables = this.orderedTableNodes();
14601460
let ret = '';
14611461
for( let i = 0; i < tables.length; i++ ) {
1462-
const inserts = tab2inserts[tables[i].parseName()];
1462+
const objName = ddl.objPrefix() + tables[i].parseName();
1463+
const inserts = tab2inserts[objName];
14631464
if( inserts != null )
14641465
ret += inserts;
14651466
}
@@ -1473,7 +1474,7 @@ let tree = (function(){
14731474
if( ddl.optionEQvalue('inserts',false) )
14741475
return '';
14751476

1476-
let objName = ddl.objPrefix() + this.parseName();
1477+
const objName = ddl.objPrefix() + this.parseName();
14771478
let insert = '';
14781479

14791480
let pkName = null;
@@ -1624,7 +1625,7 @@ let tree = (function(){
16241625
}
16251626
}
16261627
if( insert.lastIndexOf(',\n') == insert.length-2 )
1627-
insert = insert.substr(0,insert.length-2)+'\n';
1628+
insert = insert.substring(0,insert.length-2)+'\n';
16281629
insert += ');\n';
16291630
}
16301631

test/small_tests.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,16 +656,22 @@ students
656656
financial_year /check '23/24', \`'24/25'\`
657657
surname vc60 /check 'O''Hara', q'{O'Tool}'
658658
start_date /check \`to_date('01-APR-2025','DD-MON-YYYY')\``).getDDL();
659-
//console.log(output);
660659
assert( "0 < output.indexOf(\"check (financial_year in ('23/24','24/25')),\")" );
661660
assert( "0 < output.indexOf(\"check (surname in ('O''Hara',q'{O'Tool}')),\")" );
662661
assert( "0 < output.indexOf(\"check (start_date in (to_date('01-APR-2025','DD-MON-YYYY')))\")" );
663662
assert( "output.indexOf(\"''24/25''\") < 0" );
664663
assert( "output.indexOf(\"q''{O''Tool}''\") < 0" );
665664
assert( "output.indexOf(\"to_date(''01-APR-2025'',''DD-MON-YYYY'')\") < 0" );
666-
665+
666+
output = new quicksql(`departments /insert 1
667+
name /nn
668+
# settings = {"prefix":"test"}`).getDDL();
669+
//console.log(output);
670+
assert( "0 < output.indexOf(\"insert into test_departments (\")" );
671+
667672
}
668673

674+
669675
small_tests();
670676

671677
console.log(assertionCnt);

0 commit comments

Comments
 (0)