If table has an unsigned float with no size set then the resulting generated schema array has the precision and scale fields as blanks. This generates a mysql error on installation of the schema.

After creating a table with FLOATs as two fields (one was unsigned and one was signed) I noticed that the unsigned FLOAT was being set improperly by the schema module. The Schema module kept trying to set precision and scale but without setting any value to them.

column score - differences on: scale, precision
declared: array('description' => t('TODO: please describe this field!'), 'type' => 'float', 'unsigned' => TRUE, 'not null' => TRUE)
actual: array('description' => t('TODO: please describe this field!'), 'type' => 'float', 'unsigned' => TRUE, 'not null' => TRUE, 'precision' => '', 'scale' => '')

Comments

Kevin Rogers’s picture

StatusFileSize
new737 bytes

I've just run into the same issue.:

column yield - differences on: scale, precision
declared: array('description' => t('TODO: please describe this field!'), 'type' => 'float', 'unsigned' => TRUE, 'not null' => TRUE)
actual: array('description' => t('TODO: please describe this field!'), 'type' => 'float', 'unsigned' => TRUE, 'not null' => TRUE, 'precision' => '', 'scale' => '')

There seems to be a missing test to check if a numeric/float/double column has a precision.

The attached patch corrects the problem for me.

alive2000’s picture

This bug present in 7.x-1.0-beta3 too. Only with unsigned floats.

greggles’s picture

Version: 6.x-1.7 » 7.x-1.x-dev
Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Updating to 7.x-1.x-dev based on comment #2. Is this still relevant in the latest dev? Marking needs more information to answer that question.

jayelless’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.88 KB

I have found this problem on an install of Drupal Commons in the radioactivity module. The Schema report advises that the energy column of the radioactivity_history table differs in precision and scale.

I have taken a different approach to that in comment 2 and generated a patch that addresses the issue of a column attribute key that is neither NULL nor FALSE but is an empty string by adding a test for an empty value in the relevant part of the code.

I have also taken the opportunity to re-format the complex if statement to make it easier to understand.

Patch attached.

jayelless’s picture

StatusFileSize
new1.83 KB

Woops! There was a test in the if statement that should not have been there. I have now removed it and re-rolled the patch.