Incorrect query generated with orWhere using array criteria

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: laravel-5.2.2
    • Component/s: Laravel
    • None
    • None
    • PHP Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      https://github.com/mongodb/laravel-mongodb/discussions/3337 

      I have a query

      self::select($selected_field)
      ->where(['status'=>true,'reporting_method'=> 3])
      ->orWhere(['status'=>true,'reporting_method'=> '3'])
      ->get();

       
      it should return results where reporting_method is either 3 or '3' with status: true
      But it returns all status: true records
      Here is the dump of QueryLog

      array:1 [
        0 => array:3 [
          "query" => "{ "find" : "reporting_method", "filter" : { "$or" : [ { "$and" : [ { "status" : true }, { "reporting_method" : { "$numberInt" : "3" } } ] }, { "$or" : [ { "status" : true }, { "reporting_method" : "3" } ] } ] }, "projection" : { "_id" : true, "name" : true, "reporting_method" : true } }"
          "bindings" => []
          "time" => 234
        ]
      ]

       
      It was working well and good in Lumen 5 but in lumen 10 it is not working well.
      Please check

            Assignee:
            Jérôme Tamarelle
            Reporter:
            Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: