moodleou / moodle-mod_ouwiki

Alternative wiki module for Moodle 2 (designed for use in teaching and learning)
36 stars 32 forks source link

ORA-00918: column ambiguously defined #78

Closed rbonatuvic closed 6 years ago

rbonatuvic commented 6 years ago

77

Debug info: ORA-00918: column ambiguously defined SELECT * FROM (SELECT v.id, v.timecreated, v.userid, u.id AS userid,u.picture,u.firstname,u.lastname,u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.imagealt,u.email FROM m_ouwiki_versions v LEFT JOIN m_user u ON v.userid = u.id WHERE v.pageid = :o_param1 AND v.timecreated <= :o_param2 AND v.deletedat IS NULL ORDER BY v.id DESC) WHERE rownum <= :o_oracle_num_rows [array ( 'o_param1' => '61', 'o_param2' => '1533230149', 'o_oracle_num_rows' => 3, )] Error code: dmlreadexception

This results from the renaming of the user id field to userid which is a field name already used by another table. An example from line 694 in locallib.php:

$userfields = user_picture::fields('u', null, 'userid');

    $sql = "SELECT p.id AS pageid, p.subwikiid, p.title, p.currentversionid, p.firstversionid,
                p.locked, v.id AS versionid, v.xhtml, v.timecreated, v.userid, v.xhtmlformat,
                v.wordcount, v.previousversionid, $userfields
            FROM {ouwiki_pages} p
            $jointype {ouwiki_versions} v ON p.currentversionid = v.id
            LEFT JOIN {user} u ON v.userid = u.id
            WHERE p.subwikiid = ? AND $pagename_s";

userfields will have u.userid and the existing list includes v.userid resulting in two fields with the same name and ORA-00918 is the result.

jason-platts commented 6 years ago

Thanks for the fix...- will turn up in Master branch on our next update.