Skip to content

OrWhere is return wrong result #3337

Answered by GromNaN
vipinpapnai asked this question in Q&A
Discussion options

You must be logged in to vote

By using an array of criteria, Laravel splits them into a list of "where" clauses.
Without the MongoDB override, the SQL generated by your query is the following:

select * from "users" where ("status" = ? and "reporting_method" = ?) or ("status" = ? or "reporting_method" = ?)

The query generated by the MongoDB Query Builder is consistent with the Laravel behavior:

{
    "$or": [
        {
            "$and": [
                {
                    "status": true
                },
                {
                    "reporting_method": 3
                }
            ]
        },
        {
            "$or": [
                {
                    "status": true
                },
     …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by GromNaN
Comment options

You must be logged in to vote
1 reply
@masterbater
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants