queryparser-python3 0.7.0__py3-none-any.whl → 0.7.1__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.
- queryparser/__init__.py +1 -1
- queryparser/adql/ADQLParser.py +1034 -995
- queryparser/adql/adqltranslator.py +40 -14
- {queryparser_python3-0.7.0.dist-info → queryparser_python3-0.7.1.dist-info}/METADATA +6 -5
- {queryparser_python3-0.7.0.dist-info → queryparser_python3-0.7.1.dist-info}/RECORD +8 -8
- {queryparser_python3-0.7.0.dist-info → queryparser_python3-0.7.1.dist-info}/WHEEL +1 -1
- {queryparser_python3-0.7.0.dist-info → queryparser_python3-0.7.1.dist-info/licenses}/LICENSE +0 -0
- {queryparser_python3-0.7.0.dist-info → queryparser_python3-0.7.1.dist-info}/top_level.txt +0 -0
|
@@ -22,9 +22,17 @@ adql_function_names = ('ABS', 'ACOS', 'ASIN', 'ATAN', 'ATAN2', 'CEILING',
|
|
|
22
22
|
'SQRT', 'TAN', 'TRUNCATE')
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def
|
|
25
|
+
def _removeFirstChild(ctx):
|
|
26
|
+
if ctx.children is not None:
|
|
27
|
+
del ctx.children[0]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _remove_children(ctx, reverse=False):
|
|
26
31
|
for _ in range(ctx.getChildCount() - 1):
|
|
27
|
-
|
|
32
|
+
if reverse:
|
|
33
|
+
_removeFirstChild(ctx)
|
|
34
|
+
else:
|
|
35
|
+
ctx.removeLastChild()
|
|
28
36
|
|
|
29
37
|
|
|
30
38
|
def _convert_values(ctx, cidx, output_sql):
|
|
@@ -268,8 +276,6 @@ class ADQLGeometryTranslationVisitor(ADQLParserVisitor):
|
|
|
268
276
|
def visitPolygon(self, ctx):
|
|
269
277
|
pars = []
|
|
270
278
|
|
|
271
|
-
for ch in ctx.children:
|
|
272
|
-
print(ch.getText())
|
|
273
279
|
for j in range(2, len(ctx.children), 2):
|
|
274
280
|
par = self._convert_values(ctx, j)
|
|
275
281
|
# only append coordinates
|
|
@@ -351,18 +357,27 @@ class ADQLFunctionsTranslationVisitor(ADQLParserVisitor):
|
|
|
351
357
|
'''
|
|
352
358
|
|
|
353
359
|
def visitContains_predicate(self, ctx):
|
|
354
|
-
|
|
355
|
-
|
|
360
|
+
comp_value_l = ctx.children[0].getText()
|
|
361
|
+
comp_value_r = ctx.children[2].getText()
|
|
362
|
+
if comp_value_l == '1' or comp_value_l == '0':
|
|
356
363
|
self.visitContains(ctx.children[2])
|
|
357
364
|
ctx_text = self.contexts[ctx.children[2]]
|
|
358
365
|
if self.output_sql == 'mysql':
|
|
359
|
-
ctx_text = f"{
|
|
360
|
-
elif self.output_sql == 'postgresql' and
|
|
366
|
+
ctx_text = f"{comp_value_l} = {ctx_text}"
|
|
367
|
+
elif self.output_sql == 'postgresql' and comp_value_l == '0':
|
|
368
|
+
ctx_text = ctx_text.replace('@', '!@')
|
|
369
|
+
_remove_children(ctx)
|
|
370
|
+
elif comp_value_r == '1' or comp_value_r == '0':
|
|
371
|
+
self.visitContains(ctx.children[0])
|
|
372
|
+
ctx_text = self.contexts[ctx.children[0]]
|
|
373
|
+
if self.output_sql == 'mysql':
|
|
374
|
+
ctx_text = f"{comp_value_r} = {ctx_text}"
|
|
375
|
+
elif self.output_sql == 'postgresql' and comp_value_r == '0':
|
|
361
376
|
ctx_text = ctx_text.replace('@', '!@')
|
|
377
|
+
_remove_children(ctx, reverse=True)
|
|
362
378
|
else:
|
|
363
379
|
raise QueryError('The function CONTAINS allows comparison to 1 or 0 only.')
|
|
364
380
|
|
|
365
|
-
_remove_children(ctx)
|
|
366
381
|
self.contexts[ctx] = ctx_text
|
|
367
382
|
|
|
368
383
|
|
|
@@ -415,21 +430,32 @@ class ADQLFunctionsTranslationVisitor(ADQLParserVisitor):
|
|
|
415
430
|
ctx.removeLastChild()
|
|
416
431
|
self.contexts[ctx] = ctx_text
|
|
417
432
|
|
|
433
|
+
|
|
418
434
|
def visitIntersects_predicate(self, ctx):
|
|
419
|
-
|
|
420
|
-
|
|
435
|
+
comp_value_l = ctx.children[0].getText()
|
|
436
|
+
comp_value_r = ctx.children[2].getText()
|
|
437
|
+
if comp_value_l == '1' or comp_value_l == '0':
|
|
421
438
|
self.visitIntersects(ctx.children[2])
|
|
422
439
|
ctx_text = self.contexts[ctx.children[2]]
|
|
423
440
|
if self.output_sql == 'mysql':
|
|
424
|
-
ctx_text = f"{
|
|
425
|
-
elif self.output_sql == 'postgresql' and
|
|
441
|
+
ctx_text = f"{comp_value_l} = {ctx_text}"
|
|
442
|
+
elif self.output_sql == 'postgresql' and comp_value_l == '0':
|
|
426
443
|
ctx_text = ctx_text.replace('&&', '!&&')
|
|
444
|
+
_remove_children(ctx)
|
|
445
|
+
elif comp_value_r == '1' or comp_value_r == '0':
|
|
446
|
+
self.visitIntersects(ctx.children[0])
|
|
447
|
+
ctx_text = self.contexts[ctx.children[0]]
|
|
448
|
+
if self.output_sql == 'mysql':
|
|
449
|
+
ctx_text = f"{comp_value_r} = {ctx_text}"
|
|
450
|
+
elif self.output_sql == 'postgresql' and comp_value_r == '0':
|
|
451
|
+
ctx_text = ctx_text.replace('&&', '!&&')
|
|
452
|
+
_remove_children(ctx, reverse=True)
|
|
427
453
|
else:
|
|
428
454
|
raise QueryError('The function INTERSECTS allows comparison to 1 or 0 only.')
|
|
429
455
|
|
|
430
|
-
_remove_children(ctx)
|
|
431
456
|
self.contexts[ctx] = ctx_text
|
|
432
457
|
|
|
458
|
+
|
|
433
459
|
def visitIntersects(self, ctx):
|
|
434
460
|
arg = (self.contexts[ctx.children[2].children[0]],
|
|
435
461
|
self.contexts[ctx.children[4].children[0]])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: queryparser-python3
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: Package for parsing PostgreSQL/MySQL and translating ADQL to PostgreSQL/MySQL.
|
|
5
5
|
Author-email: Gal Matijevic <gmatijevic@aip.de>
|
|
6
6
|
Maintainer-email: Kirill Makan <kmakan@aip.de>
|
|
@@ -20,10 +20,11 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Requires-Python: >=3.9
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: antlr4-python3-runtime
|
|
23
|
+
Requires-Dist: antlr4-python3-runtime==4.13.1
|
|
24
24
|
Provides-Extra: test
|
|
25
|
-
Requires-Dist: pytest
|
|
26
|
-
Requires-Dist: PyYAML
|
|
25
|
+
Requires-Dist: pytest~=8.2.0; extra == "test"
|
|
26
|
+
Requires-Dist: PyYAML~=6.0; extra == "test"
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
|
|
28
29
|
queryparser
|
|
29
30
|
===========
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
queryparser/__init__.py,sha256=
|
|
1
|
+
queryparser/__init__.py,sha256=x2pOclYRECzfJMAd4sw67W_FEUEXKPUoISgurYPhSRg,22
|
|
2
2
|
queryparser/adql/ADQLLexer.py,sha256=JVQ_TseEuYMaNr3kHBw50oKMuu4Au1vWak8u1dQAavs,89907
|
|
3
|
-
queryparser/adql/ADQLParser.py,sha256=
|
|
3
|
+
queryparser/adql/ADQLParser.py,sha256=_kswLJMJIR9EwMhpS17xRC2hcSZo8O1ygkXlHc7Vd0s,370976
|
|
4
4
|
queryparser/adql/ADQLParserListener.py,sha256=V80PMXEy6hoQMwRqExOFRvJocH2eBIdR3BbxW1t14Dk,39836
|
|
5
5
|
queryparser/adql/ADQLParserVisitor.py,sha256=YpDeQorBMJG4AWeBQk7Gxdijmf302WuY83iWu5taOZo,23612
|
|
6
6
|
queryparser/adql/__init__.py,sha256=QjRobun31YF-F8qf66RtwjRgRgRiQjLIao4jaIE5Lv8,108
|
|
7
|
-
queryparser/adql/adqltranslator.py,sha256=
|
|
7
|
+
queryparser/adql/adqltranslator.py,sha256=8opHoxIbXBeZ2oZ3YC4w2EvsnDlHfJcs7BDJtDcxtg4,25582
|
|
8
8
|
queryparser/common/__init__.py,sha256=k1jnIaxY1TYG8dVXokbsT9Q56msjKRfOSTPEhWbo3GE,214
|
|
9
9
|
queryparser/common/common.py,sha256=cpolo-LaV9xK7aurSPwr58sMine_FJ1J5ZHacV_fvqY,35075
|
|
10
10
|
queryparser/exceptions/__init__.py,sha256=zVJsC5p3_CfpC0wDdVbS0-HLIbRGz6-xMa5K5_qX82A,247
|
|
@@ -20,8 +20,8 @@ queryparser/postgresql/PostgreSQLParserListener.py,sha256=Fm30DYmRbnAJKAxuE7WH7D
|
|
|
20
20
|
queryparser/postgresql/__init__.py,sha256=Y06UttOdTusJH1hHDdmm1XOwNP1K03c7K1iNJrh7Yyw,123
|
|
21
21
|
queryparser/postgresql/postgresqllisteners.py,sha256=wCyqDsNPQ2Hl0odXy-ZZmI3HB_6CY7LvwkQDogOLONg,72
|
|
22
22
|
queryparser/postgresql/postgresqlprocessor.py,sha256=ruxpXQlHOC8YHSbCM3MbYeVtzzDJUu_0zckv7Sg4KvE,708
|
|
23
|
-
queryparser_python3-0.7.
|
|
24
|
-
queryparser_python3-0.7.
|
|
25
|
-
queryparser_python3-0.7.
|
|
26
|
-
queryparser_python3-0.7.
|
|
27
|
-
queryparser_python3-0.7.
|
|
23
|
+
queryparser_python3-0.7.1.dist-info/licenses/LICENSE,sha256=oRiVx4r69ZT4QO-yy0V8lx8xhGm_OudJKSjd-Q6NL9Q,25853
|
|
24
|
+
queryparser_python3-0.7.1.dist-info/METADATA,sha256=_4RpAUOXYEvIJFBP9r4wWvqJONJSCK_xftKioEvpeTY,5537
|
|
25
|
+
queryparser_python3-0.7.1.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
|
26
|
+
queryparser_python3-0.7.1.dist-info/top_level.txt,sha256=SsQ3yI4UEjGsc6tHaZTmHTdvhAk4Itp5BGQ-J-zvx7U,12
|
|
27
|
+
queryparser_python3-0.7.1.dist-info/RECORD,,
|
{queryparser_python3-0.7.0.dist-info → queryparser_python3-0.7.1.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|