From 37f43534dbffd77281f8f876aef6e69a784c3f54 Mon Sep 17 00:00:00 2001 From: zzy Date: Fri, 13 Dec 2024 17:32:32 +0800 Subject: [PATCH] Fix the bug with default negative values, and add the ability to handle field comments. --- src/SQLParser.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SQLParser.php b/src/SQLParser.php index 5105744..6eeace8 100644 --- a/src/SQLParser.php +++ b/src/SQLParser.php @@ -108,7 +108,7 @@ private function _lex($sql){ # [ [ ] ] # # ::= ... - 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; @@ -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]