sql-metadata
sql-metadata copied to clipboard
Update statement gets wrongly identified table
Hi,
Parsing this statement:
Update a SET b=1 FROM schema1.testtable as a;
Gives "a" as both alias and table.
It should identify a as alias only.
Fixed using this workaround, for now:
TABLES_list = [];
...
metadata_parsing = Parser(stmt.value)
alias_list = list(metadata_parsing.tables_aliases.items()) #List of Items[0]=alias, Values[1]=tables
if len(alias_list)>0: #If we have tables_aliases
wrongly_identified =(list(set(alias_list[0]).intersection(alias_list[1]))) #Finding entities both identified as Table & Alias.
TABLES_list.extend([x for x in metadata_parsing.tables if x not in wrongly_identified]) #Add all others