Moodle
  1. Moodle
  2. MDL-38753

Error in enrolment web service unit test with Oracle

    Details

    • Rank:
      48811

      Description

      The following failure is reported when running unit tests with Oracle (only). I found this error in the current master and 2.4.3+. I assume it has not been introduced by recent changes.

      1) core_enrol_external_testcase::test_get_users_courses
      dml_read_exception: Error reading from database (ORA-00933: SQL command not prop
      erly ended
      SELECT COUNT(*) FROM (SELECT DISTINCT eu2_u.id
                    FROM p_user eu2_u
                  JOIN p_user_enrolments eu2_ue ON eu2_ue.userid = eu2_u.id
      JOIN p_enrol eu2_e ON (eu2_e.id = eu2_ue.enrolid AND eu2_e.courseid = :o_eu2_cou
      rseid)
                 WHERE eu2_u.deleted = 0 AND eu2_u.id <> :o_eu2_guestid) AS enrolledus
      erids
      [array (
        'o_eu2_courseid' => '3',
        'o_eu2_guestid' => '1',
      )])
      
      D:\xampp\htdocs\master_integration\lib\dml\moodle_database.php:426
      D:\xampp\htdocs\master_integration\lib\dml\oci_native_moodle_database.php:272
      D:\xampp\htdocs\master_integration\lib\dml\oci_native_moodle_database.php:1114
      D:\xampp\htdocs\master_integration\lib\dml\moodle_database.php:1401
      D:\xampp\htdocs\master_integration\lib\dml\oci_native_moodle_database.php:1048
      D:\xampp\htdocs\master_integration\lib\dml\moodle_database.php:1474
      D:\xampp\htdocs\master_integration\lib\dml\moodle_database.php:1645
      D:\xampp\htdocs\master_integration\enrol\externallib.php:320
      D:\xampp\htdocs\master_integration\enrol\tests\externallib_test.php:113
      D:\xampp\htdocs\master_integration\lib\phpunit\classes\advanced_testcase.php:76
      
      To re-run:
       \xampp\php\phpunit core_enrol_external_testcase enrol\tests\externallib_test.php
      

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          Reassigning, I am not responsible for WS code, sorry.

          Show
          Petr Škoda added a comment - Reassigning, I am not responsible for WS code, sorry.
          Hide
          Michael de Raadt added a comment -

          If this is a problem in the Web services and unit tests in Enrolment, then you are responsible for it. If it's a problem with Web services in general, then Jerome could take a look at it, but I don't think that's the case.

          Show
          Michael de Raadt added a comment - If this is a problem in the Web services and unit tests in Enrolment, then you are responsible for it. If it's a problem with Web services in general, then Jerome could take a look at it, but I don't think that's the case.
          Hide
          Petr Škoda added a comment -

          The failing code was written by Jerome and Dongsheng, the Oracle weirdness could be most probably explained by Eloy only, so reassigning to Eloy.

          the problematic code is:

          
                      list($enrolledsqlselect, $enrolledparams) = get_enrolled_sql($context);
                      $enrolledsql = "SELECT COUNT(*) FROM ($enrolledsqlselect) AS enrolleduserids";
                      $enrolledusercount = $DB->count_records_sql($enrolledsql, $enrolledparams);
          
          Show
          Petr Škoda added a comment - The failing code was written by Jerome and Dongsheng, the Oracle weirdness could be most probably explained by Eloy only, so reassigning to Eloy. the problematic code is: list($enrolledsqlselect, $enrolledparams) = get_enrolled_sql($context); $enrolledsql = "SELECT COUNT(*) FROM ($enrolledsqlselect) AS enrolleduserids" ; $enrolledusercount = $DB->count_records_sql($enrolledsql, $enrolledparams);
          Hide
          Petr Škoda added a comment -

          This is very weird, Eloy! why is Oracle doing this?

          Show
          Petr Škoda added a comment - This is very weird, Eloy! why is Oracle doing this?
          Hide
          Eloy Lafuente (stronk7) added a comment -

          (views without AS always, I bet)

          Show
          Eloy Lafuente (stronk7) added a comment - (views without AS always, I bet)
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (23, 24 & master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (23, 24 & master), thanks!
          Hide
          Michael de Raadt added a comment -

          Nicely done.

          Show
          Michael de Raadt added a comment - Nicely done.
          Hide
          Michael de Raadt added a comment -

          Test result: Success!

          Tested on Oracle, MySQL, PostgreSQL and MSSQL.

          Tested in master and 2.4 only (2.3 did not have a corresponding unit test).

          Show
          Michael de Raadt added a comment - Test result: Success! Tested on Oracle, MySQL, PostgreSQL and MSSQL. Tested in master and 2.4 only (2.3 did not have a corresponding unit test).
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Your awesome contributions are now part of Moodle, your fav LMS out there.

          Closing this as fixed.

          Many thanks for all the hard work, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Your awesome contributions are now part of Moodle, your fav LMS out there. Closing this as fixed. Many thanks for all the hard work, ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: