-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to parse table names that start with "e1" #578
Comments
Actually the same problem happens with any table name that starts with "e" followed by a number. |
Thank you @sergio-paternoster for reporting this @niconoe- did you encounter this bug ? |
Never heard about it, but based on what has been said here, my thoughts are that the lexer fails to understand "e[0-9]+" as a string here, but instead as an integer (10^n). EDIT:
I'll try to continue to take a look about it. |
Sorry for double posting here, but this is no longer about testing the bug, but rather about the explaination of the bug. The lexer is trying all of these methods and stops as soon as the method matches with a "lexable" token:
With the string "erp.my_table", the lexer detects that:
But, with the string "erp.e1_table", the lexer detects that:
Why that ? Because @williamdes it may have an impact, but looking at the |
If I understand this correctly by reading the code of your PR you change the step order to avoid this e/E detection ? |
Yes, but only on a certain context. When a string starts with ".", it must be detected as a number if it is followed by a digit. But when a string contains a ".", it must be detected as a number if it is followed by a digit or "e"/"E" for scientific notation. This difference wasn't taken into account in the lexer. I hope this is understandable through my comments and my PR 😄 |
@sergio-paternoster I think you can avoid the parsing error by using quote-identifiers around your table names. use PhpMyAdmin\SqlParser\Parser as Parser;
$query = "LOAD DATA LOCAL INFILE '/home/user/myloadfile.csv'
IGNORE INTO TABLE `erp`.`e1_table`
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
IGNORE 0 LINES;"; This should unlock the situation for you waiting for a patch version integrating #579 is released. |
@niconoe- Thanks for the fix! The workaround you suggested works well! |
Not sure if this is a bug of just a table name with reserved keywords. If the name of my table starts with "e1" the parser is unable to recognize it. It works with any other table name that doesn't start with "e1". Here is my code (SqlParser v.5.10, php version 8.2.16 CLI):
This is the actual output:
Expected output:
The text was updated successfully, but these errors were encountered: