@query-doctor/core 0.8.0 → 0.8.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 +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +18 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -855,6 +855,12 @@ function stripTableQualifiers(node) {
|
|
|
855
855
|
//#endregion
|
|
856
856
|
//#region src/sql/analyzer.ts
|
|
857
857
|
const ignoredIdentifier = "__qd_placeholder";
|
|
858
|
+
const STATEMENT_TYPE_MAP = {
|
|
859
|
+
SelectStmt: "select",
|
|
860
|
+
InsertStmt: "insert",
|
|
861
|
+
UpdateStmt: "update",
|
|
862
|
+
DeleteStmt: "delete"
|
|
863
|
+
};
|
|
858
864
|
/**
|
|
859
865
|
* Analyzes a query and returns a list of column references that
|
|
860
866
|
* should be indexed.
|
|
@@ -870,6 +876,7 @@ var Analyzer = class {
|
|
|
870
876
|
if (!ast.stmts) throw new Error("Query did not have any statements. This should probably never happen?");
|
|
871
877
|
const stmt = ast.stmts[0].stmt;
|
|
872
878
|
if (!stmt) throw new Error("Query did not have any statements. This should probably never happen?");
|
|
879
|
+
const statementType = STATEMENT_TYPE_MAP[getNodeKind(stmt)] ?? "other";
|
|
873
880
|
const { highlights, indexRepresentations, indexesToCheck, shadowedAliases, tempTables, tableMappings, nudges } = new Walker(query).walk(stmt);
|
|
874
881
|
const sortedHighlights = highlights.sort((a, b) => b.position.end - a.position.end);
|
|
875
882
|
let currQuery = query;
|
|
@@ -907,6 +914,7 @@ var Analyzer = class {
|
|
|
907
914
|
const { tags, queryWithoutTags } = this.extractSqlcommenter(query);
|
|
908
915
|
const formattedQueryWithoutTags = formattedQuery ? this.extractSqlcommenter(formattedQuery).queryWithoutTags : void 0;
|
|
909
916
|
return {
|
|
917
|
+
statementType,
|
|
910
918
|
indexesToCheck,
|
|
911
919
|
ansiHighlightedQuery: currQuery,
|
|
912
920
|
referencedTables,
|
|
@@ -2526,6 +2534,15 @@ var PssRewriter = class {
|
|
|
2526
2534
|
}
|
|
2527
2535
|
};
|
|
2528
2536
|
//#endregion
|
|
2537
|
+
//#region src/sentry.ts
|
|
2538
|
+
function deriveSentryEnvironment(url) {
|
|
2539
|
+
if (!url) return "local";
|
|
2540
|
+
if (url.includes("next")) return "next";
|
|
2541
|
+
if (url.includes("staging")) return "staging";
|
|
2542
|
+
if (url.includes("querydoctor.com")) return "production";
|
|
2543
|
+
return "local";
|
|
2544
|
+
}
|
|
2545
|
+
//#endregion
|
|
2529
2546
|
exports.Analyzer = Analyzer;
|
|
2530
2547
|
exports.ExportedStats = ExportedStats;
|
|
2531
2548
|
exports.ExportedStatsColumns = ExportedStatsColumns;
|
|
@@ -2543,6 +2560,7 @@ exports.SKIP = SKIP;
|
|
|
2543
2560
|
exports.Statistics = Statistics;
|
|
2544
2561
|
exports.StatisticsMode = StatisticsMode;
|
|
2545
2562
|
exports.StatisticsSource = StatisticsSource;
|
|
2563
|
+
exports.deriveSentryEnvironment = deriveSentryEnvironment;
|
|
2546
2564
|
exports.dropIndex = dropIndex;
|
|
2547
2565
|
exports.ignoredIdentifier = ignoredIdentifier;
|
|
2548
2566
|
exports.isIndexProbablyDroppable = isIndexProbablyDroppable;
|