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
Describe the bug
A SQL containing aliased function calls is parsed (and formatted) wrong when the AS keyword is mussing.
To Reproduce
good_sql_no_alias="select extract(year from foo), extract(month from foo), value from orders"bad_sql_alias="select extract(year from foo) year, extract(month from foo) month, value from orders"good_sql_alias="select extract(year from foo) as year, extract(month from foo) as month, value from orders"importsqlparse>>>print(sqlparse.format(good_sql_no_alias, reindent=True))
selectextract(yearfromfoo),
extract(monthfromfoo),
valuefromorders>>>print(sqlparse.format(bad_sql_alias, reindent=True))
selectextract(yearfromfoo) year,
extract(monthfromfoo) month,
valuefromorders>>>print(sqlparse.format(good_sql_alias, reindent=True))
selectextract(yearfromfoo) asyear,
extract(monthfromfoo) asmonth,
valuefromorders
The parser identifies year and month as keywords.
Expected behavior
The formatting (and parsing) of bad_sql_alias should be the same way as for the good ones.
Versions (please complete the following information):
Python: 3.11
sqlparse: 0.5.0
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered:
Removing milestone again, this is once again the ambiguity of year, month, etc. being a keyword and being used as an identifier. That's why the as year variant works, this removes the ambiguity.
I'm not sure how to handle this in the parser right now, as the parser has little to none context.
@mhmtsoydam, I'm sorry, but I don't think that this gets fixed any time soon...
Describe the bug
A SQL containing aliased function calls is parsed (and formatted) wrong when the
AS
keyword is mussing.To Reproduce
The parser identifies
year
andmonth
as keywords.Expected behavior
The formatting (and parsing) of
bad_sql_alias
should be the same way as for the good ones.Versions (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: