php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76108 error in build filter with array
Submitted: 2018-03-17 07:43 UTC Modified: 2018-03-17 10:12 UTC
From: 860760361 at qq dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.28 OS:
Private report: No CVE-ID: None
 [2018-03-17 07:43 UTC] 860760361 at qq dot com
Description:
------------
---
From manual page: http://www.php.net/mongodb-driver-manager.executequery
---
using the current version of mongodb driver,it has a bug in building a filter for a query when use '$or' operator to the same field.
there is field named "foo" ,not every docs has this field. I want to search a list contain the docs that not has field "foo" or "foo" is equal to "value" . I shoud build a filter such as below:
['$or'=>[
'foo'=>['$exists'=>false],
'foo'=>['$eq'=>"value"]
]]
so the key has named twitce,we can't use array to define a filter 

Expected result:
----------------
may be
['$or'=>[
['foo',['$exists'=>false]],
['foo',['$eq'=>"value"]]
]]
or
{ $or : [ { foo : { $exists: false } }, { foo : value } ] }


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-17 08:18 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-03-17 08:18 UTC] requinix@php.net
> I shoud build a filter such as below:
No, that array structure is incorrect. $or is an array containing conditions and a [foo=>value] array is one condition.

['$or' => [
  ['foo' => ['$exists' => false]],
  ['foo' => ['$eq' => "value"]]
]]
 [2018-03-17 10:12 UTC] 860760361 at qq dot com
it's confirmed,thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC