sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

Parser does not recognize single character table name or alias

Open joseffi opened this issue 4 years ago • 1 comments

When using a single character as a table alias or name, the table.column names are not properly recognized

For example, this SQL:

SELECT x.asset_id FROM
    (SELECT evt.asset_id FROM evt) x

is incorrectly parsed into:

                (
                    [0] => PhpMyAdmin\SqlParser\Components\Expression Object
                        (
                            [database] => 
                            [table] => 
                            [column] => 
                            [expr] => x.asset_id
                            [alias] => 
                            [function] => 
                            [subquery] => 
                        )

                )

But this works:

SELECT xx.asset_id FROM
    (SELECT evt.asset_id FROM evt) xx

parser result:

                (
                    [0] => PhpMyAdmin\SqlParser\Components\Expression Object
                        (
                            [database] => 
                            [table] => xx
                            [column] => asset_id
                            [expr] => xx.asset_id
                            [alias] => 
                            [function] => 
                            [subquery] => 
                        )

                )

joseffi avatar Jan 29 '21 04:01 joseffi

Thank you for reporting this issue !

williamdes avatar Jan 30 '21 22:01 williamdes

Fixed by #385 Similar to #378

williamdes avatar Jan 31 '23 11:01 williamdes