Skip to content

Commit 1ec9e18

Browse files
Bump sqlparse from 0.5.3 to 0.5.4 (#598)
* Bump sqlparse from 0.5.3 to 0.5.4 Bumps [sqlparse](https://github.com/andialbrecht/sqlparse) from 0.5.3 to 0.5.4. - [Changelog](https://github.com/andialbrecht/sqlparse/blob/master/CHANGELOG) - [Commits](andialbrecht/sqlparse@0.5.3...0.5.4) --- updated-dependencies: - dependency-name: sqlparse dependency-version: 0.5.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * SQLToken: fix the handling of a new IFNOTEXISTS token * _determine_last_relevant_keyword: handle the new IFNOTEXISTS keyword so that columns in "CREATE TABLE IF NOT EXISTS foo" statements are properly detected * Makefile: add the "format" command --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Maciej Brencz <[email protected]>
1 parent 6cea5dc commit 1ec9e18

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ lint:
1111
poetry run flake8 sql_metadata
1212
poetry run pylint sql_metadata
1313

14+
format:
15+
poetry run black .
16+
1417
publish:
1518
# run git tag -a v0.0.0 before running make publish
1619
poetry build

poetry.lock

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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/parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ def _determine_last_relevant_keyword(self, token: SQLToken, last_keyword: str):
10051005
and self._open_parentheses[-1].is_partition_clause_start
10061006
)
10071007
and not (token.normalized == "USING" and last_keyword == "SELECT")
1008+
and not (token.normalized == "IFNOTEXISTS")
10081009
):
10091010
last_keyword = token.normalized
10101011
return last_keyword

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)