Skip to content

Commit 52f3c95

Browse files
committed
Merge branch 'zzycad-master'
2 parents 644fd99 + a670a90 commit 52f3c95

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/SQLParser.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private function _lex($sql){
108108
# <unsigned integer> [ <period> [ <unsigned integer> ] ]
109109
# <period> <unsigned integer>
110110
# <unsigned integer> ::= <digit>...
111-
if (preg_match('!(\d+\.?\d*|\.\d+)!A', $sql, $m, 0, $pos)){
111+
if (preg_match('![-+]?(\d+\.?\d*|\.\d+)!A', $sql, $m, 0, $pos)){
112112
$source_map[] = array($pos, strlen($m[0]));
113113
$pos += strlen($m[0]);
114114
continue;
@@ -760,6 +760,11 @@ function parse_field($tokens){
760760

761761
# [UNIQUE [KEY] | [PRIMARY] KEY]
762762
# [COMMENT 'string']
763+
if (count($tokens) >= 1 && StrToUpper($tokens[0]) == 'COMMENT'){
764+
$f['comment'] = $this->decode_value($tokens[1]);
765+
array_shift($tokens);
766+
array_shift($tokens);
767+
}
763768
# [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}]
764769
# [STORAGE {DISK|MEMORY|DEFAULT}]
765770
# [reference_definition]

tests/FieldTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ function testFieldOptions(){
335335
'null' => true,
336336
)
337337
), $fields);
338+
339+
$fields = $this->get_fields("bar INT NOT NULL DEFAULT -1");
340+
$this->assertEquals(array(
341+
array(
342+
'name' => "bar",
343+
'type' => "INT",
344+
'default' => '-1',
345+
'null' => false,
346+
)
347+
), $fields);
348+
349+
$fields = $this->get_fields("ucount int NOT NULL comment 'user count'");
350+
$this->assertEquals('user count', $fields[0]['comment']);
338351
}
339352

340353
function testVirtualOptions(){

0 commit comments

Comments
 (0)