@mastra/pg 1.14.1 → 1.14.2-alpha.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 1.14.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed PgVector numeric range filters (`$gt`, `$gte`, `$lt`, `$lte`) so rows with non-numeric metadata values no longer fail the whole query. ([#18430](https://github.com/mastra-ai/mastra/pull/18430))
8
+
9
+ A single document with a value like `{ price: 'N/A' }` used to make the entire query error out, breaking all range-filtered vector queries (and semantic recall using `semanticRecall.filter`) on that index. Rows whose value isn't a number are now skipped for numeric range checks instead, matching the behavior of the other Mastra vector stores. Numeric rows still match as expected.
10
+
11
+ ```typescript
12
+ await pgVector.upsert({
13
+ indexName: 'products',
14
+ vectors: [
15
+ [1, 0],
16
+ [0, 1],
17
+ ],
18
+ metadata: [{ price: 100 }, { price: 'N/A' }],
19
+ });
20
+
21
+ // Before: threw "invalid input syntax for type numeric: N/A"
22
+ // After: returns only the row whose price is actually a number
23
+ await pgVector.query({
24
+ indexName: 'products',
25
+ queryVector: [1, 0],
26
+ topK: 10,
27
+ filter: { price: { $gt: 50 } },
28
+ });
29
+ ```
30
+
31
+ - Updated dependencies [[`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`7c9dd77`](https://github.com/mastra-ai/mastra/commit/7c9dd77bd18cb8dc72797e25f1a0fbdc71a11347), [`9990965`](https://github.com/mastra-ai/mastra/commit/999096571635a83b42ef40841fd7028cfa630779), [`c0ffa3c`](https://github.com/mastra-ai/mastra/commit/c0ffa3c897ccd326de880df734740a7f0681a18f), [`0504bf5`](https://github.com/mastra-ai/mastra/commit/0504bf5e8cffc571a4b343326178de371e6f859b), [`5afe423`](https://github.com/mastra-ai/mastra/commit/5afe423e4badf040f1b0d4525183a856fcb8146e), [`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`8c9f1c0`](https://github.com/mastra-ai/mastra/commit/8c9f1c0361d89066f9bcd14a2f69e761b01766c8)]:
32
+ - @mastra/core@1.47.0-alpha.2
33
+
3
34
  ## 1.14.1
4
35
 
5
36
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-pg
3
3
  description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/pg"
6
- version: "1.14.1"
6
+ version: "1.14.2-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.14.1",
2
+ "version": "1.14.2-alpha.0",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -185,7 +185,7 @@ var createNumericOperator = (symbol) => {
185
185
  const isNumeric = typeof value === "number" || typeof value === "string" && !isNaN(Number(value)) && value.trim() !== "";
186
186
  if (isNumeric) {
187
187
  return {
188
- sql: `(metadata#>>'{${jsonPathKey}}')::numeric ${symbol} $${paramIndex}::numeric`,
188
+ sql: `(CASE WHEN jsonb_typeof(metadata#>'{${jsonPathKey}}') = 'number' THEN (metadata#>>'{${jsonPathKey}}')::numeric ${symbol} $${paramIndex}::numeric ELSE FALSE END)`,
189
189
  needsValue: true
190
190
  };
191
191
  } else {
@@ -226,7 +226,7 @@ function buildElemMatchConditions(value, paramIndex) {
226
226
  throw new Error(`Invalid operator: ${paramOperator}`);
227
227
  }
228
228
  const result = operatorFn(paramKey, nextParamIndex, paramValue);
229
- const sql = result.sql.replaceAll("metadata#>>", "elem#>>");
229
+ const sql = result.sql.replaceAll("metadata#>>", "elem#>>").replaceAll("metadata#>", "elem#>");
230
230
  conditions.push(sql);
231
231
  if (result.needsValue) {
232
232
  values.push(paramValue);