sql-testing-tools 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl

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.
@@ -152,7 +152,7 @@ def buildAndSendCosetteRequest(baseDict, sql, sol):
152
152
  def checkKeywords(startWord:str, endWords:list):
153
153
  global sql,sol
154
154
 
155
- if(startWord not in sol or startWord not in sql):
155
+ if(startWord not in sol and startWord not in sql):
156
156
  return ""
157
157
 
158
158
  if(startWord in sql):
@@ -186,119 +186,30 @@ def checkKeywords(startWord:str, endWords:list):
186
186
  return "Der '"+startWord+"' Teil der SQL-Abfrage ist nicht korrekt (oder nicht automatisch überprüfbar)."
187
187
 
188
188
 
189
-
190
-
191
189
  def checkColumns(sqlPath="", solPath=""):
192
190
  global sql,sol
193
191
  setup(sqlPath, solPath)
194
192
  return checkKeywords("SELECT", ["FROM", "WHERE", "GROUP BY", "ORDER BY", "LIMIT", ";", "HAVING"])
195
193
 
196
194
 
197
-
198
-
199
- if("SELECT" in sql and "FROM" in sql):
200
- start = str.find(sql, "SELECT")
201
- end = str.find(sql, "FROM")
202
- submission = str.strip(sql[start:end])
203
- print("'"+submission+"'")
204
-
205
- start = str.find(sol, "SELECT")
206
- end = str.find(sol, "FROM")
207
- solution = str.strip(sol[start:end])
208
- print("'"+solution+"'")
209
-
210
- if submission == solution:
211
- return ""
212
- return "Ausgegebene Spalten sind nicht korrekt (oder nicht automatisch überprüfbar)."
213
-
214
195
  def checkTables(sqlPath="", solPath=""):
215
196
  global sql,sol
216
197
  setup(sqlPath, solPath)
217
198
  return checkKeywords("FROM", ["FROM", "WHERE", "GROUP BY", "ORDER BY", "LIMIT", ";", "HAVING"])
218
199
 
219
200
 
220
-
221
-
222
- if("SELECT" in sql and "FROM" in sql):
223
- endFromKeywords = ["WHERE", "GROUP", "ORDER", "LIMIT", ";"]
224
-
225
- start = str.find(sql, "FROM")
226
- end = -1
227
-
228
-
229
- for keyword in endFromKeywords:
230
- if(str.find(sql, keyword) != -1):
231
- end = str.find(sql, keyword)
232
- break
233
- if(end == -1):
234
- end = len(sql)
235
-
236
- submission = str.strip(sql[start:end])
237
- print("'"+submission+"'")
238
-
239
- start = str.find(sol, "FROM")
240
- end = -1
241
-
242
- for keyword in endFromKeywords:
243
- if(str.find(sol, keyword) != -1):
244
- end = str.find(sol, keyword)
245
- break
246
- if(end == -1):
247
- end = len(sol)
248
-
249
- solution = str.strip(sol[start:end])
250
- print("'"+solution+"'")
251
-
252
- if submission == solution:
253
- return ""
254
- return "Verwendete Tabellen sind nicht korrekt (oder nicht automatisch überprüfbar)."
255
-
256
201
  def checkCondition(sqlPath="", solPath=""):
257
202
  global sql,sol
258
203
  setup(sqlPath, solPath)
259
204
  return checkKeywords("WHERE", ["GROUP BY", "ORDER BY", "LIMIT", ";", "HAVING"])
260
205
 
206
+
261
207
  def checkOrder(sqlPath="", solPath=""):
262
208
  global sql,sol
263
209
  setup(sqlPath, solPath)
264
210
  return checkKeywords("ORDER BY", ["WHERE", "GROUP BY", "ORDER BY", "LIMIT", ";", "HAVING"])
265
211
 
266
212
 
267
-
268
- if("ORDER BY" in sql):
269
- endFromKeywords = ["WHERE", "GROUP", "LIMIT", ";"]
270
-
271
- start = str.find(sql, "ORDER BY")
272
- end = -1
273
-
274
-
275
- for keyword in endFromKeywords:
276
- if(str.find(sql, keyword) != -1):
277
- end = str.find(sql, keyword)
278
- break
279
- if(end == -1):
280
- end = len(sql)
281
-
282
- submission = str.strip(sql[start:end])
283
- print("'"+submission+"'")
284
-
285
- start = str.find(sol, "ORDER BY")
286
- end = -1
287
-
288
- for keyword in endFromKeywords:
289
- if(str.find(sol, keyword) != -1):
290
- end = str.find(sol, keyword)
291
- break
292
- if(end == -1):
293
- end = len(sol)
294
-
295
- solution = str.strip(sol[start:end])
296
- print("'"+solution+"'")
297
-
298
- if submission == solution:
299
- return ""
300
- return "Die Sortierung ist nicht korrekt (oder nicht automatisch überprüfbar)."
301
-
302
213
  def checkGroup(sqlPath="", solPath=""):
303
214
  global sql,sol
