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

enhance groupby behaviour with sql_mode=only_full_group_by? #9844

Open
blueo opened this issue Feb 4, 2021 · 0 comments
Open

enhance groupby behaviour with sql_mode=only_full_group_by? #9844

blueo opened this issue Feb 4, 2021 · 0 comments

Comments

@blueo
Copy link
Contributor

blueo commented Feb 4, 2021

Affected Version

SS4 with mysql >=5.7.5

Description

As mentioned in #5451 and #9721 MYSQL 5.7.5 and above has stricter requirements for queries using group by.

So it seems there is a little bit of a foot-gun for people when doing something like:

$list = MyDataObject::get();
$list->alterDataQuery(static function (DataQuery $query) use ($value) {
    return $query
        ->groupby('ID');
});

As the ORM will get all fields by default, this will result in an error as discussed a bit here: #6892.

Given it feels quite natural for people to take a the ORM as a start point and tweak it slightly like this could we do anything to help this situation?

Ideas include:

  • adding a getQueriedColumns method on DataQuery. Currently setQueriedColumns but it seems difficult to access the existing queried columns without diving into a manipulator class. This allows people to add to the groupby if needed?
  • automatically add select columns when using groupby? This is probably not a good idea/difficult but just putting it out there
  • add some suggestions to the error?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants