[SERVER-58867] Equality Match not working in $expr Created: 27/Jul/21  Updated: 01/Jun/22  Resolved: 27/Jul/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Abolfazl Ziaratban Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Hi

yii::$app->mongodb->GetCollection('sessions')->Aggregate([
    [
        '$lookup' => [
            'from' => 'users',
            'localField' => '_userId',
            'foreignField' => '_id',
            'let' => ['sRoleId' => '$_roleId'],
            'pipeline' => [
                [
                    '$match' => [
                        'enable' => true,
                    ],
                ],
                [
                    '$lookup' => [
                        'from' => 'roles',
                        'pipeline' => [
                            [
                                '$match' => [
                                    //'$expr' => ['$_id' => '$$sRoleId'],          //Error
                                    //'$expr' => ['x' => 'y'],                    //Always is true and return all docs
                                    '$expr' => ['$eq' => ['$_id','$$sRoleId']],  //OK
                                ],
                            ],
                        ],
                        'as' => 'role',
                    ],
                ],
            ],
            'as' => 'user',
        ],
    ],
]);



 Comments   
Comment by Edwin Zhou [ 27/Jul/21 ]

Hi abolfazl.ziaratban@gmail.com,

Thanks for your report. Please note that the SERVER project is for bugs and feature suggestions for the MongoDB server. As this ticket does not appear to be a bug, I will now close it. If you need further assistance troubleshooting, I encourage you to ask our community by posting on the MongoDB Developer Community Forums. If your discussion with our community forums leads you to believe that you've encountered a bug, please let us know and we will be happy to reopen this ticket and further investigate!

Best,
Edwin

Generated at Thu Feb 08 05:45:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.