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

xmldb does not generate correct code for foreign-unique key

    XMLWordPrintable

Details

    • MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_20_STABLE, MOODLE_21_STABLE
    • 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.
    • 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)

    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

            stronk7 Eloy Lafuente (stronk7)
            quen Sam Marshall
            Sam Hemelryk Sam Hemelryk
            Aparup Banerjee Aparup Banerjee
            Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              28/Nov/11