quick
quick copied to clipboard
doesntHave returns incorrect data on to-one relationships when foreign key is null
doesntHave
currently creates a WHERE NOT EXISTS
sub-select on a to-one relationship that looks like this:
SELECT *
FROM [myTable]
WHERE NOT EXISTS (SELECT 1 FROM [myOtherTable] WHERE ([myOtherTable].[id] = [FK_otherTable]))
This means that if FK_otherTable
is null, it will return all of those records, in addition to any where the empty does not exist.
The workaround, of course, is to use whereNull( 'FK_otherTable' )
but it seems like doesntHave
should be able to handle belongsTo
relationships