@m1212e/rumble 0.23.4 → 0.23.5

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/out/index.cjs CHANGED
@@ -208,12 +208,25 @@ function mapNullFieldsToUndefined(obj) {
208
208
  }
209
209
  //#endregion
210
210
  //#region package.json
211
- var version = "0.23.4";
211
+ var version = "0.23.5";
212
212
  //#endregion
213
213
  //#region lib/helpers/mergeFilters.ts
214
+ const EmptyFilter$1 = Symbol.for("drizzle:EmptyFilter");
215
+ /**
216
+ * Normalizes drizzle-orm's `EmptyFilter` sentinel to `undefined` so it's
217
+ * treated as "no filter" rather than a real filter value to combine with
218
+ * AND/OR — otherwise merging an unrestricted (EmptyFilter) base filter with
219
+ * a real `where` would needlessly wrap it as `{ AND: [EmptyFilter, where] }`
220
+ * instead of just `where`.
221
+ */
222
+ function realWhere(where) {
223
+ return where === EmptyFilter$1 ? void 0 : where;
224
+ }
214
225
  function mergeFilters(filterA, filterB, mode = "AND") {
226
+ const filterAWhere = realWhere(filterA?.where);
227
+ const filterBWhere = realWhere(filterB?.where);
215
228
  return {
216
- where: filterA?.where && filterB?.where ? mode === "OR" ? { OR: [filterA.where, filterB.where] } : { AND: [filterA.where, filterB.where] } : filterA?.where ?? filterB?.where,
229
+ where: filterAWhere && filterBWhere ? mode === "OR" ? { OR: [filterAWhere, filterBWhere] } : { AND: [filterAWhere, filterBWhere] } : filterAWhere ?? filterBWhere,
217
230
  columns: filterA?.columns || filterB?.columns ? new Set([Object.entries(filterA?.columns ?? {}), Object.entries(filterB?.columns ?? {})].flat().filter(([, v]) => v === true).map(([k]) => k)).entries().reduce((acc, [key]) => {
218
231
  acc[key] = true;
219
232
  return acc;
@@ -440,6 +453,21 @@ function tableHelper({ db, table }) {
440
453
  }
441
454
  //#endregion
442
455
  //#region lib/abilityBuilder.ts
456
+ /**
457
+ * drizzle-orm's sentinel value for "this filter field is deliberately
458
+ * skipped", as opposed to `undefined`, which some drizzle-orm versions
459
+ * reject when it ends up as an explicit (present but `undefined`) `where`
460
+ * property nested inside a relational `with` query.
461
+ *
462
+ * drizzle-orm defines this via `Symbol.for("drizzle:EmptyFilter")` — a
463
+ * globally registered symbol — so recreating it the same way here yields
464
+ * the exact same value drizzle-orm's relational query engine checks for,
465
+ * without importing it directly: not every drizzle-orm version rumble
466
+ * supports exports it as a named export, and older versions that don't know
467
+ * about it at all still handle it safely (`Object.entries` on a symbol
468
+ * yields no entries, i.e. "no filter").
469
+ */
470
+ const EmptyFilter = Symbol.for("drizzle:EmptyFilter");
443
471
  function isDynamicQueryFilter(filter) {
444
472
  return typeof filter === "function" && filter.constructor.name !== "AsyncFunction";
445
473
  }
@@ -608,7 +636,7 @@ by: (explicitFilter) => {
608
636
  */
609
637
  single: {
610
638
  extras: filters?.extras,
611
- where: filters?.where,
639
+ where: filters?.where ?? EmptyFilter,
612
640
  columns: filters?.columns
613
641
  },
614
642
  /**
@@ -616,7 +644,7 @@ by: (explicitFilter) => {
616
644
  */
617
645
  many: {
618
646
  extras: filters?.extras,
619
- where: filters?.where,
647
+ where: filters?.where ?? EmptyFilter,
620
648
  columns: filters?.columns,
621
649
  get limit() {
622
650
  return limit();
@@ -662,14 +690,14 @@ by: (explicitFilter) => {
662
690
  */
663
691
  single: {
664
692
  extras: filters?.extras,
665
- where: filters?.where
693
+ where: filters?.where ?? EmptyFilter
666
694
  },
667
695
  /**
668
696
  * For find many calls
669
697
  */
670
698
  many: {
671
699
  extras: filters?.extras,
672
- where: filters?.where,
700
+ where: filters?.where ?? EmptyFilter,
673
701
  get limit() {
674
702
  return limit();
675
703
  }