Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sql_metadata/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def tables_aliases(self) -> Dict[str, str]:
token.last_keyword_normalized in TABLE_ADJUSTMENT_KEYWORDS
and (token.is_name or (token.is_keyword and not token.is_as_keyword))
and not token.next_token.is_as_keyword
and not token.value in RELEVANT_KEYWORDS
):
if token.previous_token.is_as_keyword:
# potential <DB.<SCHEMA>.<TABLE> as <ALIAS>
Expand Down
4 changes: 4 additions & 0 deletions sql_metadata/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ def is_alias_of_self(self) -> bool:
end_of_column = end_of_column.find_nearest_token(
[",", "FROM"], value_attribute="normalized", direction="right"
)

if end_of_column is EmptyToken:
return False

return end_of_column.previous_token.normalized == self.normalized

@property
Expand Down