You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT *
FROM `booking_boats`
INNER JOIN `bookings`
ON `bookings`.`id` = `booking_boats`.`booking_id`
WHERE `bookings`.`deleted_at` is null
AND `bookings`.`location_id` = ?
AND (`booking_boats`.`status` = ? or (`booking_boats`.`status` = ? AND `booking_boats`.`checkout_date` != ?))
AND `booking_boats`.`deleted_at` is null
The important part is: (booking_boats.status = ? ANDbooking_boats.checkout_date != ?)
In Laravel 11, the following query is generated:
SELECT *
FROM `booking_boats`
INNER JOIN `bookings`
ON `bookings`.`id` = `booking_boats`.`booking_id`
WHERE `bookings`.`location_id` = ?
AND (`booking_boats`.`status` = ? or (`booking_boats`.`status` = ? or `booking_boats`.`checkout_date` != ?))
AND `booking_boats`.`deleted_at` is null
AND `bookings`.`deleted_at` is null
The important part is: (booking_boats.status = ? orbooking_boats.checkout_date != ?)
So, previously using ->orWhere with an array syntax would generate an AND query, but now it generates an OR query.
This seems like a bug but if somehow I missed this in the laravel upgrade notes I would appreciate knowing what exactly was changed and what functions are impacted as there are hundreds of queries I will have to update.
Thank you.
Steps To Reproduce
Perform an ->orWhere using multiple array elements, ie:
Thanks for the context. I don't really see a resolution in the duplicate though? A PR was even added to revert the breaking change but it was closed. Per this comment sounds like I'm not the only one to have spent a lot of time debugging this without seeing any mention of it in the migration guide.
Does this change in behavior only effect orWhere or does it affect other queries too?
Is there an alternative to orWhere that will keep the same behavior?
Laravel Version
11.33.2
PHP Version
8.3.13
Database Driver & Version
MySQL
Description
I recently upgraded a legacy laravel application from 5.4 to laravel 11.
The following code:
Would previously generate a query like this:
The important part is:
(
booking_boats
.status
= ? ANDbooking_boats
.checkout_date
!= ?)In Laravel 11, the following query is generated:
The important part is:
(
booking_boats
.status
= ? orbooking_boats
.checkout_date
!= ?)So, previously using ->orWhere with an array syntax would generate an AND query, but now it generates an OR query.
This seems like a bug but if somehow I missed this in the laravel upgrade notes I would appreciate knowing what exactly was changed and what functions are impacted as there are hundreds of queries I will have to update.
Thank you.
Steps To Reproduce
Perform an ->orWhere using multiple array elements, ie:
The text was updated successfully, but these errors were encountered: