laravel-mongodb icon indicating copy to clipboard operation
laravel-mongodb copied to clipboard

raw method ignores all condition before calling

Open matinkhosravani opened this issue 4 years ago • 0 comments

  • Laravel-mongodb Version: 3.7.3
  • PHP Version: 7.4

when im using raw method it ignores all condition that i performed on query builder instance

Steps to reproduce

1. Course::query()->where('price' , 600000)->count() //its 1

  1. Course::query()->count() //its 3

  2. ` Course::query()
         ->where('price' , 600000)
         ->raw(function ($collection){
                       return $collection->aggregate([
                           [
                               '$match' => [
                                   'price' => ['$gte' => 5000]
                               ]
                           ],
                       ]);
     })->count(); //its 3 `
    

Expected behaviour

expect to apply all conditions that performed on query

Actual behaviour

whats happening now is that raw method ignores all conditions

i know you might suggest using whereRaw but this is basic example of bug i faced this bug using when i was doing some aggregation stage like lookup and and addfields

matinkhosravani avatar Apr 25 '21 08:04 matinkhosravani