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

Bug #1255378 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Aaron Wells
1.8
Fix Released
Medium
Unassigned
1.9
Fix Released
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.

Tags: api ddl
Revision history for this message
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.

Revision history for this message
Aaron Wells (u-aaronw) wrote :
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

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)
Changed in mahara:
status: In Progress → Fix Committed
Revision history for this message
Aaron Wells (u-aaronw) wrote :
Revision history for this message
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

Revision history for this message
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)
Changed in mahara:
status: Fix Committed → Fix Released
Robert Lyon (robertl-9)
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.