This issue was originally part of that reported by @thiftyngreen in #1058846: Schema

Currently Schema flags a warning on primary key columns that do not explicitly set not null or set not null to FALSE, blogapi_files is one example where there isn't a 'not null' directive set...

Schema also flags a mismatch for columns such as blogapi_files.fid since the inspected database reports the column not null.

So whilst it might look like a small fix is needed to the blogapi_files schema definition, schema API (http://api.drupal.org/api/drupal/includes--database.inc/group/schemaapi/6) designates not null as optional. This is fine for primary key columns because of the way MySQL and PostgreSQL treat them:

From http://dev.mysql.com/doc/refman/5.1/en/create-table.html

A PRIMARY KEY is a unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently).

So at the very least I think it's questionable whether we should be raising a warning where there isn't a 'not null' directive on primary key columns as in the case of blogapi_files.fid and it also makes no sense to flag a mismatch when the column is compared with the database.

The attached patch adds 'not null' = TRUE to PRIMARY KEY columns for the sake of comparison against the database, it also removes the warning that occurs when a 'not null' directive has been omitted on a primary key column.

CommentFileSizeAuthor
#1 schema-not-null-warning-1060502.patch1.51 KBmatason
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

matason’s picture

Status: Active » Needs review
FileSize
1.51 KB

Attaching the patch.

jcnventura’s picture

Status: Needs review » Closed (outdated)

Versions 6.x of the module are no longer supported.