diff options
author | Brion Vibber <brion@pobox.com> | 2010-10-07 17:22:36 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-10-07 17:22:36 -0700 |
commit | 85156fcbed81b8e3e9d7ca4d3755df5c6c5b44a2 (patch) | |
tree | b509263b4b74fa30479ed83b42d43806abf4ac8d /lib | |
parent | 3c979ec5068ed342fe4fed66c7310923c770793e (diff) |
Fix detection of auto_increment fields in MySQL (sets them as 'serial' type)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mysqlschema.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/mysqlschema.php b/lib/mysqlschema.php index d3b463c10..e4d91ffa0 100644 --- a/lib/mysqlschema.php +++ b/lib/mysqlschema.php @@ -134,12 +134,15 @@ class MysqlSchema extends Schema $field['description'] = $row['COLUMN_COMMENT']; } - // $row['EXTRA'] may contain 'autoincrement' - // ^ type=serial? - // $row['EXTRA'] may contain 'on update CURRENT_TIMESTAMP' - // ^ ...... how to specify? - // these seem to be the only values in curent use - + $extra = $row['EXTRA']; + if ($extra) { + if (preg_match('/(^|\s)auto_increment(\s|$)/i', $extra)) { + $field['type'] = 'serial'; + } + // $row['EXTRA'] may contain 'on update CURRENT_TIMESTAMP' + // ^ ...... how to specify? + } + if ($row['CHARACTER_SET_NAME'] !== null) { // @fixme check against defaults? //$def['charset'] = $row['CHARACTER_SET_NAME']; |