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

Support modern SQL modes #370

Open
Alanaktion opened this issue Apr 9, 2019 · 1 comment
Open

Support modern SQL modes #370

Alanaktion opened this issue Apr 9, 2019 · 1 comment
Assignees
Labels

Comments

@Alanaktion
Copy link
Owner

MySQL 5.7 and higher set this SQL mode by default: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

We should update our queries to support these defaults. In particular, some queries don't use GROUP BY correctly under these restrictions.

@Alanaktion Alanaktion added the bug label Apr 9, 2019
@Alanaktion Alanaktion self-assigned this Apr 9, 2019
@Alanaktion
Copy link
Owner Author

Alanaktion commented Sep 9, 2019

Example: When a user is in a group and visits /backlog under MySQL 5.7 and higher, this error is triggered:

PDOStatement: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'user_group.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
PHP message: [vendor/bcosca/fatfree-core/db/sql/mapper.php:305] DB\SQL->exec()
PHP message: [vendor/bcosca/fatfree-core/db/sql/mapper.php:345] DB\SQL\Mapper->select()
PHP message: [app/model/user.php:168] DB\SQL\Mapper->find()
PHP message: [app/view/backlog/index.html:32] Model\User->getSharedGroupUserIds()
PHP message: [app/controller.php:73] Preview->render()
PHP message: [app/controller/backlog.php:124] Controller->_render()
PHP message: [index.php:142] Base->run()

This attempts to run this query:

SELECT `id`,`user_id`,`group_id`,`manager` FROM `user_group` WHERE group_id IN (?) GROUP BY `user_id`

The ORM itself is somewhat the problem here, but we can either add id to the grouping, or bypass the default SQL_MODE (which is not ideal), both of which should work fine.

Alanaktion added a commit that referenced this issue Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant