Just added the contract and trait to my 'Company' model, sometimes now I get a weird error:
SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns
(MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause (SQL:
select count(*) as aggregate from `audits` where `audits`.`auditable_id` = 1 and
`audits`.`auditable_id` is not null and `audits`.`auditable_type` = App\Models\Company order by
`created_at` desc)
(There are no customizations applied to anything else, just a clean model)
Small update, whenever I add: protected $auditThreshold = 500; to the model it will give the error above. If I remove this its just fine.
Hi @Cannonb4ll,
Apparently, the default MySQL connection configuration has a strict value of true, which is what is triggering that error.
You'll have to change your database.php config to:
<?php
return [
// ...
'connections' => [
// ...
'mysql' => [
// ...
'strict' => false,
// ...
],
// ...
],
];
If you search for Laravel MySQL strict mode, you'll find similar issues.
This however, led me to a subtle bug in the prune() method, which will be fixed in the next version.
Thank you, I will be awaiting the new version and for now I will set set strict to false then :)
Apparently the same error occurs in version 4.0.3 when inserting/updating with protected $auditThreshold = 10; property enabled.
@kamihouse, have you set the strict value to false?
Thanks @quetzyg. Not really, is it a requirement?
Yes, it is in this case.
How can I be sure when I change strict to false, nothing else will be affected? (I mean the originallity of the framework itself)
Some elaboration on strict would be nice.
strict mode has been active by default since Laravel 5.2. Do a search and you'll find numerous issues about it.