Skip to content
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

fix filtering with operator not like issue #1829

Merged
merged 3 commits into from
Sep 13, 2019
Merged

fix filtering with operator not like issue #1829

merged 3 commits into from
Sep 13, 2019

Conversation

ahmedsayedabdelsalam
Copy link
Contributor

when filtering data with not like operator like the following example

User::where('name', 'not like', 'ahmed')

the following exception has been thrown
unknown operator: $not like

this PR fixes this issue and treated it as regex same as the like operator.

@Smolevich
Copy link
Contributor

@ahmedsayedabdelsalam, let's go to slack community, you can find link here. We have channel #review for communicating about PR's

$operator = '=';
// Replace like or not like with a Regex instance.
if (in_array($operator, ['like', 'not like'])) {
if (Str::startsWith($operator, 'not')) {
Copy link
Contributor

@jenssegers jenssegers Sep 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do string operations here:

Suggested change
if (Str::startsWith($operator, 'not')) {
if ($operator === 'not like') {

@jenssegers
Copy link
Contributor

Any chance you could add a test as well?

@jenssegers
Copy link
Contributor

@Smolevich I think the issue is clear enough here to keep the discussion on github. I rather have discussions on Slack regarding difficult topics and see how others can help to collaborate.

Moving the discussions away from github will only make it harder for people to know what's going on.

Copy link
Contributor

@Smolevich Smolevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Smolevich I think the issue is clear enough here to keep the discussion on github. I rather have discussions on Slack regarding difficult topics and see how others can help to collaborate.

Moving the discussions away from github will only make it harder for people to know what's going on.

Ok, I agree

if ($operator == 'like') {
$operator = '=';
// Replace like or not like with a Regex instance.
if (in_array($operator, ['like', 'not like'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add additional test case for not like here please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could add a test as well?

I added the test case and replaced the string operation as suggested.

@jenssegers
Copy link
Contributor

Good stuff!

@jenssegers jenssegers merged commit 2d76d22 into mongodb:master Sep 13, 2019
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this pull request Sep 2, 2024
fix filtering with operator not like issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants