Skip to content

Commit

Permalink
Fixes #11664. Online syntax verifier bug - "IF" on SELECT statement
Browse files Browse the repository at this point in the history
Fixes #11665. Format breaks query with COUNT()
Update sql-parser to phpmyadmin/sql-parser@5621792 (v3.0.7).

Signed-off-by: Dan Ungureanu <udan1107@gmail.com>
  • Loading branch information
Dan Ungureanu committed Nov 17, 2015
1 parent 633d6fd commit 0d5bf18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions libraries/sql-parser/src/Components/ExpressionArray.php
Expand Up @@ -70,6 +70,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =

if (($token->type === Token::TYPE_KEYWORD)
&& ($token->flags & Token::FLAG_KEYWORD_RESERVED)
&& ((~$token->flags & Token::FLAG_KEYWORD_FUNCTION))
&& ($token->value !== 'DUAL')
) {
// No keyword is expected.
Expand Down
11 changes: 6 additions & 5 deletions libraries/sql-parser/src/Utils/Formatter.php
Expand Up @@ -304,7 +304,9 @@ public function formatList($list)
if (($this->options['parts_newline'])
&& (!$formattedOptions)
&& (empty(self::$INLINE_CLAUSES[$lastClause]))
&& ($curr->type != Token::TYPE_KEYWORD)
&& (($curr->type !== Token::TYPE_KEYWORD)
|| (($curr->type === Token::TYPE_KEYWORD)
&& ($curr->flags & Token::FLAG_KEYWORD_FUNCTION)))
) {
$formattedOptions = true;
$lineEnded = true;
Expand Down Expand Up @@ -334,8 +336,8 @@ public function formatList($list)
// Formatting fragments delimited by comma.
if (($prev->type === Token::TYPE_OPERATOR) && ($prev->value === ',')) {
// Fragments delimited by a comma are broken into multiple
// pieces only if the clause if the clause is not inlined or
// this fragment is between brackets that were on new line.
// pieces only if the clause is not inlined or this fragment
// is between brackets that are on new line.
if (((empty(self::$INLINE_CLAUSES[$lastClause]))
&& ($this->options['parts_newline']))
|| (end($blocksLineEndings) === true)
Expand Down Expand Up @@ -401,8 +403,7 @@ public function formatList($list)
$comment = '';
}

// Saving the next token as the one that will be processed during
// the next iteration.
// Iteration finished, consider current token as previous.
$prev = $curr;
}

Expand Down

0 comments on commit 0d5bf18

Please sign in to comment.