Bug in unit tests with constraints in mysql

Bug #1810427 reported by Marie-Eve Lévesque
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned

Bug Description

Mahara version : 18.10
Database : MySQL

The unit tests fail to execute when using MySQL, because of an sql error due to constraints ("DROP CONSTRAINT" is not supported in MySQL).

In htdocs/testing/classes/util.php, I think that the following line
execute_sql('ALTER TABLE {lti_assessment} DROP CONSTRAINT {ltiasse_oau_fk}');

should be replaced by
if (is_mysql()) {
    execute_sql('ALTER TABLE {lti_assessment} DROP FOREIGN KEY {ltiasse_oau_fk}');
}
else {
    execute_sql('ALTER TABLE {lti_assessment} DROP CONSTRAINT {ltiasse_oau_fk}');
}

and
execute_sql('ALTER TABLE {collection} DROP CONSTRAINT {coll_fra_fk}');

should be
if (is_mysql()) {
    execute_sql('ALTER TABLE {collection} DROP FOREIGN KEY {coll_fra_fk}');
}
else {
    execute_sql('ALTER TABLE {collection} DROP CONSTRAINT {coll_fra_fk}');
}

The same logic is already used in the same file for other contraints. Maybe some indexes should be dropped also, not only the foreign key.

Changed in mahara:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/9399

Changed in mahara:
status: Confirmed → In Progress
milestone: none → 19.04.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/9399
Committed: https://git.mahara.org/mahara/mahara/commit/dae3023da7706ae29170c1f856f560663d476316
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit dae3023da7706ae29170c1f856f560663d476316
Author: Marie-Eve L��vesque <email address hidden>
Date: Tue Jan 8 11:20:34 2019 +1300

Bug 1810427: constraint drop fails in MySQL in unit testing

behatnotneeded

Change-Id: I72c2ce1f592f316c591583e7e3020f6e9c5d380e

Robert Lyon (robertl-9)
Changed in mahara:
status: In Progress → Fix Committed
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.