sql-testing-tools 0.1.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_testing_tools
3
- Version: 0.1.7
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,6 +12,9 @@ A library that normalizes simple SQL queries and compares them first by equality
12
12
  [![Build and Test](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml/badge.svg)](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml)
13
13
  [![Build and Test](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-unittests.yml/badge.svg)](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
17
+
15
18
  ### V 0.1.6 + V 0.1.7
16
19
  - Fixed import error to ensure imports working in different environemnts
17
20
 
@@ -6,7 +6,7 @@ with open("sql_testing_tools/README.md", "r") as fh:
6
6
 
7
7
  setup(
8
8
  name='sql_testing_tools',
9
- version='0.1.7',
9
+ version='0.1.8',
10
10
  packages=find_packages(),
11
11
  install_requires=[
12
12
  'sqlparse>=0.5.1',
@@ -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 = where.normalized.upper().count(" AND ")
221
- or_count = where.normalized.upper().count(" OR ")
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(where, alias_map, baseDict, " AND " if and_count > 0 else " OR ")
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(where, alias_map, baseDict: dict):
293
+ def _where_simpleCondition(where_tokens, alias_map, baseDict: dict):
296
294
  cond = []
297
- for tok in where.tokens:
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(where, alias_map, baseDict: dict, keyword: str):
306
+ def _where_sameStrengthKeywords(where_tokens, alias_map, baseDict: dict, keyword: str):
309
307
  cond = []
310
- for tok in where.tokens:
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.7
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,6 +12,9 @@ A library that normalizes simple SQL queries and compares them first by equality
12
12
  [![Build and Test](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml/badge.svg)](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-build.yml)
13
13
  [![Build and Test](https://github.com/ValentinHerrmann/sql_testing_tools/actions/workflows/python-unittests.yml/badge.svg)](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
17
+
15
18
  ### V 0.1.6 + V 0.1.7
16
19
  - Fixed import error to ensure imports working in different environemnts
17
20