sql-testing-tools 0.2.1__tar.gz → 0.2.3__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.2
2
2
  Name: sql_testing_tools
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Description-Content-Type: text/markdown
5
5
  Requires-Dist: sqlparse>=0.5.1
6
6
  Requires-Dist: requests>=2.32.3
@@ -11,10 +11,21 @@ Dynamic: requires-dist
11
11
  A library that normalizes simple SQL queries and compares them first by equality of the normalized string and then using the cosette API.
12
12
 
13
13
 
14
+
14
15
  ### [Beta in Development!]
15
16
  [![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)
16
17
  [![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)
17
18
 
19
+ Submit bug reports and features requests at: https://github.com/ValentinHerrmann/sql_testing_tools
20
+
21
+ ### V 0.2.3
22
+ - fix: ASC/DESC in ORDER BY (also with multiple columns and order directions), no direction treated as ASC
23
+ - Verified that ; and whitespaces, linebreaks at end of query are ignored
24
+
25
+ ### V 0.2.2
26
+ - Support LIKE
27
+ - Support '<=' and '>=' (geq and leq)
28
+
18
29
  ### V 0.2.1
19
30
  - Support LIMIT
20
31
 
@@ -29,6 +40,7 @@ A library that normalizes simple SQL queries and compares them first by equality
29
40
 
30
41
  ### V 0.1.4 + V 0.1.5
31
42
  - Chained conditions (with AND,OR and Paranthesises) in WHERE statement
43
+ - Aggregate Functions
32
44
 
33
45
  ### V 0.1.3
34
46
  - SELECT: columns with our without table prefix
@@ -1,10 +1,21 @@
1
1
  A library that normalizes simple SQL queries and compares them first by equality of the normalized string and then using the cosette API.
2
2
 
3
3
 
4
+
4
5
  ### [Beta in Development!]
5
6
  [![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)
6
7
  [![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)
7
8
 
9
+ Submit bug reports and features requests at: https://github.com/ValentinHerrmann/sql_testing_tools
10
+
11
+ ### V 0.2.3
12
+ - fix: ASC/DESC in ORDER BY (also with multiple columns and order directions), no direction treated as ASC
13
+ - Verified that ; and whitespaces, linebreaks at end of query are ignored
14
+
15
+ ### V 0.2.2
16
+ - Support LIKE
17
+ - Support '<=' and '>=' (geq and leq)
18
+
8
19
  ### V 0.2.1
9
20
  - Support LIMIT
10
21
 
@@ -19,6 +30,7 @@ A library that normalizes simple SQL queries and compares them first by equality
19
30
 
20
31
  ### V 0.1.4 + V 0.1.5
21
32
  - Chained conditions (with AND,OR and Paranthesises) in WHERE statement
33
+ - Aggregate Functions
22
34
 
23
35
  ### V 0.1.3
24
36
  - SELECT: columns with our without table prefix
@@ -6,7 +6,7 @@ with open("README.md", "r") as fh:
6
6
 
7
7
  setup(
8
8
  name='sql_testing_tools',
9
- version='0.2.1',
9
+ version='0.2.3',
10
10
  packages=find_packages(),
11
11
  install_requires=[
12
12
  'sqlparse>=0.5.1',
@@ -2,6 +2,7 @@ import sqlparse
2
2
  from sqlparse.sql import Identifier, IdentifierList, Where, Comparison, Function, Parenthesis
3
3
  from sqlparse.tokens import Keyword, DML, Name, Wildcard, Whitespace, Newline
4
4
 
5
+
5
6
  try:
6
7
  import Helper as He
7
8
  except ImportError:
@@ -96,10 +97,21 @@ def _groupby(groupby_, alias_map, baseDict: dict):
96
97
  def _orderby(orderby_, alias_map, baseDict: dict):
97
98
  orderby_tokens = []
98
99
  if isinstance(orderby_, Identifier):
99
- orderby_tokens.append(_identifier(orderby_, alias_map, baseDict).lower())
100
+ if len(orderby_.tokens) > 0 and orderby_.tokens[-1].ttype==Keyword.Order:
101
+ for tok in orderby_.tokens:
102
+ if isinstance(tok, Identifier):
103
+ orderby_tokens.append(_identifier(tok, alias_map, baseDict).lower())
104
+ if tok.ttype==Keyword.Order:
105
+ orderby_tokens[-1] += (" "+tok.value)
106
+ else:
107
+ orderby_tokens.append(_identifier(orderby_, alias_map, baseDict).lower())
108
+ orderby_tokens[-1] += " ASC"
100
109
  elif isinstance(orderby_, IdentifierList):
101
- for identifier in orderby_.get_identifiers():
102
- orderby_tokens.append(_identifier(identifier, alias_map, baseDict).lower())
110
+ for tok in orderby_.tokens:
111
+ if isinstance(tok, Identifier):
112
+ orderby_tokens.append(_identifier(tok, alias_map, baseDict).lower())
113
+ #elif isinstance(orderby_, Order):
114
+ # pass
103
115
  # orderby_tokens.sort()
104
116
  return ",".join(orderby_tokens)
105
117
 
@@ -120,6 +132,10 @@ def _condition(token, alias_map, baseDict: dict):
120
132
  operator.value = "<"
121
133
  elif operator.value == "<":
122
134
  operator.value = ">"
135
+ elif operator.value == ">=":
136
+ operator.value = "<="
137
+ elif operator.value == "<=":
138
+ operator.value = ">="
123
139
  leftLiteral = rightLiteral
124
140
  rightLiteral = True
125
141
  flipAllowed = False
@@ -133,6 +149,10 @@ def _condition(token, alias_map, baseDict: dict):
133
149
  operator = "<"
134
150
  elif operator.value == "<":
135
151
  operator = ">"
152
+ if operator.value == ">=":
153
+ operator = "<="
154
+ elif operator.value == "<=":
155
+ operator = ">="
136
156
 
137
157
  return f"{left if leftLiteral else left.lower()} {operator} {right if rightLiteral else right.lower()}"
138
158
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: sql_testing_tools
3
- Version: 0.2.1
3
+ Version: 0.2.3
4
4
  Description-Content-Type: text/markdown
5
5
  Requires-Dist: sqlparse>=0.5.1
6
6
  Requires-Dist: requests>=2.32.3
@@ -11,10 +11,21 @@ Dynamic: requires-dist
11
11
  A library that normalizes simple SQL queries and compares them first by equality of the normalized string and then using the cosette API.
12
12
 
13
13
 
14
+
14
15
  ### [Beta in Development!]
15
16
  [![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)
16
17
  [![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)
17
18
 
19
+ Submit bug reports and features requests at: https://github.com/ValentinHerrmann/sql_testing_tools
20
+
21
+ ### V 0.2.3
22
+ - fix: ASC/DESC in ORDER BY (also with multiple columns and order directions), no direction treated as ASC
23
+ - Verified that ; and whitespaces, linebreaks at end of query are ignored
24
+
25
+ ### V 0.2.2
26
+ - Support LIKE
27
+ - Support '<=' and '>=' (geq and leq)
28
+
18
29
  ### V 0.2.1
19
30
  - Support LIMIT
20
31
 
@@ -29,6 +40,7 @@ A library that normalizes simple SQL queries and compares them first by equality
29
40
 
30
41
  ### V 0.1.4 + V 0.1.5
31
42
  - Chained conditions (with AND,OR and Paranthesises) in WHERE statement
43
+ - Aggregate Functions
32
44
 
33
45
  ### V 0.1.3
34
46
  - SELECT: columns with our without table prefix