Skip to content

Conversation

tomershay
Copy link
Contributor

Mysql allows identifiers to start with a digit, but JSqlParser's parser fails when parsing such aliases.
Documentation:
https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
Search for "Identifiers may begin with a digit".

An example for a query that will fail before this change: SELECT a AS 1_a FROM tbl WHERE c = d

Mysql allows identifiers to start with a digit, but JSqlParser's parser fails when parsing such aliases.
Documentation:
https://dev.mysql.com/doc/refman/5.7/en/identifiers.html
Search for "Identifiers may begin with a digit".
@coveralls
Copy link

coveralls commented Nov 22, 2017

Coverage Status

Coverage increased (+0.003%) to 87.044% when pulling ca9256e on sh-tomer:allow_identifiers_to_begin_with_digits into f0ffe4c on JSQLParser:master.

@wumpz
Copy link
Member

wumpz commented Nov 23, 2017

Isn't the valid aproach regarding sql standards to quote those names?

"1_col" or [1_col] or 1_col

@tomershay
Copy link
Contributor Author

Thanks for the reply. It's the standard in some cases, but not in MySQL's case.
The reference I mentioned in the pull request description shows that MySQL allows identifiers to start with a digit, even without quotes around it.
Also, I tested it and MySQL runs a query like the following without any problem:
select inv_item_sk as 1_a from inventory limit 1000;

@wumpz
Copy link
Member

wumpz commented Nov 23, 2017

That would collide with e.g. postgresql

select 1e

where it is a scientific number.

@tomershay
Copy link
Contributor Author

tomershay commented Nov 23, 2017

Bummer, it kind of blocks the way to make both cases work. Any thoughts on how to move forward?

@wumpz wumpz closed this Jul 4, 2018
@tomershay tomershay deleted the allow_identifiers_to_begin_with_digits branch December 20, 2018 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants