sql-metadata
sql-metadata copied to clipboard
Parser.columns drops column named 'source' when it is the last column in a SELECT statement
Hello, if a column named 'source' is the last column in a SELECT statement, it gets dropped from the list returned by Parser(sql_str).columns. If 'source' is moved to another place in the SELECT statement, it is not dropped. I can recreate this issue in v2.18.0 as well as in the interactive demo (https://sql-app.infocruncher.com/). I would not expect 'source' to get dropped if it's the last column in a SELECT statement.
from sql_metadata import Parser
sql_query_str = 'select foo, bar, source from my_table'
Parser(sql_query_str).columns
# ['foo', 'bar']
sql_query_str = 'select foo, source, bar from my_table'
Parser(sql_query_str).columns
# ['foo', 'source', 'bar']