Skip to content

Commit 634e93a

Browse files
committed
SQLToken: fix the handling of a new IFNOTEXISTS token
1 parent f1919cc commit 634e93a

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

sql_metadata/keywords_lists.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"INTO",
3434
"UPDATE",
3535
"TABLE",
36+
"IFNOTEXISTS",
3637
}
3738

3839
# next statement beginning after with statement

sql_metadata/token.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ def is_potential_table_name(self) -> bool:
262262
(self.is_name or self.is_keyword)
263263
and self.last_keyword_normalized in TABLE_ADJUSTMENT_KEYWORDS
264264
and self.previous_token.normalized not in ["AS", "WITH"]
265-
and self.normalized not in ["AS", "SELECT", "IF", "SET", "WITH"]
265+
and self.normalized
266+
not in ["AS", "SELECT", "IF", "SET", "WITH", "IFNOTEXISTS"]
266267
)
267268

268269
@property
@@ -288,7 +289,7 @@ def is_alias_of_table_or_alias_of_subquery(self) -> bool:
288289
is_alias_without_as = (
289290
self.previous_token.normalized != self.last_keyword_normalized
290291
and not self.previous_token.is_punctuation
291-
and not self.previous_token.normalized == "EXISTS"
292+
and not self.previous_token.normalized == "IFNOTEXISTS"
292293
)
293294
return is_alias_without_as or self.previous_token.is_right_parenthesis
294295

0 commit comments

Comments
 (0)