@gpi What are you expecting? Your subquery isn't doing anything.
Mar 17, 2021
8
Level 1
Eloquent closures insert to query - "SELECT *" and "is null"
After update Laravel from 5.5 to 8.0 I noticed strange SQL errors: General error: 1096 No tables used. I found out that it was caused by the closers on the Eloquent model like this:
$results = Product::where('products.id', '=', 10)->where(function($query) {
});
generate SQL Query like this ($results->toSql()):
select * from `products` where `products`.`id` = ? and (select *) is null
The closure generates automatically select * and add is null. Is it a bug in Eloquent/QueryBuilder ?
Please or to participate in this conversation.