304
215
  setup(sqlPath, solPath)
@@ -306,17 +217,17 @@ def checkGroup(sqlPath="", solPath=""):
306
217
 
307
218
 
308
219
  def checkEquality(sqlPath="", solPath=""):
309
- global sql,sol
220
+ global sql, sol
310
221
  setup(sqlPath, solPath)
311
222
 
312
- if(sql==sol):
223
+ if sql == sol:
313
224
  return ""
314
225
 
315
226
  result = buildAndSendCosetteRequest(bd, sql, sol)
316
227
 
317
- if(result[0] == "ERR"):
228
+ if result[0] == "ERR":
318
229
  return "\n\nFehler bei der automatischen Überprüfung der Abgabe. Es kann keine Aussage über die Korrektheit der Abgabe getroffen werden."
319
- elif(result[0] != "EQ"):
230
+ elif result[0] != "EQ":
320
231
  return "\n\nDie Abgabe stimmt nicht mit der Musterlösung überein."
321
232
  return ""
322
233
 
@@ -143,6 +143,11 @@ def _condition(token, alias_map, baseDict: dict):
143
143
  left = _identifier(left, alias_map, baseDict)
144
144
  right = _identifier(right, alias_map, baseDict)
145
145
 
146
+ if operator.value in ("!=", "<>"):
147
+ return f"NOT {left} LIKE {right}"
148
+ if operator.value in ("NOT LIKE"):
149
+ return f"NOT {left} LIKE {right}"
150
+
146
151
  if flipAllowed and left.lower() >= right.lower():
147
152
  left, right = right, left
148
153
  if operator.value == ">":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: sql_testing_tools
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Description-Content-Type: text/markdown
5
5
  Requires-Dist: sqlparse>=0.5.1
6
6
  Requires-Dist: requests>=2.32.3
@@ -136,6 +136,13 @@ res = checkEquality()
136
136
 
137
137
  ### Changelog
138
138
 
139
+
140
+ ##### V 0.2.7
141
+ - Normalize String unequality: ...<>..., ...!=..., ...NOT LIKE... --> NOT...LIKE...
142
+
143
+ ##### V 0.2.6
144
+ - Fixed bug in checkKeywords: if keyword was present in one query and not in the other, the comparison was not performed correctly.
145
+
139
146
  ##### V 0.2.5
140
147
  - Added support for [dbiu.de](https://www.datenbanken-im-unterricht.de/catalog.php) databases 1-18 (loaded via [dbiu_databases](https://github.com/ValentinHerrmann/dbiu_databases)) with option to still load DBs from local repo.
141
148
  - Improved docs
@@ -0,0 +1,8 @@
1
+ sql_testing_tools/BaseAccess.py,sha256=VcudaUKwhIF00UxZSYTQAN-6bK6K4Q1zrsSM6VoPF6o,6297
2
+ sql_testing_tools/Helper.py,sha256=ZJ5aT-hvRT7LPaaayupk_OyCpChQCwmIX0ip7YAS1Pc,8278
3
+ sql_testing_tools/TokenProcessing.py,sha256=4FWC1ZtJ33tCKG3c2UFG6uO2BadKCqCP6hIuuK_B2KQ,13761
4
+ sql_testing_tools/__init__.py,sha256=eihMp9aizQd5Lnegu0y57WcyCinmy4Jvp66e0fiMPU4,49
5
+ sql_testing_tools-0.2.7.dist-info/METADATA,sha256=yseH2cUHV5qqEokWy0sBPGaI6ZN46bUP_70PH1KEaPs,7118
6
+ sql_testing_tools-0.2.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
+ sql_testing_tools-0.2.7.dist-info/top_level.txt,sha256=qwEkmfJ_lYhIwcLXgfU75m0_JavVbOg96fN2zSatN3E,18
8
+ sql_testing_tools-0.2.7.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- sql_testing_tools/BaseAccess.py,sha256=VcudaUKwhIF00UxZSYTQAN-6bK6K4Q1zrsSM6VoPF6o,6297
2
- sql_testing_tools/Helper.py,sha256=gduUhpskF7TITInVTf8s33sWg7wsHNi1lYHxOZy5Fj0,10667
3
- sql_testing_tools/TokenProcessing.py,sha256=S3TCdE6XVuR1G14UeQJ4vVtWFt-xahQlHqu-utEhkro,13598
4
- sql_testing_tools/__init__.py,sha256=eihMp9aizQd5Lnegu0y57WcyCinmy4Jvp66e0fiMPU4,49
5
- sql_testing_tools-0.2.5.dist-info/METADATA,sha256=jo8T4wdtjQWkH-a6B98jZrPypHZLJvqIh0vD9YjO1L0,6871
6
- sql_testing_tools-0.2.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
7
- sql_testing_tools-0.2.5.dist-info/top_level.txt,sha256=qwEkmfJ_lYhIwcLXgfU75m0_JavVbOg96fN2zSatN3E,18
8
- sql_testing_tools-0.2.5.dist-info/RECORD,,