Escaping of > char in havingRaw to >

Laravel Framework 8.37.0
PHP 8.0.3

public function scopePending($query) {
    $query->join('workshops', 'workshops.event_id', '=', '')
        ->havingRaw('min(workshops.start) > NOW()');

Returns the following error:

IlluminateDatabaseQueryException: SQLSTATE[42000]: Syntax error or access violation: 1055 '' isn't in GROUP BY (SQL: select `events`.* from `events` inner join `workshops` on `workshops`.`event_id` = `events`.`id` group by `events`.`id` having min(workshops.start) > NOW()) in file /var/www/laravel8testapp/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 678

It somehow escapes the > with > in a raw expression.
In normal where queries > works as expected.
If I run the query manually (with > replaced with >) it works as expected

Do you guys have any ideas?
Maybe its just some issue on my side or is it a reproducible bug?

Best regards


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It is as the Exception mentions, my bad:

`’’ isn’t in GROUP BY“

SET SQL_MODE=''solves the issue though that I would not recommend.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x