You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to parse a WHERE clause such as WHERE foo LIKE :bar it returns foo LIKE : as a single token, where as I would expect it to return fooLIKE:bar as individual tokens. It doesn't have this issue when using back ticks on the columns, or = instead of LIKE.
Sample script:
<?phprequire_once__DIR__ . '/vendor/autoload.php';
usePhpMyAdmin\SqlParser\Parser;
usePhpMyAdmin\SqlParser\Token;
usePhpMyAdmin\SqlParser\TokensList;
$sql = 'SELECT * FROM test WHERE foo LIKE :bar';
echo'sql: ' . $sql . PHP_EOL;
$parser = newParser($sql);
foreach ($parser->list->tokensas$i => $token) {
echo'token: ' . $token->token , PHP_EOL;
}
$sql = 'SELECT * FROM test WHERE `foo` LIKE :bar';
echo'sql: ' . $sql . PHP_EOL;
$parser = newParser($sql);
foreach ($parser->list->tokensas$i => $token) {
echo'token: ' . $token->token , PHP_EOL;
}
$sql = 'SELECT * FROM test WHERE foo = :bar';
echo'sql: ' . $sql . PHP_EOL;
$parser = newParser($sql);
foreach ($parser->list->tokensas$i => $token) {
echo'token: ' . $token->token , PHP_EOL;
}
Output:
sql: SELECT * FROM test WHERE foo LIKE :bar
token: SELECT
token:
token: *
token:
token: FROM
token:
token: test
token:
token: WHERE
token:
token: foo LIKE :
token: bar
token:
sql: SELECT * FROM test WHERE `foo` LIKE :bar
token: SELECT
token:
token: *
token:
token: FROM
token:
token: test
token:
token: WHERE
token:
token: `foo`
token:
token: LIKE
token:
token: :bar
token:
sql: SELECT * FROM test WHERE foo = :bar
token: SELECT
token:
token: *
token:
token: FROM
token:
token: test
token:
token: WHERE
token:
token: foo
token:
token: =
token:
token: :bar
token:
The text was updated successfully, but these errors were encountered:
When trying to parse a WHERE clause such as
WHERE foo LIKE :bar
it returnsfoo LIKE :
as a single token, where as I would expect it to returnfoo
LIKE
:bar
as individual tokens. It doesn't have this issue when using back ticks on the columns, or=
instead ofLIKE
.Sample script:
Output:
The text was updated successfully, but these errors were encountered: