Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryException: Syntax error or access violation #215

Closed
Cannonb4ll opened this issue Mar 19, 2017 · 9 comments
Closed

QueryException: Syntax error or access violation #215

Cannonb4ll opened this issue Mar 19, 2017 · 9 comments
Labels
bug Issue, error or unexpected behavior

Comments

@Cannonb4ll
Copy link

Cannonb4ll commented Mar 19, 2017

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)

@Cannonb4ll
Copy link
Author

Small update, whenever I add: protected $auditThreshold = 500; to the model it will give the error above. If I remove this its just fine.

@quetzyg quetzyg added the bug Issue, error or unexpected behavior label Mar 20, 2017
@quetzyg
Copy link
Contributor

quetzyg commented Mar 20, 2017

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.

@Cannonb4ll
Copy link
Author

Thank you, I will be awaiting the new version and for now I will set set strict to false then :)

@quetzyg quetzyg mentioned this issue Mar 21, 2017
@kamihouse
Copy link

kamihouse commented Apr 11, 2017

Apparently the same error occurs in version 4.0.3 when inserting/updating with protected $auditThreshold = 10; property enabled.

@quetzyg
Copy link
Contributor

quetzyg commented Apr 11, 2017

@kamihouse, have you set the strict value to false?

@kamihouse
Copy link

Thanks @quetzyg. Not really, is it a requirement?

@quetzyg
Copy link
Contributor

quetzyg commented Apr 12, 2017

Yes, it is in this case.

@Cannonb4ll
Copy link
Author

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.

@quetzyg
Copy link
Contributor

quetzyg commented Apr 12, 2017

strict mode has been active by default since Laravel 5.2. Do a search and you'll find numerous issues about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue, error or unexpected behavior
Projects
None yet
Development

No branches or pull requests

3 participants