esbenp / esbenp/bruno

Bug with not contains

Open
#39 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
163
Forks
70
PR merge metrics
No merged PRs in 30d

Description

Hello There,

I can't submit a pull request for this as i've changed so much of the code. However, I found a rather fatal bug when filtering by something that DOES NOT contain X

You current code ends up creating an SQL query that will look something like this :

```
select * from `users` where `users`.`customer_id` = 1 and `users`.`customer_id` is not null and (CAST(users.name AS CHAR) = NOTLIKE) order by `id` desc
```

Obviously this is wrong.

You simply need to make a small change to your case switch in the database trait from this :

```
$clauseOperator = ($not ? 'NOT':'') . (($dbType === 'postgres') ? 'ILIKE' : 'LIKE');
```

To this (adding a space after the NOT)

```
$clauseOperator = ($not ? 'NOT ':'') . (($dbType === 'postgres') ? 'ILIKE' : 'LIKE');
```

The end query will then look tike this :

```
select * from `users` where `users`.`customer_id` = 1 and `users`.`customer_id` is not null and (CAST(users.name AS CHAR) NOT LIKE '%frank%') order by `id` desc
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.