@mastra/pg 1.14.2-alpha.0 → 1.14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 1.14.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed workflow runs advancing their update time when re-persisted in PostgreSQL storage. ([#18004](https://github.com/mastra-ai/mastra/pull/18004))
8
+
9
+ - 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))
10
+
11
+ 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.
12
+
13
+ ```typescript
14
+ await pgVector.upsert({
15
+ indexName: 'products',
16
+ vectors: [
17
+ [1, 0],
18
+ [0, 1],
19
+ ],
20
+ metadata: [{ price: 100 }, { price: 'N/A' }],
21
+ });
22
+
23
+ // Before: threw "invalid input syntax for type numeric: N/A"
24
+ // After: returns only the row whose price is actually a number
25
+ await pgVector.query({
26
+ indexName: 'products',
27
+ queryVector: [1, 0],
28
+ topK: 10,
29
+ filter: { price: { $gt: 50 } },
30
+ });
31
+ ```
32
+
33
+ - Negated numeric range filters (`$not` with `$gt`, `$gte`, `$lt`, `$lte`) now correctly exclude rows where the filtered field is missing or non-numeric. Previously these rows were incorrectly included in results. ([#18466](https://github.com/mastra-ai/mastra/pull/18466))
34
+
35
+ - Updated dependencies [[`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`023766f`](https://github.com/mastra-ai/mastra/commit/023766f44d59b30a50f3a381e33eddde8ab56c00), [`0200e75`](https://github.com/mastra-ai/mastra/commit/0200e7552d02d4221cd6040bf4eddf189a97a156), [`7c9dd77`](https://github.com/mastra-ai/mastra/commit/7c9dd77bd18cb8dc72797e25f1a0fbdc71a11347), [`7f9ae70`](https://github.com/mastra-ai/mastra/commit/7f9ae70826b047e5a66218f9e92f20e54a2d791f), [`a0509c7`](https://github.com/mastra-ai/mastra/commit/a0509c731a08aa3ed626557c5338126362856f57), [`06e0d63`](https://github.com/mastra-ai/mastra/commit/06e0d63d42bc2a202e18bc091f3781f409f5e6fb), [`bf3fe49`](https://github.com/mastra-ai/mastra/commit/bf3fe49f9467dbbdb8f9eaf74e0f7971ffb19559), [`01caf93`](https://github.com/mastra-ai/mastra/commit/01caf93d71ae2c1e65f49735cafb531975187426), [`438a971`](https://github.com/mastra-ai/mastra/commit/438a9715c8b4398e5eaf8914a1f19dc8a85dc1de), [`9990965`](https://github.com/mastra-ai/mastra/commit/999096571635a83b42ef40841fd7028cfa630779), [`77518cc`](https://github.com/mastra-ai/mastra/commit/77518ccb5bb8cc684875081e64213dc85cffdbee), [`fbeda0c`](https://github.com/mastra-ai/mastra/commit/fbeda0c0f35def07e6837936dd3a003b2b7c5172), [`8a68844`](https://github.com/mastra-ai/mastra/commit/8a688443013816105a09f89c6afa34b5ff13e26d), [`bb2a13b`](https://github.com/mastra-ai/mastra/commit/bb2a13bb4b32e6bb807200fe7b18ae8fa4322118), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`a73cd1a`](https://github.com/mastra-ai/mastra/commit/a73cd1a62a5e4ca023dcc39ba150029f4f1f74c1), [`c0ffa3c`](https://github.com/mastra-ai/mastra/commit/c0ffa3c897ccd326de880df734740a7f0681a18f), [`462a769`](https://github.com/mastra-ai/mastra/commit/462a769da61850862ca1be3d74134d33078ee6a7), [`0504bf5`](https://github.com/mastra-ai/mastra/commit/0504bf5e8cffc571a4b343326178de371e6f859b), [`0b5cc47`](https://github.com/mastra-ai/mastra/commit/0b5cc4726dc18d9a685a27520db39ff1b36bb89a), [`87f38a3`](https://github.com/mastra-ai/mastra/commit/87f38a3de03e24731f2dd6f8ed6a60b6722b85a1), [`d5fa3cd`](https://github.com/mastra-ai/mastra/commit/d5fa3cda1788c3cb93a361a3c6ec47de6ba21e98), [`fe98ef2`](https://github.com/mastra-ai/mastra/commit/fe98ef2e66dbfcbd7d645c88c9ee1e67b458a136), [`6ccf67b`](https://github.com/mastra-ai/mastra/commit/6ccf67bf075753754927a57bc2e1734ba2c820c5), [`793ea0f`](https://github.com/mastra-ai/mastra/commit/793ea0f52f831178837f21c83af6af93bf4ce638), [`825d8de`](https://github.com/mastra-ai/mastra/commit/825d8def9fa64c2bcc3d8dd6b49e09342c3ac5c7), [`507a5c4`](https://github.com/mastra-ai/mastra/commit/507a5c461bdc3136ad80744c0efbb55ce1f18f97), [`5afe423`](https://github.com/mastra-ai/mastra/commit/5afe423e4badf040f1b0d4525183a856fcb8146e), [`307573b`](https://github.com/mastra-ai/mastra/commit/307573b9ff3149b70c79540dbc86f1319b180f29), [`79b3626`](https://github.com/mastra-ai/mastra/commit/79b3626f8d647307eb07c8da14c9073c2699719d), [`c2c1d7b`](https://github.com/mastra-ai/mastra/commit/c2c1d7bb61d2602955f14ed3952f807c2d6eb576), [`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`1505c07`](https://github.com/mastra-ai/mastra/commit/1505c07603f6346bae12aa82f140e8b88ffea9ab), [`f328049`](https://github.com/mastra-ai/mastra/commit/f3280498c324afd2a8d36cd828f5b9f94a2dddc1), [`e545228`](https://github.com/mastra-ai/mastra/commit/e54522856934a5dc030b7b6385771e3548020d59), [`3eb852e`](https://github.com/mastra-ai/mastra/commit/3eb852e5435bc908b800193498103dc724f455b0), [`ffa09e7`](https://github.com/mastra-ai/mastra/commit/ffa09e772a5c92270eabe2090fc42d45bd8ec4b7), [`8c9f1c0`](https://github.com/mastra-ai/mastra/commit/8c9f1c0361d89066f9bcd14a2f69e761b01766c8), [`461a7c5`](https://github.com/mastra-ai/mastra/commit/461a7c501449295287f4f0ee4b0b42344f39fcf8), [`4211472`](https://github.com/mastra-ai/mastra/commit/4211472a5a2bd319c60cd2e42d9109c3eef7ac1c), [`9e45902`](https://github.com/mastra-ai/mastra/commit/9e4590208e745055cecca202e2db0e5c65e17d3c), [`5c0df77`](https://github.com/mastra-ai/mastra/commit/5c0df776c40efa420f8c07a2f3ee66010296618e), [`e940f09`](https://github.com/mastra-ai/mastra/commit/e940f099ef5d18b403e6f2b4937e086a4da857b1)]:
36
+ - @mastra/core@1.47.0
37
+
38
+ ## 1.14.2-alpha.1
39
+
40
+ ### Patch Changes
41
+
42
+ - Fixed workflow runs advancing their update time when re-persisted in PostgreSQL storage. ([#18004](https://github.com/mastra-ai/mastra/pull/18004))
43
+
44
+ - Negated numeric range filters (`$not` with `$gt`, `$gte`, `$lt`, `$lte`) now correctly exclude rows where the filtered field is missing or non-numeric. Previously these rows were incorrectly included in results. ([#18466](https://github.com/mastra-ai/mastra/pull/18466))
45
+
46
+ - Updated dependencies [[`bf3fe49`](https://github.com/mastra-ai/mastra/commit/bf3fe49f9467dbbdb8f9eaf74e0f7971ffb19559), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`6ccf67b`](https://github.com/mastra-ai/mastra/commit/6ccf67bf075753754927a57bc2e1734ba2c820c5), [`825d8de`](https://github.com/mastra-ai/mastra/commit/825d8def9fa64c2bcc3d8dd6b49e09342c3ac5c7), [`ffa09e7`](https://github.com/mastra-ai/mastra/commit/ffa09e772a5c92270eabe2090fc42d45bd8ec4b7), [`461a7c5`](https://github.com/mastra-ai/mastra/commit/461a7c501449295287f4f0ee4b0b42344f39fcf8), [`4211472`](https://github.com/mastra-ai/mastra/commit/4211472a5a2bd319c60cd2e42d9109c3eef7ac1c), [`9e45902`](https://github.com/mastra-ai/mastra/commit/9e4590208e745055cecca202e2db0e5c65e17d3c), [`5c0df77`](https://github.com/mastra-ai/mastra/commit/5c0df776c40efa420f8c07a2f3ee66010296618e)]:
47
+ - @mastra/core@1.47.0-alpha.3
48
+
3
49
  ## 1.14.2-alpha.0
4
50
 
5
51
  ### 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.2-alpha.0"
6
+ version: "1.14.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.14.2-alpha.0",
2
+ "version": "1.14.2",
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: `(CASE WHEN jsonb_typeof(metadata#>'{${jsonPathKey}}') = 'number' THEN (metadata#>>'{${jsonPathKey}}')::numeric ${symbol} $${paramIndex}::numeric ELSE FALSE END)`,
188
+ sql: `(CASE WHEN jsonb_typeof(metadata#>'{${jsonPathKey}}') = 'number' THEN (metadata#>>'{${jsonPathKey}}')::numeric ${symbol} $${paramIndex}::numeric ELSE NULL END)`,
189
189
  needsValue: true
190
190
  };
191
191
  } else {
@@ -18300,11 +18300,12 @@ var WorkflowsPG = class _WorkflowsPG extends storage.WorkflowsStorage {
18300
18300
  const now = /* @__PURE__ */ new Date();
18301
18301
  const sanitizedSnapshot = sanitizeJsonForPg(JSON.stringify(snapshot));
18302
18302
  await t.none(
18303
- `INSERT INTO ${tableName} (workflow_name, run_id, snapshot, "createdAt", "updatedAt")
18304
- VALUES ($1, $2, $3, $4, $5)
18303
+ `INSERT INTO ${tableName}
18304
+ (workflow_name, run_id, snapshot, "createdAt", "updatedAt", "createdAtZ", "updatedAtZ")
18305
+ VALUES ($1, $2, $3, $4, $5, $6, $7)
18305
18306
  ON CONFLICT (workflow_name, run_id) DO UPDATE
18306
- SET snapshot = $3, "updatedAt" = $5`,
18307
- [workflowName, runId, sanitizedSnapshot, now, now]
18307
+ SET snapshot = $3, "updatedAt" = $5, "updatedAtZ" = $7`,
18308
+ [workflowName, runId, sanitizedSnapshot, now, now, now, now]
18308
18309
  );
18309
18310
  return snapshot.context;
18310
18311
  });
@@ -18346,9 +18347,12 @@ var WorkflowsPG = class _WorkflowsPG extends storage.WorkflowsStorage {
18346
18347
  }
18347
18348
  const updatedSnapshot = { ...snapshot, ...opts };
18348
18349
  const sanitizedSnapshot = sanitizeJsonForPg(JSON.stringify(updatedSnapshot));
18350
+ const now = /* @__PURE__ */ new Date();
18349
18351
  await t.none(
18350
- `UPDATE ${tableName} SET snapshot = $1, "updatedAt" = $2 WHERE workflow_name = $3 AND run_id = $4`,
18351
- [sanitizedSnapshot, /* @__PURE__ */ new Date(), workflowName, runId]
18352
+ `UPDATE ${tableName}
18353
+ SET snapshot = $1, "updatedAt" = $2, "updatedAtZ" = $3
18354
+ WHERE workflow_name = $4 AND run_id = $5`,
18355
+ [sanitizedSnapshot, now, now, workflowName, runId]
18352
18356
  );
18353
18357
  return updatedSnapshot;
18354
18358
  });
@@ -18381,11 +18385,21 @@ var WorkflowsPG = class _WorkflowsPG extends storage.WorkflowsStorage {
18381
18385
  const updatedAtValue = updatedAt ? updatedAt : now;
18382
18386
  const sanitizedSnapshot = sanitizeJsonForPg(JSON.stringify(snapshot));
18383
18387
  await this.#db.client.none(
18384
- `INSERT INTO ${getTableName7({ indexName: storage.TABLE_WORKFLOW_SNAPSHOT, schemaName: getSchemaName7(this.#schema) })} (workflow_name, run_id, "resourceId", snapshot, "createdAt", "updatedAt")
18385
- VALUES ($1, $2, $3, $4, $5, $6)
18388
+ `INSERT INTO ${getTableName7({ indexName: storage.TABLE_WORKFLOW_SNAPSHOT, schemaName: getSchemaName7(this.#schema) })}
18389
+ (workflow_name, run_id, "resourceId", snapshot, "createdAt", "updatedAt", "createdAtZ", "updatedAtZ")
18390
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
18386
18391
  ON CONFLICT (workflow_name, run_id) DO UPDATE
18387
- SET "resourceId" = $3, snapshot = $4, "updatedAt" = $6`,
18388
- [workflowName, runId, resourceId, sanitizedSnapshot, createdAtValue, updatedAtValue]
18392
+ SET "resourceId" = $3, snapshot = $4, "updatedAt" = $6, "updatedAtZ" = $8`,
18393
+ [
18394
+ workflowName,
18395
+ runId,
18396
+ resourceId,
18397
+ sanitizedSnapshot,
18398
+ createdAtValue,
18399
+ updatedAtValue,
18400
+ createdAtValue,
18401
+ updatedAtValue
18402
+ ]
18389
18403
  );
18390
18404
  } catch (error$1) {
18391
18405
  throw new error.MastraError(