sql-testing-tools 0.1.6__tar.gz → 0.1.8__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_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/PKG-INFO +8 -4
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/setup.py +1 -1
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools/TokenProcessing.py +10 -12
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools.egg-info/PKG-INFO +8 -4
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/README.md +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/setup.cfg +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools/BaseAccess.py +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools/Helper.py +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools/__init__.py +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools.egg-info/SOURCES.txt +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools.egg-info/dependency_links.txt +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools.egg-info/requires.txt +0 -0
- {sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sql_testing_tools
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Description-Content-Type: text/markdown
|
|
5
5
|
Requires-Dist: sqlparse>=0.5.1
|
|
6
6
|
Requires-Dist: requests>=2.32.3
|
|
@@ -12,13 +12,17 @@ A library that normalizes simple SQL queries and compares them first by equality
|
|
|
12
12
|
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml)
|
|
13
13
|
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-unittests.yml)
|
|
14
14
|
|
|
15
|
+
### V 0.1.8
|
|
16
|
+
- Fixed linebreak problems: Linebreaks are now converted into whitespaces before parsing where tokens
|
|
15
17
|
|
|
18
|
+
### V 0.1.6 + V 0.1.7
|
|
19
|
+
- Fixed import error to ensure imports working in different environemnts
|
|
16
20
|
|
|
17
|
-
###
|
|
18
|
-
- V0.1.5 is just a reupload of
|
|
21
|
+
### V 0.1.4 + V 0.1.5
|
|
22
|
+
- V0.1.5 is just a reupload of V 0.1.4
|
|
19
23
|
- Chained conditions (with AND,OR and Paranthesises) in WHERE statement
|
|
20
24
|
|
|
21
|
-
###
|
|
25
|
+
### V 0.1.3
|
|
22
26
|
- SELECT: columns with our without table prefix
|
|
23
27
|
- FROM: one or more table from DB; no queries as tables!
|
|
24
28
|
- WHERE: single conditions; no Paranthesises!
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import sqlparse
|
|
2
2
|
from sqlparse.sql import Identifier, IdentifierList, Where, Comparison, Function, Parenthesis
|
|
3
|
-
from sqlparse.tokens import Keyword, DML, Name, Wildcard, Whitespace
|
|
3
|
+
from sqlparse.tokens import Keyword, DML, Name, Wildcard, Whitespace, Newline
|
|
4
4
|
|
|
5
5
|
try:
|
|
6
6
|
import Helper as He
|
|
7
7
|
except ImportError:
|
|
8
8
|
from . import Helper as He
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
|
|
13
11
|
#####################################
|
|
14
12
|
#####################################
|
|
@@ -216,10 +214,11 @@ def _where(where, alias_map, baseDict: dict):
|
|
|
216
214
|
|
|
217
215
|
isParanthesis = isinstance(where, Parenthesis)
|
|
218
216
|
|
|
217
|
+
where_tokens = [token for token in where.tokens if (token.ttype is not Whitespace and token.ttype is not Newline)and token.value != "WHERE"]
|
|
218
|
+
where_string = " ".join([str(token) for token in where_tokens])
|
|
219
219
|
|
|
220
|
-
and_count =
|
|
221
|
-
or_count
|
|
222
|
-
|
|
220
|
+
and_count = where_string.upper().count(" AND ")
|
|
221
|
+
or_count = where_string.upper().count(" OR ")
|
|
223
222
|
|
|
224
223
|
# No AND / OR
|
|
225
224
|
if and_count + or_count == 0:
|
|
@@ -227,11 +226,10 @@ def _where(where, alias_map, baseDict: dict):
|
|
|
227
226
|
|
|
228
227
|
# only ANDs / only ORs
|
|
229
228
|
elif and_count == 0 or or_count == 0:
|
|
230
|
-
return _where_sameStrengthKeywords(
|
|
229
|
+
return _where_sameStrengthKeywords(where_tokens, alias_map, baseDict, " AND " if and_count > 0 else " OR ")
|
|
231
230
|
|
|
232
231
|
# ANDs and ORs
|
|
233
232
|
|
|
234
|
-
where_tokens = [token for token in where.tokens if token.ttype is not Whitespace and token.value != "WHERE"]
|
|
235
233
|
|
|
236
234
|
# count keywords on top level
|
|
237
235
|
top_and_count = count_keywordValues(where_tokens, ["AND"])
|
|
@@ -292,9 +290,9 @@ def _where_addBracketsAroundAND(where, alias_map, baseDict: dict):
|
|
|
292
290
|
|
|
293
291
|
|
|
294
292
|
|
|
295
|
-
def _where_simpleCondition(
|
|
293
|
+
def _where_simpleCondition(where_tokens, alias_map, baseDict: dict):
|
|
296
294
|
cond = []
|
|
297
|
-
for tok in
|
|
295
|
+
for tok in where_tokens:
|
|
298
296
|
if isinstance(tok, Comparison):
|
|
299
297
|
cond.append(_condition(tok, alias_map, baseDict))
|
|
300
298
|
elif isinstance(tok, Parenthesis):
|
|
@@ -305,9 +303,9 @@ def _where_simpleCondition(where, alias_map, baseDict: dict):
|
|
|
305
303
|
tok = _tok
|
|
306
304
|
return "".join(cond)
|
|
307
305
|
|
|
308
|
-
def _where_sameStrengthKeywords(
|
|
306
|
+
def _where_sameStrengthKeywords(where_tokens, alias_map, baseDict: dict, keyword: str):
|
|
309
307
|
cond = []
|
|
310
|
-
for tok in
|
|
308
|
+
for tok in where_tokens:
|
|
311
309
|
if isinstance(tok, Comparison):
|
|
312
310
|
cond.append(_condition(tok, alias_map, baseDict))
|
|
313
311
|
elif isinstance(tok, Parenthesis):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sql_testing_tools
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
4
4
|
Description-Content-Type: text/markdown
|
|
5
5
|
Requires-Dist: sqlparse>=0.5.1
|
|
6
6
|
Requires-Dist: requests>=2.32.3
|
|
@@ -12,13 +12,17 @@ A library that normalizes simple SQL queries and compares them first by equality
|
|
|
12
12
|
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml)
|
|
13
13
|
[](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-unittests.yml)
|
|
14
14
|
|
|
15
|
+
### V 0.1.8
|
|
16
|
+
- Fixed linebreak problems: Linebreaks are now converted into whitespaces before parsing where tokens
|
|
15
17
|
|
|
18
|
+
### V 0.1.6 + V 0.1.7
|
|
19
|
+
- Fixed import error to ensure imports working in different environemnts
|
|
16
20
|
|
|
17
|
-
###
|
|
18
|
-
- V0.1.5 is just a reupload of
|
|
21
|
+
### V 0.1.4 + V 0.1.5
|
|
22
|
+
- V0.1.5 is just a reupload of V 0.1.4
|
|
19
23
|
- Chained conditions (with AND,OR and Paranthesises) in WHERE statement
|
|
20
24
|
|
|
21
|
-
###
|
|
25
|
+
### V 0.1.3
|
|
22
26
|
- SELECT: columns with our without table prefix
|
|
23
27
|
- FROM: one or more table from DB; no queries as tables!
|
|
24
28
|
- WHERE: single conditions; no Paranthesises!
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{sql_testing_tools-0.1.6 → sql_testing_tools-0.1.8}/sql_testing_tools.egg-info/top_level.txt
RENAMED
|
File without changes
|