Skip to content

whereAny and whereAll query Error #2757

Closed as not planned
Closed as not planned
@ilejohn-official

Description

@ilejohn-official
  • Laravel-mongodb Version: 4.1.x-dev
  • PHP Version: 8.2.14
  • Database Driver & Version:

Description:

The whereAny and whereAll query are not generating accurate mongo queries as it does in SQL. https://laravel.com/docs/10.x/queries#where-any-all-clauses

Steps to reproduce

  1. perform a whereAny or whereAll query on a collection
  2. chain toMql() to see the query output

Expected behaviour

for example a whereAny query

Model::whereAny(['title','text','shortcut','first_line'], 'like', '%-p%')->toMql();

should look like this

[
 'find' => [
     '$or' => [
            ['title' => new \MongoDB\BSON\Regex('^.*\-p.*$', 'i')],
            ['text' => new \MongoDB\BSON\Regex('^.*\-p.*$', 'i')],
            ['shortcut' => new \MongoDB\BSON\Regex('^.*\-p.*$', 'i')],
            ['first_line' => new \MongoDB\BSON\Regex('^.*\-p.*$', 'i')],
      ],
 ],
]
  

Actual behaviour

Instead this is what I see

[
 'find' => [
    'any' => [
            0 => ['title' => true],
            1 => ['text' => true],
            2 => ['shortcut' => true],
            3 => ['first_line' => true],
        ],
  ]
 ]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions