Skip to content

Commit

Permalink
fixed bug #12145: missing optional spaces in regexp in _getTableColum…
Browse files Browse the repository at this point in the history
…ns() in the Reverse module

git-svn-id: http://svn.php.net/repository/pear/packages/MDB2/trunk@247393 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
quipo committed Dec 1, 2007
1 parent 9688ddc commit becd76b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions MDB2/Driver/Reverse/sqlite.php
Expand Up @@ -63,20 +63,20 @@ function _getTableColumns($sql)
if (PEAR::isError($db)) {
return $db;
}
$start_pos = strpos($sql, '(');
$end_pos = strrpos($sql, ')');
$start_pos = strpos($sql, '(');
$end_pos = strrpos($sql, ')');
$column_def = substr($sql, $start_pos+1, $end_pos-$start_pos-1);
// replace the decimal length-places-separator with a colon
$column_def = preg_replace('/(\d),(\d)/', '\1:\2', $column_def);
$column_sql = split(',', $column_def);
$columns = array();
$count = count($column_sql);
$columns = array();
$count = count($column_sql);
if ($count == 0) {
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
'unexpected empty table column definition list', __FUNCTION__);
}
$regexp = '/^([^ ]+) +(CHAR|VARCHAR|VARCHAR2|TEXT|BOOLEAN|SMALLINT|INT|INTEGER|DECIMAL|BIGINT|DOUBLE|FLOAT|DATETIME|DATE|TIME|LONGTEXT|LONGBLOB)( ?\(([1-9][0-9]*)(:([1-9][0-9]*))?\))?( UNSIGNED)?( PRIMARY KEY)?( DEFAULT (\'[^\']*\'|[^ ]+))?( NULL| NOT NULL)?( PRIMARY KEY)?$/i';
$regexp2 = '/^([^ ]+) +(PRIMARY|UNIQUE|CHECK)$/i';
$regexp = '/^\s*([^\s]+) +(CHAR|VARCHAR|VARCHAR2|TEXT|BOOLEAN|SMALLINT|INT|INTEGER|DECIMAL|BIGINT|DOUBLE|FLOAT|DATETIME|DATE|TIME|LONGTEXT|LONGBLOB)( ?\(([1-9][0-9]*)(:([1-9][0-9]*))?\))?( UNSIGNED)?( PRIMARY KEY)?( DEFAULT (\'[^\']*\'|[^ ]+))?( NULL| NOT NULL)?( PRIMARY KEY)?$/i';
$regexp2 = '/^\s*([^ ]+) +(PRIMARY|UNIQUE|CHECK)$/i';
for ($i=0, $j=0; $i<$count; ++$i) {
if (!preg_match($regexp, trim($column_sql[$i]), $matches)) {
if (!preg_match($regexp2, trim($column_sql[$i]))) {
Expand Down
2 changes: 2 additions & 0 deletions package_sqlite.php
Expand Up @@ -7,6 +7,8 @@
$state = 'alpha';
$notes = <<<EOT
- fixed bug #12105: new error message in the SQLite driver (patch by Adam Ashley)
- fixed bug #12145: missing optional spaces in regexp in _getTableColumns() in the
Reverse module
note:
open todo items:
Expand Down

0 comments on commit becd76b

Please sign in to comment.