@@ -277,27 +277,29 @@ public static function parse(Parser $parser, TokensList $list, array $options =
277277 } elseif (($ token ->value === ', ' ) && ($ brackets === 0 )) {
278278 break ;
279279 }
280- } elseif (! empty (Parser::$ STATEMENT_PARSERS [$ token ->value ])) {
281- // We have reached the end of ALTER operation and suddenly found
282- // a start to new statement, but have not find a delimiter between them
280+ } elseif (! self ::checkIfTokenQuotedSymbol ($ token )) {
281+ if (! empty (Parser::$ STATEMENT_PARSERS [$ token ->value ])) {
282+ // We have reached the end of ALTER operation and suddenly found
283+ // a start to new statement, but have not find a delimiter between them
283284
284- if (! ($ token ->value === 'SET ' && $ list ->tokens [$ list ->idx - 1 ]->value === 'CHARACTER ' )) {
285+ if (! ($ token ->value === 'SET ' && $ list ->tokens [$ list ->idx - 1 ]->value === 'CHARACTER ' )) {
286+ $ parser ->error (
287+ 'A new statement was found, but no delimiter between it and the previous one. ' ,
288+ $ token
289+ );
290+ break ;
291+ }
292+ } elseif ((array_key_exists ($ array_key , self ::$ DB_OPTIONS )
293+ || array_key_exists ($ array_key , self ::$ TABLE_OPTIONS ))
294+ && ! self ::checkIfColumnDefinitionKeyword ($ array_key )
295+ ) {
296+ // This alter operation has finished, which means a comma was missing before start of new alter operation
285297 $ parser ->error (
286- 'A new statement was found, but no delimiter between it and the previous one . ' ,
298+ 'Missing comma before start of a new alter operation . ' ,
287299 $ token
288300 );
289301 break ;
290302 }
291- } elseif ((array_key_exists ($ array_key , self ::$ DB_OPTIONS )
292- || array_key_exists ($ array_key , self ::$ TABLE_OPTIONS ))
293- && ! self ::checkIfColumnDefinitionKeyword ($ array_key )
294- ) {
295- // This alter operation has finished, which means a comma was missing before start of new alter operation
296- $ parser ->error (
297- 'Missing comma before start of a new alter operation. ' ,
298- $ token
299- );
300- break ;
301303 }
302304 $ ret ->unknown [] = $ token ;
303305 }
@@ -356,4 +358,14 @@ private static function checkIfColumnDefinitionKeyword($tokenValue)
356358 // both table as well as a specific column in the table
357359 return in_array ($ tokenValue , $ common_options );
358360 }
361+
362+ /**
363+ * Check if token is symbol and quoted with backtick
364+ *
365+ * @param Token $token token to check
366+ * @return bool
367+ */
368+ private static function checkIfTokenQuotedSymbol ($ token ) {
369+ return $ token ->type === Token::TYPE_SYMBOL && $ token ->flags === Token::FLAG_SYMBOL_BACKTICK ;
370+ }
359371}
0 commit comments