Fill in the missing "key_exists()" method in ddl.php

Bug #1255378 reported by Aaron Wells on 2013-11-27
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Medium
Aaron Wells
1.8
Medium
Unassigned
1.9
Medium
Aaron Wells

Bug Description

For bug 1081947 we want to check whether some keys exist on certain tables in the database. We have an "index_exists" and "find_index_name" function in ddl.php to check for whether indexes exist, but just some TODO's in the corresponding "find_key_name" method.

Aaron Wells (u-aaronw) wrote :

Here's the test file I used to test whether the script worked properly for some existing Mahara primary keys, foreign keys, and unique keys. Although the XMLDB library also defines an XMLDB_KEY_FOREIGN_UNIQUE type, there aren't actually any keys of that type in Mahara, so I left that test out.

Hm, and actually, the keys in my test script are ones that were added for https://bugs.launchpad.net/mahara/+bug/1081947 . So you'll have to install patch https://reviews.mahara.org/#/c/2744/ before the test will all work correctly.

Reviewed: https://reviews.mahara.org/2753
Committed: http://gitorious.org/mahara/mahara/commit/3385efa8a822069c3a5c10e2586c7db872832b2c
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 3385efa8a822069c3a5c10e2586c7db872832b2c
Author: Aaron Wells <email address hidden>
Date: Wed Nov 27 15:14:41 2013 +1300

Fill in the missing implementation for find_key_name()

Bug #1255378

This fundamentally changes the behavior of find_key_name(). Before, it only generated what the default name for the key would be, now it actually checks whether a key of that description exists in the DB and returns its actual name in the DB.

In core the method was only used by XMLDBGenerator in the methods for dropping or altering a key, so this change will actually make it more robust.

In theory, though, if there is third-party code relying on the current behavior of find_key_name(), they could have problems.

Change-Id: I0470422a6e6514af98beb83e884178ee7f341ccd

Aaron Wells (u-aaronw) on 2013-12-16
Changed in mahara:
status: In Progress → Fix Committed
Aaron Wells (u-aaronw) wrote :
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/2813
Committed: http://gitorious.org/mahara/mahara/commit/6d784d9245cbfe340910cbd3ab46e36f562060d6
Submitter: Aaron Wells (<email address hidden>)
Branch: 1.8_STABLE

commit 6d784d9245cbfe340910cbd3ab46e36f562060d6
Author: Aaron Wells <email address hidden>
Date: Wed Nov 27 15:14:41 2013 +1300

Fill in the missing implementation for find_key_name()

Bug #1255378

This fundamentally changes the behavior of find_key_name(). Before, it only generated what the default name for the key would be, now it actually checks whether a key of that description exists in the DB and returns its actual name in the DB.

In core the method was only used by XMLDBGenerator in the methods for dropping or altering a key, so this change will actually make it more robust.

In theory, though, if there is third-party code relying on the current behavior of find_key_name(), they could have problems.

Change-Id: I0470422a6e6514af98beb83e884178ee7f341ccd

Aaron Wells (u-aaronw) wrote :

Even though this is technically a "new feature", I'm backporting it to 1.8 so that it can be used in https://bugs.launchpad.net/bugs/1081947 , to correct schema drift in Mahara sites upgraded from 1.0

Aaron Wells (u-aaronw) on 2013-12-18
Changed in mahara:
status: Fix Committed → Fix Released
Robert Lyon (robertl-9) on 2014-04-22
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