bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Bug with not contains

Open TheFrankman opened this issue 6 years ago • 0 comments

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

TheFrankman avatar Jun 14 '18 15:06 TheFrankman