@query-doctor/core 0.1.6 → 0.1.8

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 CHANGED
@@ -344,9 +344,12 @@ var Walker = class _Walker {
344
344
  part.schema = node.RangeVar.schemaname;
345
345
  }
346
346
  if (existingMapping) {
347
- console.warn(
348
- `Ignoring alias ${aliasName} as it shadows an existing mapping for ${existingMapping.text}. We currently do not support alias shadowing.`
349
- );
347
+ const isSystemCatalog = node.RangeVar.relname?.startsWith("pg_") ?? false;
348
+ if (!isSystemCatalog) {
349
+ console.warn(
350
+ `Ignoring alias ${aliasName} as it shadows an existing mapping for ${existingMapping.text}. We currently do not support alias shadowing.`
351
+ );
352
+ }
350
353
  this.shadowedAliases.push(part);
351
354
  return;
352
355
  }
@@ -744,7 +747,7 @@ var Analyzer = class {
744
747
  return { tags: [], queryWithoutTags: trimmedQuery };
745
748
  }
746
749
  const queryWithoutTags = trimmedQuery.slice(0, startPosition);
747
- const tagString = trimmedQuery.slice(startPosition + 2, endPosition);
750
+ const tagString = trimmedQuery.slice(startPosition + 2, endPosition).trim();
748
751
  if (!tagString || typeof tagString !== "string") {
749
752
  return { tags: [], queryWithoutTags };
750
753
  }
@@ -752,7 +755,11 @@ var Analyzer = class {
752
755
  for (const match of tagString.split(",")) {
753
756
  const [key, value] = match.split("=");
754
757
  if (!key || !value) {
755
- console.warn(`Invalid sqlcommenter tag: ${match}. Ignoring`);
758
+ if (tags.length > 0) {
759
+ console.warn(
760
+ `Invalid sqlcommenter tag: ${match} in comment: ${tagString}. Ignoring`
761
+ );
762
+ }
756
763
  continue;
757
764
  }
758
765
  try {
@@ -1331,11 +1338,15 @@ var _IndexOptimizer = class _IndexOptimizer {
1331
1338
  findUsedIndexes(explain) {
1332
1339
  const newIndexes = /* @__PURE__ */ new Set();
1333
1340
  const existingIndexes = /* @__PURE__ */ new Set();
1341
+ const prefix = _IndexOptimizer.prefix;
1334
1342
  function go(plan) {
1335
1343
  const indexName = plan["Index Name"];
1336
1344
  if (indexName) {
1337
- if (indexName.startsWith(_IndexOptimizer.prefix)) {
1345
+ if (indexName.startsWith(prefix)) {
1338
1346
  newIndexes.add(indexName);
1347
+ } else if (indexName.includes(prefix)) {
1348
+ const actualName = indexName.substring(indexName.indexOf(prefix));
1349
+ newIndexes.add(actualName);
1339
1350
  } else {
1340
1351
  existingIndexes.add(indexName);
1341
1352
  }