@@ -547,17 +547,27 @@ export class RedisDriver implements Driver, DriverInterface {
547547 if ( ! command . updates || ! Array . isArray ( command . updates ) ) {
548548 throw new Error ( 'BulkUpdate command requires updates array' ) ;
549549 }
550- // Use Redis PIPELINE for batch operations
551- const updatePipeline = this . client . multi ( ) ;
552- const updateResults : any [ ] = [ ] ;
553- const updateTime = new Date ( ) . toISOString ( ) ;
554550
551+ // First, batch GET all existing records using PIPELINE
552+ const getPipeline = this . client . multi ( ) ;
555553 for ( const update of command . updates ) {
556554 const key = this . generateRedisKey ( command . object , update . id ) ;
557- const existing = await this . client . get ( key ) ;
555+ getPipeline . get ( key ) ;
556+ }
557+ const getResults = await getPipeline . exec ( ) ;
558+
559+ // Then, batch SET updated records using PIPELINE
560+ const setPipeline = this . client . multi ( ) ;
561+ const updateResults : any [ ] = [ ] ;
562+ const updateTime = new Date ( ) . toISOString ( ) ;
563+
564+ for ( let i = 0 ; i < command . updates . length ; i ++ ) {
565+ const update = command . updates [ i ] ;
566+ const result = getResults ?. [ i ] as any ;
567+ const existingData = result ?. [ 1 ] ;
558568
559- if ( existing ) {
560- const existingDoc = JSON . parse ( existing ) ;
569+ if ( existingData && typeof existingData === 'string' ) {
570+ const existingDoc = JSON . parse ( existingData ) ;
561571 const doc = {
562572 ...existingDoc ,
563573 ...update . data ,
@@ -566,11 +576,12 @@ export class RedisDriver implements Driver, DriverInterface {
566576 updated_at : updateTime
567577 } ;
568578 updateResults . push ( doc ) ;
569- updatePipeline . set ( key , JSON . stringify ( doc ) ) ;
579+ const key = this . generateRedisKey ( command . object , update . id ) ;
580+ setPipeline . set ( key , JSON . stringify ( doc ) ) ;
570581 }
571582 }
572583
573- await updatePipeline . exec ( ) ;
584+ await setPipeline . exec ( ) ;
574585
575586 return {
576587 success : true ,
@@ -646,6 +657,9 @@ export class RedisDriver implements Driver, DriverInterface {
646657 switch ( node . type ) {
647658 case 'comparison' :
648659 // Convert comparison node to [field, operator, value] format
660+ if ( ! node . operator ) {
661+ console . warn ( '[RedisDriver] FilterNode comparison missing operator, defaulting to "="' ) ;
662+ }
649663 const operator = node . operator || '=' ;
650664 return [ [ node . field , operator , node . value ] ] ;
651665
0 commit comments