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

Allow DEFAULT NULL clause in CHAR columns

XMLWordPrintable

    • MOODLE_39_STABLE
    • MDL-69821-master
    • Hide
      • Define a database table with a CHAR column allowing null values and no default in your db/install.xml file. In the top XMLDB element, add the ALLOWDEFAULTNULLCHAR="true" attribute.
      • Install the database using a fresh install (upgrades don't read this file).
      • Insert a row without providing a value for this column. It should work creating a row where this column's value is NULL, before this patch it would be initialized with an empty string.
      Show
      Define a database table with a CHAR column allowing null values and no default in your db/install.xml file. In the top XMLDB element, add the ALLOWDEFAULTNULLCHAR="true" attribute. Install the database using a fresh install (upgrades don't read this file). Insert a row without providing a value for this column. It should work creating a row where this column's value is NULL, before this patch it would be initialized with an empty string.

      As described in MDL-9658, the way databases are created at the moment it's not possible to create a CHAR column that uses the DEFAULT NULL clause. Instead, those columns are declared as DEFAULT '', which is misleading when those columns are defined using NOTNULL="false".

      The ideal situation would be to allow declarations such as the following to work as expected:

      <FIELD NAME="name" TYPE="char" LENGTH="100" NOTNULL="false" SEQUENCE="false"/>

      And use the following if the desired outcome is the DEFAULT '' clause:

      <FIELD NAME="name" TYPE="char" LENGTH="100" NOTNULL="true" DEFAULT="" SEQUENCE="false"/>

      However, doing this change now would break a lot of existing code, so this must be implemented as an opt-in first. Later on, this can be changed to opt-out. Eventually, this behavior could be deprecated entirely.

            jleyva Juan Leyva
            noeldemartin Noel De Martin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 40 minutes
                40m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.