Skip to content

Commit

Permalink
Merge branch 'zzycad-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcal committed Dec 13, 2024
2 parents 644fd99 + a670a90 commit 52f3c95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/SQLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private function _lex($sql){
# <unsigned integer> [ <period> [ <unsigned integer> ] ]
# <period> <unsigned integer>
# <unsigned integer> ::= <digit>...
if (preg_match('!(\d+\.?\d*|\.\d+)!A', $sql, $m, 0, $pos)){
if (preg_match('![-+]?(\d+\.?\d*|\.\d+)!A', $sql, $m, 0, $pos)){
$source_map[] = array($pos, strlen($m[0]));
$pos += strlen($m[0]);
continue;
Expand Down Expand Up @@ -760,6 +760,11 @@ function parse_field($tokens){

# [UNIQUE [KEY] | [PRIMARY] KEY]
# [COMMENT 'string']
if (count($tokens) >= 1 && StrToUpper($tokens[0]) == 'COMMENT'){
$f['comment'] = $this->decode_value($tokens[1]);
array_shift($tokens);
array_shift($tokens);
}
# [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}]
# [STORAGE {DISK|MEMORY|DEFAULT}]
# [reference_definition]
Expand Down
13 changes: 13 additions & 0 deletions tests/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,19 @@ function testFieldOptions(){
'null' => true,
)
), $fields);

$fields = $this->get_fields("bar INT NOT NULL DEFAULT -1");
$this->assertEquals(array(
array(
'name' => "bar",
'type' => "INT",
'default' => '-1',
'null' => false,
)
), $fields);

$fields = $this->get_fields("ucount int NOT NULL comment 'user count'");
$this->assertEquals('user count', $fields[0]['comment']);
}

function testVirtualOptions(){
Expand Down

0 comments on commit 52f3c95

Please sign in to comment.