Details
-
Improvement
-
Resolution: Unresolved
-
Medium
-
None
-
2011.9
-
None
Description
Currently, when creating the db_schema.dba from a MySQL table (but same thing for all other dbs), that contains an auto increment field with a type different than integer, so for example: tinyint, smallint, mediumint, bigint
the type is lost, and just integer will be used on next load of this db_schema.dba
Here is an export of such a table (just an extract of a db_schema.dba):
[...] 'djrefs_types' => array ( 'name' => 'djrefs_types', 'fields' => array ( 'id' => array ( 'type' => 'auto_increment', 'default' => false, ), [...]
It comes from the fact, the type, that usually contains the type of field (logic is perfect), is also used to say if the field is auto_increment (and then we loose the real type)
However, it's 2 different things: a field can have a type (tinyint, smallint, etc..), and 'also' can be auto increment (or not)
So why not have an export that just activate a new attribute in the array that says: 'auto_increment' => true ?, and leave the type untouched
the extract of the export would be then:
[...] 'djrefs_types' => array ( 'name' => 'djrefs_types', 'fields' => array ( 'id' => array ( 'length' => 3, 'type' => 'tinyint', 'auto_increment' => true, 'default' => false, ), [...]
The patch to perform this is quite easy I think, and can be done for all dbs. Because the part that needs to be patched exist (roughtly) in the same form for all dbs:
if ( $autoinc ) { unset( $field['length'] ); $field['not_null'] = 0; $field['default'] = false; $field['type'] = 'auto_increment'; }
On Oracle:
if ( $isAutoIncCol ) { $field['type'] = 'auto_increment'; $field['default'] = false; }