Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-29668

xmldb does not generate correct code for foreign-unique key

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      1. Edit an xmldb file.
      2. Go in and edit a table (you will need one with an id-ish field that doesn't already have an index on it).
      3. Add a key.
      4. Choose foreign-unique type. Enter the name of the field in the current table, and details of another table such as id field in course_sections. Save the form.
      5. Click 'View php code', choose 'Add key' and select the key

      Check that the generated code includes the constant XMLDB_FOREIGN_UNIQUE and includes the details of the other table (course_sections, id)

      Show
      1. Edit an xmldb file. 2. Go in and edit a table (you will need one with an id-ish field that doesn't already have an index on it). 3. Add a key. 4. Choose foreign-unique type. Enter the name of the field in the current table, and details of another table such as id field in course_sections. Save the form. 5. Click 'View php code', choose 'Add key' and select the key Check that the generated code includes the constant XMLDB_FOREIGN_UNIQUE and includes the details of the other table (course_sections, id)
    • Workaround:
      Hide

      To get correct code, copy the code used for generating a normal foreign key and edit XMLDB_KEY_FOREIGN to XMLDB_KEY_FOREIGN_UNIQUE.

      Show
      To get correct code, copy the code used for generating a normal foreign key and edit XMLDB_KEY_FOREIGN to XMLDB_KEY_FOREIGN_UNIQUE.
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      If you add a foreign-unique key (normally used for 1:1 relationships), this is correctly stored in the install.xml, but if you get xmldb to generate the php code, it is incorrect.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                28/Nov/11