'length' parameter is supported by MySQL for 'int' type, and the documentation as well mentions this,
'length': The maximal length of a type 'varchar', 'text' or 'int' field. Ignored for other field types.
But, it isn't working. I can confirm this problem on both Windows and CentOS with mysql version 5.1. I think the problem resides in the function _db_create_field_sql:
function _db_create_field_sql($name, $spec) {
$sql = "`". $name ."` ". $spec['mysql_type'];
if (in_array($spec['type'], array('varchar', 'char', 'text')) && isset($spec['length'])) {
$sql .= '('. $spec['length'] .')';
}
Clearly, 'length' parameter is ignored for the 'int' type. Including 'int' in the above array solves the problem.
Comments
Comment #1
klonossubscribing...
Comment #2
damien tournoud commentedThis parameter is of no use at all for numeric types. Let's just fix the documentation.
Comment #3
damien tournoud commented7.x is already fixed:
Bumping for fixing in 6.x.
Comment #4
publicmind commentedI do not agree with the generality of your statement. Of course 'length' parameter makes sense and that's why it exists for numeric type on all major databases.
Regards,
Comment #5
damien tournoud commented@publicmind: AFAIK, that parameter is not used anywhere in the MySQL server code. It's just supposedly useful for some clients. It is completely and utterly useless with Drupal.
Comment #6
damien tournoud commentedAnd by the way, PostgreSQL doesn't have that concept of 'length' at all. Don't confuse size for length.