Bug in unit tests with constraints in mysql

Bug #1810427 reported by Marie-Eve Lévesque on 2019-01-03
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
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
Changed in mahara:
status: Confirmed → In Progress
milestone: none → 19.04.0

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) on 2019-01-17
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  Edit
Everyone can see this information.

Other bug subscribers