Uploaded image for project: 'In-Portal CMS'
  1. In-Portal CMS
  2. INP-558

SQL Error during usage of "Re-build Multilanguage Fields" functionality

    XMLWordPrintable

    Details

    • Type: Bug Report
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.3-B2
    • Fix Version/s: 5.1.1-B1
    • Component/s: Database
    • Labels:
      None
    • Additional information:
      Hide

      In global scale phpMyAdmin displays "None", when "DEFAULT ..." statement was omitted during table creation/column adding. When we have default value, then it is used. When we don't have default value, then default value will be:

      • NULL for fields, that can be NULL
      • empty string for textual fields
      • 0 for numeric fields

      We need to updated following places to reflect that:

      • remove "DEFAULT ..." statement from "install_schema.sql" file, when it matches default value auto-assigned from previous list
      • update unit config validator to support ommited "DEFAULT ..." statements
      • update translatable field auto-creator (partially what Sergey posted) to skip "DEFAULT ..." in ALTER TABLE statements, when field's default value matches the one, that MySQL will use automatically

      This all can be successfully done based on DESCRIBE results. Omitted "DEFAULT ..." statement is shown differently on DESCRIBE sql only since 5.x version of MySQL. Although omitted "DEFAULT ..." statement was allowed in 4.x version of MySQL too, but DESCRIBE showed actual default value, what MySQL will use for NOT NULL fields and not NULL as 5.x MySQL does.

      Show
      In global scale phpMyAdmin displays "None", when "DEFAULT ..." statement was omitted during table creation/column adding. When we have default value, then it is used. When we don't have default value, then default value will be: NULL for fields, that can be NULL empty string for textual fields 0 for numeric fields We need to updated following places to reflect that: remove "DEFAULT ..." statement from "install_schema.sql" file, when it matches default value auto-assigned from previous list update unit config validator to support ommited "DEFAULT ..." statements update translatable field auto-creator (partially what Sergey posted) to skip "DEFAULT ..." in ALTER TABLE statements, when field's default value matches the one, that MySQL will use automatically This all can be successfully done based on DESCRIBE results. Omitted "DEFAULT ..." statement is shown differently on DESCRIBE sql only since 5.x version of MySQL. Although omitted "DEFAULT ..." statement was allowed in 4.x version of MySQL too, but DESCRIBE showed actual default value, what MySQL will use for NOT NULL fields and not NULL as 5.x MySQL does.
    • External issue ID:
      707
    • Copy Issue Key:
    • Patch Instructions:

      Patches must be submitted through Phabricator.

      Description

      In MySQL 5.x versions output format of "DESCRIBE" sql statement has changed. In particular it returns "NULL" instead of default column value even for "NOT NULL" fields, that were added to table without specifying actual default value.

      That have raised a problem in 3 system places:
      1. unit config "Fields" array validator (enable "DBG_VALIDATE_CONFIGS" in "debug.php" and press "Reset Configs Cache" in "System Tools" section.
      2. unit config "Fields" array builder (enter table name into "Table Structure" input in "System Tools" section and press "Run" near it)
      3. "Re-build Multilanguage Fields" functionality (button in "System Tools" section).

      In all mentioned above places NOT NULL fields can have NULL as default value and this can lead to SQL fatal error.

      For items "1." and "2." I propose to guess default value using following rule:

      • NULL for fields, that can be NULL
      • empty string for textual fields
      • 0 for numeric fields

      For "3." item I propose to omit "DEFAULT ..." statement from "ALTER TABLE ..." database query when we have retrieved "NULL" as default value for "NOT NULL" field.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                alex Alex
                Developer:
                Alex
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: