searchable icon indicating copy to clipboard operation
searchable copied to clipboard

SQLSTATE[42803]: Grouping error

Open lperry65 opened this issue 6 years ago • 2 comments

I've just started getting this error today, this code hasn't changed in weeks and has been working fine. I have done a composer update this morning but cant think of anything else that's changed, all my other queries work but none of the ones using search ?

SQLSTATE[42803]: Grouping error: 7 ERROR: column "users.branch_id" must appear in the GROUP BY clause or be used in an aggregate function.

users.branch_id is not part of my search:

This is whats in my model: rotected $searchable = [ /** * Columns and their priority in search results. * Columns with higher values are more important. * Columns with equal values have equal importance. * * @var array */ 'columns' => [ 'users.first_name' => 10, 'users.last_name' => 10, 'users.username' => 10, 'users.email' => 5 ] ];

I've tried re-installing the package and clearing the cache etc.

This is some test code that gives the error:

$users = User::search('lee')->get();

This used to bring back results !

Thanks,

Lee.

lperry65 avatar Nov 30 '17 13:11 lperry65

found a quick solution : in config/database.php , mysql array

            'strict' => true,
            'modes' => [
                //'ONLY_FULL_GROUP_BY', // Disable this to allow grouping by one column
                'STRICT_TRANS_TABLES',
                'NO_ZERO_IN_DATE',
                'NO_ZERO_DATE',
                'ERROR_FOR_DIVISION_BY_ZERO',
                'NO_AUTO_CREATE_USER',
                'NO_ENGINE_SUBSTITUTION'
            ],

taken from https://stackoverflow.com/a/44984930/6333300

n1crack avatar Dec 02 '17 18:12 n1crack

I'm using PostgreSQL 9

lperry65 avatar Dec 09 '17 01:12 lperry65