Skip to content

Commit 1759209

Browse files
Merge pull request #196 from objectstack-ai/copilot/fix-action-run-error
2 parents 332243e + 682118c commit 1759209

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

packages/drivers/redis/src/index.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,40 @@ export class RedisDriver implements Driver {
674674
return condition;
675675
}
676676

677-
// If it's an object (FilterCondition), convert to array format
678-
// This is a simplified conversion - a full implementation would need to handle all operators
677+
// Handle new @objectstack/spec FilterCondition format (v0.3.3+)
678+
// Check if it's the new format with 'type' property
679+
if (condition.type) {
680+
if (condition.type === 'comparison') {
681+
// Handle comparison filter: { type: 'comparison', field, operator, value }
682+
return [[condition.field, condition.operator, condition.value]];
683+
} else if (condition.type === 'and' || condition.type === 'or') {
684+
// Handle logical filter: { type: 'and' | 'or', children: [...] }
685+
const result: any[] = [];
686+
const logicalOp = condition.type;
687+
688+
if (condition.children && Array.isArray(condition.children)) {
689+
for (let i = 0; i < condition.children.length; i++) {
690+
const converted = this.convertFilterConditionToArray(condition.children[i]);
691+
if (converted && converted.length > 0) {
692+
if (result.length > 0) {
693+
result.push(logicalOp);
694+
}
695+
result.push(...converted);
696+
}
697+
}
698+
}
699+
700+
return result.length > 0 ? result : undefined;
701+
} else if (condition.type === 'not') {
702+
// Handle NOT filter: { type: 'not', child: {...} }
703+
console.warn('[RedisDriver] NOT operator in filters is not fully supported in legacy format');
704+
if (condition.child) {
705+
return this.convertFilterConditionToArray(condition.child);
706+
}
707+
}
708+
}
709+
710+
// Fallback: Handle legacy MongoDB-style filters for backward compatibility
679711
const result: any[] = [];
680712

681713
for (const [key, value] of Object.entries(condition)) {
@@ -703,7 +735,6 @@ export class RedisDriver implements Driver {
703735
}
704736
} else if (key === '$not' && typeof value === 'object') {
705737
// Handle $not: { condition }
706-
// Note: NOT is complex to represent in array format, so we skip it for now
707738
console.warn('[RedisDriver] NOT operator in filters is not fully supported in legacy format');
708739
const converted = this.convertFilterConditionToArray(value);
709740
if (converted) {

0 commit comments

Comments
 (0)