Moodle
  1. Moodle
  2. MDL-35270

Column ambiguously defined when adding users to cohort

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.1, 2.4
    • Fix Version/s: 2.3.3
    • Component/s: Cohorts
    • Labels:
      None
    • Rank:
      43925

      Description

      When adding more than one user to a cohort (via CSV or directly from the form), the following error is displayed:

      Debug info: ORA-00918: column ambiguously defined
      SELECT e.*, r.id as roleexists
      FROM m2enrol e
      LEFT JOIN m2role r ON (r.id = e.roleid)
      WHERE customint1 = :o_cohortid AND enrol = 'cohort'
      ORDER BY id ASC
      [array (
      'o_cohortid' => '21',
      )]
      Error code: dmlreadexception
      Stack trace:
      line 407 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 274 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->query_end()
      line 1101 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()
      line 56 of /enrol/cohort/locallib.php: call to oci_native_moodle_database->get_records_sql()
      line ? of unknownfile: call to enrol_cohort_handler::member_added()
      line 299 of /lib/eventslib.php: call to call_user_func()
      line 519 of /lib/eventslib.php: call to events_dispatch()
      line 142 of /cohort/lib.php: call to events_trigger()
      line 786 of /admin/tool/uploaduser/index.php: call to cohort_add_member()

      Database: Oracle

        Activity

        Hide
        Sara Arjona added a comment -

        To fix the problem it's necessary to edit the function member_added($ca) in the file enrol/cohort/locallib.php and modify the following SQL to specify the "ORDER BY" column (line 51):

        $sql = "SELECT e.*, r.id as roleexists
        FROM

        {enrol}

        e
        LEFT JOIN

        {role}

        r ON (r.id = e.roleid)
        WHERE customint1 = :cohortid AND enrol = 'cohort'
        ORDER BY e.id ASC";

        Show
        Sara Arjona added a comment - To fix the problem it's necessary to edit the function member_added($ca) in the file enrol/cohort/locallib.php and modify the following SQL to specify the "ORDER BY" column (line 51): $sql = "SELECT e.*, r.id as roleexists FROM {enrol} e LEFT JOIN {role} r ON (r.id = e.roleid) WHERE customint1 = :cohortid AND enrol = 'cohort' ORDER BY e.id ASC";
        Hide
        Petr Škoda added a comment -

        Thanks for the report and patch.

        Show
        Petr Škoda added a comment - Thanks for the report and patch.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Integrated (23 and master), thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Integrated (23 and master), thanks!
        Hide
        David Monllaó added a comment -

        It passes, tested in master with Oracle 10g (10.2.0.1.0 express edition)

        Show
        David Monllaó added a comment - It passes, tested in master with Oracle 10g (10.2.0.1.0 express edition)
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio

        This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads).

        Thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads). Thanks!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: