@mastra/pg 1.28.0-alpha.2 → 1.28.0-alpha.3

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.
@@ -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.28.0-alpha.2"
6
+ version: "1.28.0-alpha.3"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.28.0-alpha.2",
2
+ "version": "1.28.0-alpha.3",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -482,14 +482,8 @@ function buildDeleteFilterQuery(filter) {
482
482
  const joined = value.map((f) => {
483
483
  const entries = Object.entries(f || {});
484
484
  if (entries.length === 0) return "";
485
- const [firstKey, firstValue] = entries[0] || [];
486
- if ([
487
- "$and",
488
- "$or",
489
- "$not",
490
- "$nor"
491
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
492
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
485
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
486
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
493
487
  }).join(` ${joinOperator} `);
494
488
  const operatorFn = FILTER_OPERATORS[key];
495
489
  return operatorFn(joined, 0, value).sql;
@@ -573,14 +567,8 @@ function buildFilterQuery(filter, minScore, topK) {
573
567
  const joined = value.map((f) => {
574
568
  const entries = Object.entries(f || {});
575
569
  if (entries.length === 0) return "";
576
- const [firstKey, firstValue] = entries[0] || [];
577
- if ([
578
- "$and",
579
- "$or",
580
- "$not",
581
- "$nor"
582
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
583
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
570
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
571
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
584
572
  }).join(` ${joinOperator} `);
585
573
  const operatorFn = FILTER_OPERATORS[key];
586
574
  return operatorFn(joined, 0, value).sql;