-
-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow regex as search arguments #19
Comments
@klimov-paul I think this is not a proper fix as you can't always use On the other hand, I just tried with
And the query that was ran in MongoDB is:
Which doesn't seem to be valid. I can't find anywhere in MongoDB's docs the I tried running that same query from
Am I doing something wrong? |
Can I get some attention, please? I think this is a genuine issue that should be addressed somehow (and get this issue reopened). (or if it's not, I'd like to hear where am I failing) @klimov-paul |
There is a Official Yii forum for question asking. |
@klimov-paul I'm not asking for coding help. I'm trying to report a bug and you're constantly misreading all my issues and closing them. I already explained to you that the fix you pointed me to is not a proper fix as there are situations in which MongoDB requires an actual regex expression instead of a I'll sum that up:
|
Regular expression usage is covered by unit tests. Its correct function confirmed at yiisoft/yii2#2337. What bug are you reporting here? Or you consider yourself the first person ever using this feature? |
@klimov-paul I will agree with @alexandernst. What if I want to query a collection using simple key that has the name |
@klimov-paul Ok, I'm not really sure what MongoDB version are you testing against, but I just ran the unit tests against MongoDB 3.0.x and it's failing.
So, back to the issue. I'll try to explain it again. Please read carefully what I'll write because I already wrote the same thing twice. There are 2 issues with the regex search. The first one is that the code is using (or generating)
Now, this query generates this
You see? That The second issue is that you're failing to provide a method to use an actual regex pattern instead of the |
Unit tests are passed via Travis successfully:
If you ever bother to actually read the docs, you may find this topic: https://github.com/yiisoft/yii2-mongodb/blob/master/docs/guide/basic-usage.md
You are absolutely free to do so. |
@klimov-paul Ok, I installed Anyways, I insist that the second issue is real. There is no way to use Consider this: If I wanted to query all documents that start with
But there is no way to do this with Yii, as |
What does prevent you from write following condition: [
'path' => ['$in' => [new \MongoRegex('/^300/'), new \MongoRegex('/^500/')]]
] ? |
@klimov-paul Oh! I wasn't aware that Yii would understand (and play well) with plain PHP-MongoDB classes. That is why I didn't use |
MongoDB is able to search regex directly, but currently there is no way (or I couldn't find one) to make Yii2 to actually tell MongoDB to use a regex instead of a String.
Example:
MyModel::findAll(["path" => "/^1/2/3//"]);
I'd expect, somehow, to make Yii2 to tell MongoDB that I'm actually searching the
/^1/2/3//
regex, and not the"/^1/2/3//"
string.The text was updated successfully, but these errors were encountered: