Skip to content

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Sep 8, 2025

If only_full_group_by is included in the sql_mode mysql settings, then attempting to view problems in the library browser results in an exception with a message like DBD::MariaDB::db selectall_arrayref failed: 'webwork.pgf.morelt_id' isn't in GROUP BY at /opt/webwork/webwork2/lib/WeBWorK/DB/Database.pm line 137.

This just adds a MAX call to the columns of the OPL_pgfile table that are selected in the GROUP BY call, and eliminates the exception. The resulting data that is returned in the query is the same as before since these columns will all hold the same data for the grouped filepath results. This is really just working around poor design in the OPL table structure.

This has been noted a few times in the forums recently. See, for instance, the latest posts in https://forums.openwebwork.org/mod/forum/discuss.php?d=8757#p22352.

To test this set

sql_mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

in the /etc/mysql/conf.d/mysql.cnf file and execute sudo systemctl restart msyql. With the shown value for sql_mode and the develop or main branches you will get the exception when you try to view problems in the library browser, but will not with this pull request.

Note that the value for sql_mode above seems to be the default for MariaDB if ONLY_FULL_GROUP_BY is removed. At least that is the case on my system. You can execute select @@sql_mode in mysql to see what the settings are for your system. The default for MySQL does include ONLY_FULL_GROUP_BY (at least if I am reading things right).

@drgrice1 drgrice1 force-pushed the fix-only-full-group-by-errors branch from bd5c742 to 7b0141e Compare September 8, 2025 21:59
Copy link
Member

@pstaabp pstaabp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and this fixes the error posted.

@drgrice1 drgrice1 force-pushed the fix-only-full-group-by-errors branch 2 times, most recently from 44a7585 to 7e07ac5 Compare September 9, 2025 20:33
@drgrice1 drgrice1 force-pushed the fix-only-full-group-by-errors branch from 7e07ac5 to ffab6e8 Compare September 16, 2025 20:46
If `only_full_group_by` is included in the `sql_mode` mysql settings,
then attempting to view problems in the library browser results in an
exception with a message like `DBD::MariaDB::db selectall_arrayref
failed: 'webwork.pgf.morelt_id' isn't in GROUP BY at
/opt/webwork/webwork2/lib/WeBWorK/DB/Database.pm line 137.`

This just adds a `MAX` call to the columns of the `OPL_pgfile` table
that are selected in the `GROUP BY` call, and eliminates the exception.
The resulting data that is returned in the query is the same as before
since these columns will all hold the same data for the grouped
`filepath` results.  This is really just working around poor design in
the OPL table structure.

This has been noted a few times in the forums recently.  See, for
instance, the latest posts in
https://forums.openwebwork.org/mod/forum/discuss.php?d=8757#p22352.

To test this set

```
sql_mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
```

in the `/etc/mysql/conf.d/mysql.cnf` file and execute `sudo systemctl restart msyql`.
With the shown value for `sql_mode` and the develop or main branches you
will get the exception when you try to view problems in the library
browser, but will not with this pull request.

Note that the value for `sql_mode` above seems to be the default for
MariaDB if `ONLY_FULL_GROUP_BY` is removed. At least that is the case on
my system.  You can execute `select @@sql_mode` in mysql to see what the
settings are for your system.  The default for MySQL does include
`ONLY_FULL_GROUP_BY` (at least if I am reading things right).
@drgrice1 drgrice1 force-pushed the fix-only-full-group-by-errors branch from ffab6e8 to a00d70a Compare September 23, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants