sql-metadata 2.18.0__tar.gz → 2.20.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/PKG-INFO +2 -3
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/pyproject.toml +3 -3
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/sql_metadata/keywords_lists.py +1 -0
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/sql_metadata/parser.py +9 -2
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/sql_metadata/token.py +4 -3
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/LICENSE +0 -0
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/README.md +0 -0
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/sql_metadata/__init__.py +0 -0
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/sql_metadata/compat.py +0 -0
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/sql_metadata/generalizator.py +0 -0
- {sql_metadata-2.18.0 → sql_metadata-2.20.0}/sql_metadata/utils.py +0 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sql_metadata
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.20.0
|
|
4
4
|
Summary: Uses tokenized query returned by python-sqlparse and generates query metadata
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
7
|
Author: Maciej Brencz
|
|
8
8
|
Author-email: maciej.brencz@gmail.com
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "sql_metadata"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.20.0"
|
|
4
4
|
license="MIT"
|
|
5
5
|
description = "Uses tokenized query returned by python-sqlparse and generates query metadata"
|
|
6
6
|
authors = ["Maciej Brencz <maciej.brencz@gmail.com>", "Radosław Drążkiewicz <collerek@gmail.com>"]
|
|
@@ -13,11 +13,11 @@ packages = [
|
|
|
13
13
|
]
|
|
14
14
|
|
|
15
15
|
[tool.poetry.dependencies]
|
|
16
|
-
python = "^3.
|
|
16
|
+
python = "^3.10"
|
|
17
17
|
sqlparse = ">=0.4.1,<0.6.0"
|
|
18
18
|
|
|
19
19
|
[tool.poetry.dev-dependencies]
|
|
20
|
-
black = "^25.
|
|
20
|
+
black = "^25.11"
|
|
21
21
|
coverage = {extras = ["toml"], version = "^7.10"}
|
|
22
22
|
pylint = "^3.3.9"
|
|
23
23
|
pytest = "^8.4.2"
|
|
@@ -447,7 +447,7 @@ class Parser: # pylint: disable=R0902
|
|
|
447
447
|
return self._table_aliases
|
|
448
448
|
|
|
449
449
|
@property
|
|
450
|
-
def with_names(self) -> List[str]:
|
|
450
|
+
def with_names(self) -> List[str]: # noqa: C901
|
|
451
451
|
"""
|
|
452
452
|
Returns with statements aliases list from a given query
|
|
453
453
|
|
|
@@ -474,6 +474,12 @@ class Parser: # pylint: disable=R0902
|
|
|
474
474
|
)
|
|
475
475
|
if is_end_of_with_block:
|
|
476
476
|
self._is_in_with_block = False
|
|
477
|
+
elif token.next_token and token.next_token.is_as_keyword:
|
|
478
|
+
# Malformed SQL like "... AS (...) AS ..."
|
|
479
|
+
raise ValueError("This query is wrong")
|
|
480
|
+
else:
|
|
481
|
+
# Advance token to prevent infinite loop
|
|
482
|
+
token = token.next_token
|
|
477
483
|
else:
|
|
478
484
|
token = token.next_token
|
|
479
485
|
|
|
@@ -676,7 +682,7 @@ class Parser: # pylint: disable=R0902
|
|
|
676
682
|
# like: with (col1, col2) as (subquery) as ..., it enters an infinite loop.
|
|
677
683
|
# return exception
|
|
678
684
|
if start_token.is_with_query_start:
|
|
679
|
-
raise ValueError("This query is wrong")
|
|
685
|
+
raise ValueError("This query is wrong") # pragma: no cover
|
|
680
686
|
start_token.is_with_columns_start = True
|
|
681
687
|
start_token.is_nested_function_start = False
|
|
682
688
|
prev_token = start_token.previous_token
|
|
@@ -1005,6 +1011,7 @@ class Parser: # pylint: disable=R0902
|
|
|
1005
1011
|
and self._open_parentheses[-1].is_partition_clause_start
|
|
1006
1012
|
)
|
|
1007
1013
|
and not (token.normalized == "USING" and last_keyword == "SELECT")
|
|
1014
|
+
and not (token.normalized == "IFNOTEXISTS")
|
|
1008
1015
|
):
|
|
1009
1016
|
last_keyword = token.normalized
|
|
1010
1017
|
return last_keyword
|
|
@@ -176,7 +176,7 @@ class SQLToken: # pylint: disable=R0902, R0904
|
|
|
176
176
|
self.is_keyword
|
|
177
177
|
and self.normalized not in RELEVANT_KEYWORDS
|
|
178
178
|
and self.previous_token.normalized in [",", "SELECT"]
|
|
179
|
-
and self.next_token.normalized in [",", "AS"]
|
|
179
|
+
and self.next_token.normalized in [",", "AS", "FROM"]
|
|
180
180
|
)
|
|
181
181
|
|
|
182
182
|
@property
|
|
@@ -262,7 +262,8 @@ class SQLToken: # pylint: disable=R0902, R0904
|
|
|
262
262
|
(self.is_name or self.is_keyword)
|
|
263
263
|
and self.last_keyword_normalized in TABLE_ADJUSTMENT_KEYWORDS
|
|
264
264
|
and self.previous_token.normalized not in ["AS", "WITH"]
|
|
265
|
-
and self.normalized
|
|
265
|
+
and self.normalized
|
|
266
|
+
not in ["AS", "SELECT", "IF", "SET", "WITH", "IFNOTEXISTS"]
|
|
266
267
|
)
|
|
267
268
|
|
|
268
269
|
@property
|
|
@@ -288,7 +289,7 @@ class SQLToken: # pylint: disable=R0902, R0904
|
|
|
288
289
|
is_alias_without_as = (
|
|
289
290
|
self.previous_token.normalized != self.last_keyword_normalized
|
|
290
291
|
and not self.previous_token.is_punctuation
|
|
291
|
-
and not self.previous_token.normalized == "
|
|
292
|
+
and not self.previous_token.normalized == "IFNOTEXISTS"
|
|
292
293
|
)
|
|
293
294
|
return is_alias_without_as or self.previous_token.is_right_parenthesis
|
|
294
295
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|