phpmyadmin/sql-parser

Unrecognized keyword when using 'x' as table alias

svivian opened this issue · 5 comments

Hopefully this is the right place for this bug. In phpMyAdmin I get an error when using a legitimate query. Using the "Country" table on the demo server as an example, putting the following query into the SQL box gives an error:

update Country x, City c
set x.Name=x.Name
where x.Code=c.CountryCode;

The first x gets underlined in red and it says "Unrecognized keyword (near x)". But the query is valid and submitting it runs just fine.

I don't get the error in a select query (e.g. select * from Country x, City c...) and changing the x to another letter works fine (e.g. Country w, City c).

Hi @svivian
This is indeed the right place to report such bugs
Thank you

@williamdes / @iifawzi
I wanted to give it a try on this issue, but I have the feeling that using SQL-Parser 5.7.0 (and thanks to #385), this bug is already fixed. I just tried with

php bin/highlight-query --query "update Country x, City c
set x.Name=x.Name
where x.Code=c.CountryCode;"

and I got a successful answer

UPDATE
    Country x,
    City c
SET
    x.Name = x.Name
WHERE
    x.Code = c.CountryCode;

wihout any error.

Are you aware of such statement that could reproduce the issue?
Thanks a lot!

Indeed, I think it was a mistake and I forgot to close the issues :O

But that is also due to the fact that Fixes #xyz should have been the wording that github would detect and close the issues on PR merge 😸

@williamdes / @iifawzi I wanted to give it a try on this issue, but I have the feeling that using SQL-Parser 5.7.0 (and thanks to #385), this bug is already fixed. I just tried with

php bin/highlight-query --query "update Country x, City c
set x.Name=x.Name
where x.Code=c.CountryCode;"

and I got a successful answer

UPDATE
    Country x,
    City c
SET
    x.Name = x.Name
WHERE
    x.Code = c.CountryCode;

wihout any error.

Are you aware of such statement that could reproduce the issue? Thanks a lot!

Probably the one on #327

Probably the one on #327

Tested and working as expected:

> php bin/highlight-query --query "SELECT x.asset_id FROM
    (SELECT evt.asset_id FROM evt) x"
SELECT
    x.asset_id
FROM
    (
SELECT
    evt.asset_id
FROM
    evt
) x

I really do think that this is fixed now 😉

EDIT: My bad, you just closed this issue while I was testing. We do agree this is OK now. Thanks a lot!