@m1212e/rumble 0.23.7 → 0.23.9

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,7 +208,7 @@ function mapNullFieldsToUndefined(obj) {
208
208
  }
209
209
  //#endregion
210
210
  //#region package.json
211
- var version = "0.23.7";
211
+ var version = "0.23.9";
212
212
  //#endregion
213
213
  //#region lib/helpers/mergeFilters.ts
214
214
  const EmptyFilter$1 = Symbol.for("drizzle:EmptyFilter");
@@ -239,6 +239,20 @@ function mergeFilters(filterA, filterB, mode = "AND") {
239
239
  };
240
240
  }
241
241
  //#endregion
242
+ //#region lib/helpers/sanitizeFilterValue.ts
243
+ const EmptyFilter = Symbol.for("drizzle:EmptyFilter");
244
+ function isPlainObject(value) {
245
+ if (typeof value !== "object" || value === null) return false;
246
+ const proto = Object.getPrototypeOf(value);
247
+ return proto === Object.prototype || proto === null;
248
+ }
249
+ function sanitizeFilterValue(value) {
250
+ if (value === void 0) return EmptyFilter;
251
+ if (Array.isArray(value)) return value.map(sanitizeFilterValue);
252
+ if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sanitizeFilterValue(entry)]));
253
+ return value;
254
+ }
255
+ //#endregion
242
256
  //#region lib/helpers/sqlTypes/types.ts
243
257
  /**
244
258
  * Strips parameter suffixes like `(256)`, `(10,2)` and timezone modifiers
@@ -453,21 +467,6 @@ function tableHelper({ db, table }) {
453
467
  }
454
468
  //#endregion
455
469
  //#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");
471
470
  function isDynamicQueryFilter(filter) {
472
471
  return typeof filter === "function" && filter.constructor.name !== "AsyncFunction";
473
472
  }
@@ -618,7 +617,7 @@ by: (explicitFilter) => {
618
617
  });
619
618
  const sqlTransformedWhere = require_lazy.lazy(() => {
620
619
  const casing = db._.session?.dialect?.casing;
621
- return filters?.where ? (0, drizzle_orm.relationsFilterToSQL)(tableSchema.foundRelation.table, filters.where, tableSchema.relations, db._.relations, casing) : void 0;
620
+ return filters?.where ? (0, drizzle_orm.relationsFilterToSQL)(tableSchema.foundRelation.table, sanitizeFilterValue(filters.where), tableSchema.relations, db._.relations, casing) : void 0;
622
621
  });
623
622
  if (filters?.columns) return {
624
623
  /**
@@ -636,7 +635,7 @@ by: (explicitFilter) => {
636
635
  */
637
636
  single: {
638
637
  extras: filters?.extras,
639
- where: filters?.where ?? EmptyFilter,
638
+ where: sanitizeFilterValue(filters?.where),
640
639
  columns: filters?.columns
641
640
  },
642
641
  /**
@@ -644,7 +643,7 @@ by: (explicitFilter) => {
644
643
  */
645
644
  many: {
646
645
  extras: filters?.extras,
647
- where: filters?.where ?? EmptyFilter,
646
+ where: sanitizeFilterValue(filters?.where),
648
647
  columns: filters?.columns,
649
648
  get limit() {
650
649
  return limit();
@@ -690,14 +689,14 @@ by: (explicitFilter) => {
690
689
  */
691
690
  single: {
692
691
  extras: filters?.extras,
693
- where: filters?.where ?? EmptyFilter
692
+ where: sanitizeFilterValue(filters?.where)
694
693
  },
695
694
  /**
696
695
  * For find many calls
697
696
  */
698
697
  many: {
699
698
  extras: filters?.extras,
700
- where: filters?.where ?? EmptyFilter,
699
+ where: sanitizeFilterValue(filters?.where),
701
700
  get limit() {
702
701
  return limit();
703
702
  }
@@ -1200,7 +1199,13 @@ function deepSetProto(obj, proto = Object.prototype, seen = /* @__PURE__ */ new
1200
1199
  if (obj === null || typeof obj !== "object") return;
1201
1200
  if (seen.has(obj)) return;
1202
1201
  seen.add(obj);
1203
- if (!Array.isArray(obj)) Object.setPrototypeOf(obj, proto);
1202
+ if (Array.isArray(obj)) {
1203
+ for (const item of obj) deepSetProto(item, proto, seen);
1204
+ return;
1205
+ }
1206
+ const currentProto = Object.getPrototypeOf(obj);
1207
+ if (currentProto !== Object.prototype && currentProto !== null) return;
1208
+ Object.setPrototypeOf(obj, proto);
1204
1209
  for (const key of Object.keys(obj)) deepSetProto(obj[key], proto, seen);
1205
1210
  }
1206
1211
  //#endregion