@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.
package/dist/index.js CHANGED
@@ -458,14 +458,8 @@ function buildDeleteFilterQuery(filter) {
458
458
  const joined = value.map((f) => {
459
459
  const entries = Object.entries(f || {});
460
460
  if (entries.length === 0) return "";
461
- const [firstKey, firstValue] = entries[0] || [];
462
- if ([
463
- "$and",
464
- "$or",
465
- "$not",
466
- "$nor"
467
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
468
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
461
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
462
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
469
463
  }).join(` ${joinOperator} `);
470
464
  const operatorFn = FILTER_OPERATORS[key];
471
465
  return operatorFn(joined, 0, value).sql;
@@ -549,14 +543,8 @@ function buildFilterQuery(filter, minScore, topK) {
549
543
  const joined = value.map((f) => {
550
544
  const entries = Object.entries(f || {});
551
545
  if (entries.length === 0) return "";
552
- const [firstKey, firstValue] = entries[0] || [];
553
- if ([
554
- "$and",
555
- "$or",
556
- "$not",
557
- "$nor"
558
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
559
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
546
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
547
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
560
548
  }).join(` ${joinOperator} `);
561
549
  const operatorFn = FILTER_OPERATORS[key];
562
550
  return operatorFn(joined, 0, value).sql;