@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 +27 -22
- package/out/index.cjs.map +1 -1
- package/out/index.d.cts.map +1 -1
- package/out/index.d.mts.map +1 -1
- package/out/index.mjs +27 -22
- package/out/index.mjs.map +1 -1
- package/package.json +1 -1
package/out/index.mjs
CHANGED
|
@@ -180,7 +180,7 @@ function mapNullFieldsToUndefined(obj) {
|
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region package.json
|
|
183
|
-
var version = "0.23.
|
|
183
|
+
var version = "0.23.9";
|
|
184
184
|
//#endregion
|
|
185
185
|
//#region lib/helpers/mergeFilters.ts
|
|
186
186
|
const EmptyFilter$1 = Symbol.for("drizzle:EmptyFilter");
|
|
@@ -211,6 +211,20 @@ function mergeFilters(filterA, filterB, mode = "AND") {
|
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
//#endregion
|
|
214
|
+
//#region lib/helpers/sanitizeFilterValue.ts
|
|
215
|
+
const EmptyFilter = Symbol.for("drizzle:EmptyFilter");
|
|
216
|
+
function isPlainObject(value) {
|
|
217
|
+
if (typeof value !== "object" || value === null) return false;
|
|
218
|
+
const proto = Object.getPrototypeOf(value);
|
|
219
|
+
return proto === Object.prototype || proto === null;
|
|
220
|
+
}
|
|
221
|
+
function sanitizeFilterValue(value) {
|
|
222
|
+
if (value === void 0) return EmptyFilter;
|
|
223
|
+
if (Array.isArray(value)) return value.map(sanitizeFilterValue);
|
|
224
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sanitizeFilterValue(entry)]));
|
|
225
|
+
return value;
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
214
228
|
//#region lib/helpers/sqlTypes/types.ts
|
|
215
229
|
/**
|
|
216
230
|
* Strips parameter suffixes like `(256)`, `(10,2)` and timezone modifiers
|
|
@@ -425,21 +439,6 @@ function tableHelper({ db, table }) {
|
|
|
425
439
|
}
|
|
426
440
|
//#endregion
|
|
427
441
|
//#region lib/abilityBuilder.ts
|
|
428
|
-
/**
|
|
429
|
-
* drizzle-orm's sentinel value for "this filter field is deliberately
|
|
430
|
-
* skipped", as opposed to `undefined`, which some drizzle-orm versions
|
|
431
|
-
* reject when it ends up as an explicit (present but `undefined`) `where`
|
|
432
|
-
* property nested inside a relational `with` query.
|
|
433
|
-
*
|
|
434
|
-
* drizzle-orm defines this via `Symbol.for("drizzle:EmptyFilter")` — a
|
|
435
|
-
* globally registered symbol — so recreating it the same way here yields
|
|
436
|
-
* the exact same value drizzle-orm's relational query engine checks for,
|
|
437
|
-
* without importing it directly: not every drizzle-orm version rumble
|
|
438
|
-
* supports exports it as a named export, and older versions that don't know
|
|
439
|
-
* about it at all still handle it safely (`Object.entries` on a symbol
|
|
440
|
-
* yields no entries, i.e. "no filter").
|
|
441
|
-
*/
|
|
442
|
-
const EmptyFilter = Symbol.for("drizzle:EmptyFilter");
|
|
443
442
|
function isDynamicQueryFilter(filter) {
|
|
444
443
|
return typeof filter === "function" && filter.constructor.name !== "AsyncFunction";
|
|
445
444
|
}
|
|
@@ -590,7 +589,7 @@ by: (explicitFilter) => {
|
|
|
590
589
|
});
|
|
591
590
|
const sqlTransformedWhere = lazy(() => {
|
|
592
591
|
const casing = db._.session?.dialect?.casing;
|
|
593
|
-
return filters?.where ? relationsFilterToSQL(tableSchema.foundRelation.table, filters.where, tableSchema.relations, db._.relations, casing) : void 0;
|
|
592
|
+
return filters?.where ? relationsFilterToSQL(tableSchema.foundRelation.table, sanitizeFilterValue(filters.where), tableSchema.relations, db._.relations, casing) : void 0;
|
|
594
593
|
});
|
|
595
594
|
if (filters?.columns) return {
|
|
596
595
|
/**
|
|
@@ -608,7 +607,7 @@ by: (explicitFilter) => {
|
|
|
608
607
|
*/
|
|
609
608
|
single: {
|
|
610
609
|
extras: filters?.extras,
|
|
611
|
-
where: filters?.where
|
|
610
|
+
where: sanitizeFilterValue(filters?.where),
|
|
612
611
|
columns: filters?.columns
|
|
613
612
|
},
|
|
614
613
|
/**
|
|
@@ -616,7 +615,7 @@ by: (explicitFilter) => {
|
|
|
616
615
|
*/
|
|
617
616
|
many: {
|
|
618
617
|
extras: filters?.extras,
|
|
619
|
-
where: filters?.where
|
|
618
|
+
where: sanitizeFilterValue(filters?.where),
|
|
620
619
|
columns: filters?.columns,
|
|
621
620
|
get limit() {
|
|
622
621
|
return limit();
|
|
@@ -662,14 +661,14 @@ by: (explicitFilter) => {
|
|
|
662
661
|
*/
|
|
663
662
|
single: {
|
|
664
663
|
extras: filters?.extras,
|
|
665
|
-
where: filters?.where
|
|
664
|
+
where: sanitizeFilterValue(filters?.where)
|
|
666
665
|
},
|
|
667
666
|
/**
|
|
668
667
|
* For find many calls
|
|
669
668
|
*/
|
|
670
669
|
many: {
|
|
671
670
|
extras: filters?.extras,
|
|
672
|
-
where: filters?.where
|
|
671
|
+
where: sanitizeFilterValue(filters?.where),
|
|
673
672
|
get limit() {
|
|
674
673
|
return limit();
|
|
675
674
|
}
|
|
@@ -1172,7 +1171,13 @@ function deepSetProto(obj, proto = Object.prototype, seen = /* @__PURE__ */ new
|
|
|
1172
1171
|
if (obj === null || typeof obj !== "object") return;
|
|
1173
1172
|
if (seen.has(obj)) return;
|
|
1174
1173
|
seen.add(obj);
|
|
1175
|
-
if (
|
|
1174
|
+
if (Array.isArray(obj)) {
|
|
1175
|
+
for (const item of obj) deepSetProto(item, proto, seen);
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
const currentProto = Object.getPrototypeOf(obj);
|
|
1179
|
+
if (currentProto !== Object.prototype && currentProto !== null) return;
|
|
1180
|
+
Object.setPrototypeOf(obj, proto);
|
|
1176
1181
|
for (const key of Object.keys(obj)) deepSetProto(obj[key], proto, seen);
|
|
1177
1182
|
}
|
|
1178
1183
|
//#endregion
|