@@ -674,8 +674,38 @@ 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+ return this . convertFilterConditionToArray ( condition . child ) ;
705+ }
706+ }
707+
708+ // Fallback: Handle legacy MongoDB-style filters for backward compatibility
679709 const result : any [ ] = [ ] ;
680710
681711 for ( const [ key , value ] of Object . entries ( condition ) ) {
@@ -703,7 +733,6 @@ export class RedisDriver implements Driver {
703733 }
704734 } else if ( key === '$not' && typeof value === 'object' ) {
705735 // Handle $not: { condition }
706- // Note: NOT is complex to represent in array format, so we skip it for now
707736 console . warn ( '[RedisDriver] NOT operator in filters is not fully supported in legacy format' ) ;
708737 const converted = this . convertFilterConditionToArray ( value ) ;
709738 if ( converted ) {
0 commit comments