@query-doctor/core 0.1.1 → 0.1.2

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
@@ -44,6 +44,7 @@ __export(index_exports, {
44
44
  PgIdentifier: () => PgIdentifier,
45
45
  PostgresQueryBuilder: () => PostgresQueryBuilder,
46
46
  PostgresVersion: () => PostgresVersion,
47
+ PssRewriter: () => PssRewriter,
47
48
  SKIP: () => SKIP,
48
49
  Statistics: () => Statistics,
49
50
  StatisticsMode: () => StatisticsMode,
@@ -2023,6 +2024,28 @@ __publicField(_Statistics, "defaultStatsMode", Object.freeze({
2023
2024
  relpages: DEFAULT_RELPAGES
2024
2025
  }));
2025
2026
  var Statistics = _Statistics;
2027
+
2028
+ // src/optimizer/pss-rewriter.ts
2029
+ var PssRewriter = class {
2030
+ constructor() {
2031
+ __publicField(this, "problematicKeywords", ["interval", "timestamp", "geometry"]);
2032
+ }
2033
+ rewrite(query) {
2034
+ return this.rewriteKeywordWithParameter(query);
2035
+ }
2036
+ rewriteKeywordWithParameter(query) {
2037
+ return query.replace(/\b(\w+) (\$\d+)\b/gi, (match) => {
2038
+ const [keyword, parameter] = match.split(" ");
2039
+ const isProblematicKeyword = this.problematicKeywords.includes(
2040
+ keyword.toLowerCase()
2041
+ );
2042
+ if (!isProblematicKeyword) {
2043
+ return match;
2044
+ }
2045
+ return `(${parameter}::${keyword.toLowerCase()})`;
2046
+ });
2047
+ }
2048
+ };
2026
2049
  // Annotate the CommonJS export names for ESM import in node:
2027
2050
  0 && (module.exports = {
2028
2051
  Analyzer,
@@ -2036,6 +2059,7 @@ var Statistics = _Statistics;
2036
2059
  PgIdentifier,
2037
2060
  PostgresQueryBuilder,
2038
2061
  PostgresVersion,
2062
+ PssRewriter,
2039
2063
  SKIP,
2040
2064
  Statistics,
2041
2065
  StatisticsMode,