]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix detection of auto_increment fields in MySQL (sets them as 'serial' type)
authorBrion Vibber <brion@pobox.com>
Fri, 8 Oct 2010 00:22:36 +0000 (17:22 -0700)
committerBrion Vibber <brion@pobox.com>
Fri, 8 Oct 2010 00:22:36 +0000 (17:22 -0700)
lib/mysqlschema.php

index d3b463c1039d0d4e0f0c1f2c99f1485918f91ec7..e4d91ffa07ec1a8cc6080a07bedeaad8b713ba5e 100644 (file)
@@ -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'];