@@ -579,41 +579,28 @@ export class MongoDriver implements Driver, DriverInterface {
579579 return [ [ node . field , operator , node . value ] ] ;
580580
581581 case 'and' :
582- // Convert AND node to array with 'and' separator
583- if ( ! node . children || node . children . length === 0 ) return undefined ;
584- const andResults : any [ ] = [ ] ;
585- for ( const child of node . children ) {
586- const converted = this . convertFilterNodeToLegacy ( child ) ;
587- if ( converted ) {
588- if ( andResults . length > 0 ) {
589- andResults . push ( 'and' ) ;
590- }
591- andResults . push ( ...( Array . isArray ( converted ) ? converted : [ converted ] ) ) ;
592- }
593- }
594- return andResults . length > 0 ? andResults : undefined ;
595-
596582 case 'or' :
597- // Convert OR node to array with 'or' separator
583+ // Convert AND/ OR node to array with separator
598584 if ( ! node . children || node . children . length === 0 ) return undefined ;
599- const orResults : any [ ] = [ ] ;
585+ const results : any [ ] = [ ] ;
586+ const separator = node . type ; // 'and' or 'or'
587+
600588 for ( const child of node . children ) {
601589 const converted = this . convertFilterNodeToLegacy ( child ) ;
602590 if ( converted ) {
603- if ( orResults . length > 0 ) {
604- orResults . push ( 'or' ) ;
591+ if ( results . length > 0 ) {
592+ results . push ( separator ) ;
605593 }
606- orResults . push ( ...( Array . isArray ( converted ) ? converted : [ converted ] ) ) ;
594+ results . push ( ...( Array . isArray ( converted ) ? converted : [ converted ] ) ) ;
607595 }
608596 }
609- return orResults . length > 0 ? orResults : undefined ;
597+ return results . length > 0 ? results : undefined ;
610598
611599 case 'not' :
612- // NOT is complex - we'll just process the first child for now
613- if ( node . children && node . children . length > 0 ) {
614- return this . convertFilterNodeToLegacy ( node . children [ 0 ] ) ;
615- }
616- return undefined ;
600+ // NOT is not directly supported in the legacy filter format
601+ // MongoDB supports $not, but legacy array format doesn't have a NOT operator
602+ // We'll throw an error to indicate this limitation
603+ throw new Error ( 'NOT filters are not supported in legacy filter format. Use native MongoDB queries with $not operator instead.' ) ;
617604
618605 default :
619606 return undefined ;
0 commit comments