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

Update SQL does not work on SQL Server #49

Closed
matthias-gass opened this issue Oct 7, 2022 · 1 comment
Closed

Update SQL does not work on SQL Server #49

matthias-gass opened this issue Oct 7, 2022 · 1 comment

Comments

@matthias-gass
Copy link

Ladies and Gents,

the report coursesize plugin relies on the moodle cron job to do the calculation of course file sizes. During execution of the moodle cron job an update statement is executed that is derived from the following sql template found in the file moodle\report\coursesize\classes\task\report_async.php:

$sql = "UPDATE {report_coursesize} rc
SET backupsize = (SELECT bf.filesize FROM ($basesql) bf WHERE bf.course = rc.course)";

SQL Server cannot execute this statement because an alias on the update table (here: "rc") is not allowed in this dialect and hence course size cannot persisted in the database. As a quick fix I implemented the following solution which works on SQL Server. However I did not test whether this works with the other db providers.

$sql = "UPDATE {report_coursesize} 
SET backupsize = (SELECT bf.filesize FROM ($basesql) bf WHERE bf.course = {report_coursesize}.course)";

I'm using Release 4.2

Best regards
Matthias

@danmarsden
Copy link
Member

Duplicates #39

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

No branches or pull requests

2 participants