diff options
author | Deven Bansod <devenbansod.bits@gmail.com> | 2016-09-20 11:38:36 +0530 |
---|---|---|
committer | Deven Bansod <devenbansod.bits@gmail.com> | 2016-09-20 12:01:53 +0530 |
commit | 34b1308d30efe6e91e0883fdce1bf4d1fce447b9 (patch) | |
tree | 06910bbb4b71c6320ebdd84ab9baa868ea0bb274 /src/Components/OptionsArray.php | |
parent | 5988855152a5c8adcc874e9868e97adcbfcd7d69 (diff) | |
download | sql-parser-34b1308d30efe6e91e0883fdce1bf4d1fce447b9.zip sql-parser-34b1308d30efe6e91e0883fdce1bf4d1fce447b9.tar.gz sql-parser-34b1308d30efe6e91e0883fdce1bf4d1fce447b9.tar.bz2 |
Fix parsing of user@host without backquotes
Introduce an option to parse 'expr=' (like var, var=, expr)
Fix tests
Fix phpmyadmin/phpmyadmin#12298
Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
Diffstat (limited to 'src/Components/OptionsArray.php')
-rw-r--r-- | src/Components/OptionsArray.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Components/OptionsArray.php b/src/Components/OptionsArray.php index c048e19..684e5cc 100644 --- a/src/Components/OptionsArray.php +++ b/src/Components/OptionsArray.php @@ -183,7 +183,7 @@ class OptionsArray extends Component 'value' => '', ); $state = 1; - } elseif ($lastOption[1] === 'expr') { + } elseif ($lastOption[1] === 'expr' || $lastOption[1] === 'expr=') { // This is a keyword that is followed by an expression. // The expression is used by the specialized parser. @@ -192,8 +192,11 @@ class OptionsArray extends Component $ret->options[$lastOptionId] = array( // @var string The name of the option. 'name' => $token->value, + // @var bool Whether it contains an equal sign. + // This is used by the builder to rebuild it. + 'equals' => $lastOption[1] === 'expr=', // @var Expression The parsed expression. - 'expr' => null, + 'expr' => '', ); $state = 1; } @@ -208,7 +211,7 @@ class OptionsArray extends Component // This is outside the `elseif` group above because the change might // change this iteration. if ($state === 2) { - if ($lastOption[1] === 'expr') { + if ($lastOption[1] === 'expr' || $lastOption[1] === 'expr=') { $ret->options[$lastOptionId]['expr'] = Expression::parse( $parser, $list, @@ -250,7 +253,8 @@ class OptionsArray extends Component && $lastOption && ($lastOption[1] == 'expr' || $lastOption[1] == 'var' - || $lastOption[1] == 'var=') + || $lastOption[1] == 'var=' + || $lastOption[1] == 'expr=') ) { $parser->error( sprintf( @@ -287,7 +291,7 @@ class OptionsArray extends Component $options[] = $option; } else { $options[] = $option['name'] - . (!empty($option['equals']) ? '=' : ' ') + . ((!empty($option['equals']) && $option['equals']) ? '=' : ' ') . (!empty($option['expr']) ? $option['expr'] : $option['value']); } } |