Remove semantically incorrect default values

Created on 14 July 2007, about 17 years ago
Updated 22 May 2024, 4 months ago

In the "making our database squeaky-clean" department:

The core schema has default values all over the place that make no sense. For example:

function node_schema() {
  $schema['node'] = array(
    'fields' => array(
      'nid'       => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
      'vid'       => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'default' => 0),
      'type'      => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),

node.type can never correctly be the empty string. node.vid can never correctly be 0. It is possible that node.vid needs to be 0 or some other temporary value while the node_revisions row is being created (since either node or node_revisions needs to come first, one column will always need a temp value), but that still doesn't mean that a "default value" of 0 is correct.

Having these incorrect default values works fine, of course, but it is semantically misleading. I'm pretty sure many of them are there because of MySQL's rather broken (IMHO) "implicit default values" behavior (http://drupal.org/node/159330) to make otherwise invaid queries work on pgsql.

Cleaning this up is straightforward. Remove the invalid default values, and any INSERT queries that rely on them will pop out during pgsql testing; they are then easy to fix. I suggest that these be considered bugs and fixed for D6, but if someone wants to tell me this is inappropriate during code freeze, I'm fine with pushing this to D7.

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
DatabaseΒ  β†’

Last updated less than a minute ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡ΊπŸ‡ΈUnited States bjaspan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    And now there are 13 files

    $ grep -r "'default' => " core/modules/*/*.install | awk -F: '{print $1}' | sort -u | nl
         1  core/modules/ban/ban.install
         2  core/modules/comment/comment.install
         3  core/modules/dblog/dblog.install
         4  core/modules/file/file.install
         5  core/modules/help/help.install
         6  core/modules/history/history.install
         7  core/modules/layout_builder/layout_builder.install
         8  core/modules/locale/locale.install
         9  core/modules/node/node.install
        10  core/modules/search/search.install
        11  core/modules/shortcut/shortcut.install
        12  core/modules/user/user.install
        13  core/modules/workspaces/workspaces.install
Production build 0.71.5 2024