Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Impossible to query for _id using whereRaw #2259

Unanswered
galzetta asked this question in Q&A
Discussion options

  • Laravel-mongodb Version: 3.2.3
  • PHP Version: 7.3
  • Database Driver & Version: Mongo DB 4.4, ext-mongo >= 1.9

Description:

Steps to reproduce

  1. Try to query something using Class::query()->whereRaw(['_id' => 'some-value']) or Class::query()->whereRaw(['_id' => ['$eq' => 'some-value']])

Expected behaviour

The query should return exactly the same results as Class:query()->where('_id', 'some-value')

Actual behaviour

No result is returned


In my situation I have some subscriptions and some logic that defines general rules for when a customer can see a certain subscription type. However I also need to implement an override (basically customer service wants to specify that user X can see subscription type Y even though this doesn't follow the standard rules). To do this I want to write a query like:

->whereRaw([
 '$or' => [$set_of_standard_rules, ['_id' => ['$in' => $user_overrides]]]
])

However the _id part is never matched, even when using the basic query whereRaw(['_id' => 'some-value']) or whereRaw(['_id' => ['$eq' => 'some-value']]).

You must be logged in to vote

Replies: 1 comment

Comment options

Hello,

You haven't given information about your key type which hard to guess why you're not getting results.

Thanks!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2255 on May 20, 2021 21:14.

AltStyle によって変換されたページ (->オリジナル) /