Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-42703

Getting course sort order fails under MSSQL

XMLWordPrintable

    • MOODLE_26_STABLE
    • MOODLE_26_STABLE
    • wip-mdl-42703-master
    • Hide

      Requires testing across multiple DBs including MSSQL.

      1. Run course-related unit tests (phpunit core_course_courselib_testcase course\tests\courselib_test.php)
      2. Watch your web server error logs in the console while performing these steps.
      3. Log in as an admin
      4. Browse to the course management interface.
      5. Select a category with at least 3 courses in it.
      6. Drag the bottom course up so that it is above the top course.
      7. Refresh the page and make sure it worked.
      8. Drag the top course back to the bottom.
      9. Refresh the page and make sure it worked.
      10. Try resorting courses.
      Show
      Requires testing across multiple DBs including MSSQL. Run course-related unit tests (phpunit core_course_courselib_testcase course\tests\courselib_test.php) Watch your web server error logs in the console while performing these steps. Log in as an admin Browse to the course management interface. Select a category with at least 3 courses in it. Drag the bottom course up so that it is above the top course. Refresh the page and make sure it worked. Drag the top course back to the bottom. Refresh the page and make sure it worked. Try resorting courses.

      The following error is reported when running unit tests under MSSQL...

      2) core_course_courselib_testcase::test_course_change_sortorder_after_course
      dml_write_exception: Error writing to database (SQLState: 42000<br>
      Error Code: 102<br>
      Message: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax
      near 'c'.<br>
       
      UPDATE phpu_course c
                             SET sortorder = sortorder + 1
                           WHERE c.category = '2'
                             AND sortorder > '20003'
      [array (
        0 => '2',
        1 => '20003',
      )])
       
      D:\xampp\htdocs\master_integration\lib\dml\moodle_database.php:444
      D:\xampp\htdocs\master_integration\lib\dml\sqlsrv_native_moodle_database.php:245
       
      D:\xampp\htdocs\master_integration\lib\dml\sqlsrv_native_moodle_database.php:352
       
      D:\xampp\htdocs\master_integration\lib\dml\sqlsrv_native_moodle_database.php:743
       
      D:\xampp\htdocs\master_integration\course\lib.php:3469
      D:\xampp\htdocs\master_integration\course\tests\courselib_test.php:2241
      D:\xampp\htdocs\master_integration\lib\phpunit\classes\advanced_testcase.php:80
       
      To re-run:
       \xampp\php\phpunit core_course_courselib_testcase course\tests\courselib_test.php
      

      In the function course_change_sortorder_after_course() there are a number of raw DB calls (I'm not sure why this was allowed). In each of the queries an alias is used for the table, however MSSQL seems to dislike this alias syntactically. As there is only a single table involved in each query the alias is not needed and can be removed. When it is removed, the queries work in MSSQL.

            salvetore Michael de Raadt
            salvetore Michael de Raadt
            Sam Hemelryk Sam Hemelryk
            Damyon Wiese Damyon Wiese
            Dan Poltawski Dan Poltawski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.