Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace PhpMyAdmin\SqlParser;

use PhpMyAdmin\SqlParser\Components\FunctionCall;
use PhpMyAdmin\SqlParser\Components\OptionsArray;

/**
Expand Down Expand Up @@ -247,10 +248,10 @@ public function parse(Parser $parser, TokensList $list)
// Unions are parsed by the parser because they represent more than
// one statement.
if (($token->keyword === 'UNION') ||
($token->keyword === 'UNION ALL') ||
($token->keyword === 'UNION DISTINCT') ||
($token->keyword === 'EXCEPT') ||
($token->keyword === 'INTERSECT')
($token->keyword === 'UNION ALL') ||
($token->keyword === 'UNION DISTINCT') ||
($token->keyword === 'EXCEPT') ||
($token->keyword === 'INTERSECT')
) {
break;
}
Expand Down Expand Up @@ -356,7 +357,7 @@ public function parse(Parser $parser, TokensList $list)
} elseif ($class === null) {
if ($this instanceof Statements\SelectStatement
&& ($token->value === 'FOR UPDATE'
|| $token->value === 'LOCK IN SHARE MODE')
|| $token->value === 'LOCK IN SHARE MODE')
) {
// Handle special end options in Select statement
// See Statements\SelectStatement::$END_OPTIONS
Expand All @@ -367,7 +368,7 @@ public function parse(Parser $parser, TokensList $list)
);
} elseif ($this instanceof Statements\SetStatement
&& ($token->value === 'COLLATE'
|| $token->value === 'DEFAULT')
|| $token->value === 'DEFAULT')
) {
// Handle special end options in SET statement
// See Statements\SetStatement::$END_OPTIONS
Expand Down Expand Up @@ -398,6 +399,13 @@ public function parse(Parser $parser, TokensList $list)
}

$this->after($parser, $list, $token);

// #223 Here may make a patch, if last is delimiter, back one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to find a way to say this a bit differently since I'm a little not clear about what the "one" is here. Would this phrasing work for you?

// Issue 223: If the previous token is a delimiter, go back to the previous token

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this line is missing a $class !== null check beforehand, as we use it a few lines above.

I tried to PR a suggestion, but it seems this lines are not contained in the master branch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@staabm This should be part of master now, can you make sure you're pulling the latest change from this repository?

if ((new $class()) instanceof FunctionCall) {
if ($list->offsetGet($list->idx)->type === Token::TYPE_DELIMITER) {
--$list->idx;
}
}
}

// This may be corrected by the parser.
Expand Down Expand Up @@ -500,8 +508,8 @@ public function validateClauseOrder($parser, $list)
if ($clauseStartIdx !== -1
&& $this instanceof Statements\SelectStatement
&& ($clauseType === 'FORCE'
|| $clauseType === 'IGNORE'
|| $clauseType === 'USE')
|| $clauseType === 'IGNORE'
|| $clauseType === 'USE')
) {
// TODO: ordering of clauses in a SELECT statement with
// Index hints is not supported
Expand Down
10 changes: 10 additions & 0 deletions src/Statements/CallStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ class CallStatement extends Statement
* @var FunctionCall
*/
public $call;

/**
* Build statement for CALL.
*
* @return string
*/
public function build()
{
return "CALL " . $this->call->name . "(" . ($this->call->parameters ? implode(",", $this->call->parameters->raw) : "") . ")";
}
}