Fix issues when the sql_mode includes the only_full_group_by setting. #2805
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If
only_full_group_by
is included in thesql_mode
mysql settings, then attempting to view problems in the library browser results in an exception with a message likeDBD::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 theOPL_pgfile
table that are selected in theGROUP 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 groupedfilepath
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
in the
/etc/mysql/conf.d/mysql.cnf
file and executesudo systemctl restart msyql
. With the shown value forsql_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 ifONLY_FULL_GROUP_BY
is removed. At least that is the case on my system. You can executeselect @@sql_mode
in mysql to see what the settings are for your system. The default for MySQL does includeONLY_FULL_GROUP_BY
(at least if I am reading things right).