From 85156fcbed81b8e3e9d7ca4d3755df5c6c5b44a2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 7 Oct 2010 17:22:36 -0700 Subject: [PATCH] Fix detection of auto_increment fields in MySQL (sets them as 'serial' type) --- lib/mysqlschema.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/mysqlschema.php b/lib/mysqlschema.php index d3b463c103..e4d91ffa07 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']; -- 2.39.5