Closed drgrice1 closed 8 months ago
Note that I have tested that this works with the MariaDB
database and both the DBD::MariaDB
and DBD::mysql
interface drivers. Although the current code also works with both of those configurations. What is needed is for someone to test this with mysql
, and see if they can reproduce the issue with the develop branch (or main), and if this pull request fixes the issue.
Update on testing this.
I built a docker image that uses mysql 8.0 with the DBD:mysql
interface driver and the current develop branch. With that build I was able to reproduce the issue. I created a test, and upon opening the overview page for that test I get the error DBD::mysql::st execute failed: Column 'set_id' in order clause is ambiguous at /opt/webwork/webwork2/lib/WeBWorK/DB/Schema/NewSQL/Std.pm line 930.
I then rebuilt the docker image switching to the branch for this pull request, and the error did not occur.
So this is the correct fix. I recommend the hotfix be considered.
It is becoming increasingly difficult to support using mysql, particularly since all of the active webwork2 developers have now switched to using MariaDB.
In
WeBWorK::ContentGenerator::Instructor::UserDetail
andWeBWorK::ContentGenerator::Instructor::ProblemSet
I usedq{(SUBSTRING(set_id,INSTR(set_id,',v')+2)+0)}
for the order by clause ingetMergedSetVersionsWhere
calls. The problem is thatgetMergedSetVersionsWhere
performs an inner join on the row from theuser_set
table that is the user's versioned set, the row from that same table that is the user's template set, and the global template set from theset
tabel. Apparently some database configurations are lenient and assume the first table, but others do not.So this replaces that with
grok_versionID_from_vsetID_sql($db->{set_version_merged}->sql->_quote('set_id'))
. The_quote
call ensures that theset_id
column is selected from the primary table (the row that is the user's versioned set) since it is passed through thetransform_all
method ofWeBWorK::DB::Schema::NewSQL::Merge
.This will most likely fix #2341. Although I am can't (easily) test this, and can't reproduce the issue reported there. I suspect that this occurs when
mysql
is used instead ofMariaDB
. I suspect thatMariaDB
is more lenient on this.