yabhq / laravel-scout-mysql-driver

Laravel Scout MySQL Driver
MIT License
522 stars 113 forks source link

Where null issue #52

Open it-can opened 7 years ago

it-can commented 7 years ago

Laravel: 5.5.18

Hi I was testing this package and see some strange behavoir with nullable columns. I have this query:

Invoice::search('fox')
            ->where('exported', null)
            ->get();

This generates a query like this:

select * from `invoice` where exported = '' AND (`name` LIKE '%fox%')

What I expect:

select * from `invoice` where exported = null AND (`name` LIKE '%fox%')

This is incorrect... Also adding a extra parameter to the where is incorrect:

Invoice::search('fox')
            ->where('exported', '!=', null)
            ->get();
select * from `invoice` where exported = '!=' AND (`name` LIKE '%fox%')

What I expect:

select * from `invoice` where exported != null AND (`name` LIKE '%fox%')