[Solar-svn] Revision 3210

pmjones at solarphp.com pmjones at solarphp.com
Mon Jun 9 18:50:06 CDT 2008


Solar_Sql_Adapter_Sqlite: [FIX] In fetchTableCols(), when looking for auto-increment column, make quotes around the name optional (to allow for tables created without quoting the name).  Also explain the regex better.


Modified: trunk/Solar/Sql/Adapter/Sqlite.php
===================================================================
--- trunk/Solar/Sql/Adapter/Sqlite.php	2008-06-09 23:29:47 UTC (rev 3209)
+++ trunk/Solar/Sql/Adapter/Sqlite.php	2008-06-09 23:50:06 UTC (rev 3210)
@@ -181,11 +181,13 @@
             list($type, $size, $scope) = $this->_getTypeSizeScope($val['type']);
             
             // find autoincrement column in CREATE TABLE sql.
-            // non-word char, followed by "colname"", followed by "INTEGER
-            // PRIMARY KEY AUTOINCREMENT", followed by non-word char
-            $find = "/\W\"$name\"\s+INTEGER\s+PRIMARY\s+KEY\s+AUTOINCREMENT\W/Ui";
+            $find = "\\b"           // word border
+                  . "\"?$name\"?"   // '"colname"' (quotes optional),
+                  . "\s+INTEGER\s+PRIMARY\s+KEY\s+AUTOINCREMENT"
+                  . "\\b";          // word border
+                  
             $autoinc = preg_match(
-                $find,
+                "/$find/Ui",
                 $create_table,
                 $matches
             );




More information about the Solar-svn mailing list