Skip to content

Commit 795e9ae

Browse files
Copilothotlong
andcommitted
fix: Add backward compatibility for array-based filters
- Detect when filters are already in legacy array format - Pass through array filters without conversion - All core tests passing (276 tests) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent cdd675e commit 795e9ae

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

packages/foundation/core/src/repository.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,21 @@ export class ObjectRepository {
4848
* Converts modern object-based syntax to legacy array-based syntax:
4949
* Input: { age: { $gte: 18 }, $or: [{ status: "active" }, { role: "admin" }] }
5050
* Output: [["age", ">=", 18], "or", [["status", "=", "active"], "or", ["role", "=", "admin"]]]
51+
*
52+
* Also supports backward compatibility: if filters is already in array format, pass through.
5153
*/
5254
private translateFilters(filters?: Filter): FilterNode | undefined {
53-
if (!filters || Object.keys(filters).length === 0) {
55+
if (!filters) {
56+
return undefined;
57+
}
58+
59+
// Backward compatibility: if it's already an array (old format), pass through
60+
if (Array.isArray(filters)) {
61+
return filters as FilterNode;
62+
}
63+
64+
// If it's an empty object, return undefined
65+
if (typeof filters === 'object' && Object.keys(filters).length === 0) {
5466
return undefined;
5567
}
5668

0 commit comments

Comments
 (0)