@query-doctor/core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/sql/analyzer.d.ts +5 -1
- package/dist/sql/analyzer.d.ts.map +1 -1
- package/dist/sql/walker.d.ts +1 -0
- package/dist/sql/walker.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/optimizer/genalgo.js +0 -304
- package/dist/optimizer/statistics.js +0 -700
- package/dist/package.json +0 -25
- package/dist/sql/analyzer.js +0 -270
- package/dist/sql/analyzer_test.d.ts +0 -2
- package/dist/sql/analyzer_test.d.ts.map +0 -1
- package/dist/sql/analyzer_test.js +0 -584
- package/dist/sql/builder.js +0 -77
- package/dist/sql/database.js +0 -20
- package/dist/sql/indexes.js +0 -12
- package/dist/sql/nudges.js +0 -241
- package/dist/sql/permutations_test.d.ts +0 -2
- package/dist/sql/permutations_test.d.ts.map +0 -1
- package/dist/sql/permutations_test.js +0 -53
- package/dist/sql/walker.js +0 -295
package/dist/index.cjs
CHANGED
|
@@ -318,11 +318,15 @@ var Walker = class _Walker {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
if (is2(node, "RangeVar") && node.RangeVar.relname) {
|
|
321
|
-
|
|
321
|
+
const columnReference = {
|
|
322
322
|
text: node.RangeVar.relname,
|
|
323
323
|
start: node.RangeVar.location,
|
|
324
324
|
quoted: false
|
|
325
|
-
}
|
|
325
|
+
};
|
|
326
|
+
if (node.RangeVar.schemaname) {
|
|
327
|
+
columnReference.schema = node.RangeVar.schemaname;
|
|
328
|
+
}
|
|
329
|
+
this.tableMappings.set(node.RangeVar.relname, columnReference);
|
|
326
330
|
if (node.RangeVar.alias?.aliasname) {
|
|
327
331
|
const aliasName = node.RangeVar.alias.aliasname;
|
|
328
332
|
const existingMapping = this.tableMappings.get(aliasName);
|
|
@@ -335,9 +339,12 @@ var Walker = class _Walker {
|
|
|
335
339
|
quoted: true,
|
|
336
340
|
alias: aliasName
|
|
337
341
|
};
|
|
342
|
+
if (node.RangeVar.schemaname) {
|
|
343
|
+
part.schema = node.RangeVar.schemaname;
|
|
344
|
+
}
|
|
338
345
|
if (existingMapping) {
|
|
339
346
|
console.warn(
|
|
340
|
-
`Ignoring alias ${aliasName} as it shadows an existing mapping. We currently do not support alias shadowing.`
|
|
347
|
+
`Ignoring alias ${aliasName} as it shadows an existing mapping for ${existingMapping.text}. We currently do not support alias shadowing.`
|
|
341
348
|
);
|
|
342
349
|
this.shadowedAliases.push(part);
|
|
343
350
|
return;
|
|
@@ -573,7 +580,10 @@ var Analyzer = class {
|
|
|
573
580
|
const referencedTables = [];
|
|
574
581
|
for (const value of tableMappings.values()) {
|
|
575
582
|
if (!value.alias) {
|
|
576
|
-
referencedTables.push(
|
|
583
|
+
referencedTables.push({
|
|
584
|
+
schema: value.schema,
|
|
585
|
+
table: value.text
|
|
586
|
+
});
|
|
577
587
|
}
|
|
578
588
|
}
|
|
579
589
|
const { tags, queryWithoutTags } = this.extractSqlcommenter(query);
|
|
@@ -629,13 +639,14 @@ var Analyzer = class {
|
|
|
629
639
|
}
|
|
630
640
|
} else if (tableReference) {
|
|
631
641
|
const [table, column] = colReference.parts;
|
|
642
|
+
const referencedSchema = table.schema;
|
|
632
643
|
const referencedTable = this.normalize(table);
|
|
633
644
|
const referencedColumn = this.normalize(column);
|
|
634
645
|
const matchingTable = tables.find((table2) => {
|
|
635
646
|
const hasMatchingColumn = table2.columns?.some((column2) => {
|
|
636
647
|
return column2.columnName === referencedColumn;
|
|
637
648
|
}) ?? false;
|
|
638
|
-
return table2.tableName === referencedTable && hasMatchingColumn;
|
|
649
|
+
return table2.schemaName === referencedSchema && table2.tableName === referencedTable && hasMatchingColumn;
|
|
639
650
|
});
|
|
640
651
|
if (matchingTable) {
|
|
641
652
|
const index = {
|