sql-blocks 1.25.1801__py3-none-any.whl → 1.25.1901__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.
- sql_blocks/sql_blocks.py +16 -14
- {sql_blocks-1.25.1801.dist-info → sql_blocks-1.25.1901.dist-info}/METADATA +1 -1
- sql_blocks-1.25.1901.dist-info/RECORD +7 -0
- sql_blocks-1.25.1801.dist-info/RECORD +0 -7
- {sql_blocks-1.25.1801.dist-info → sql_blocks-1.25.1901.dist-info}/LICENSE +0 -0
- {sql_blocks-1.25.1801.dist-info → sql_blocks-1.25.1901.dist-info}/WHEEL +0 -0
- {sql_blocks-1.25.1801.dist-info → sql_blocks-1.25.1901.dist-info}/top_level.txt +0 -0
sql_blocks/sql_blocks.py
CHANGED
@@ -335,6 +335,9 @@ class Cast(Function):
|
|
335
335
|
...
|
336
336
|
|
337
337
|
|
338
|
+
FUNCTION_CLASS = {f.__name__.lower(): f for f in Function.__subclasses__()}
|
339
|
+
|
340
|
+
|
338
341
|
class ExpressionField:
|
339
342
|
def __init__(self, expr: str):
|
340
343
|
self.expr = expr
|
@@ -468,8 +471,13 @@ class Where:
|
|
468
471
|
return cls(f'IN ({values})')
|
469
472
|
|
470
473
|
def add(self, name: str, main: SQLObject):
|
474
|
+
func_type = FUNCTION_CLASS.get(name.lower())
|
475
|
+
if func_type:
|
476
|
+
name = func_type.format('*', main)
|
477
|
+
else:
|
478
|
+
name = Field.format(name, main)
|
471
479
|
main.values.setdefault(WHERE, []).append('{}{} {}'.format(
|
472
|
-
self.prefix,
|
480
|
+
self.prefix, name, self.expr
|
473
481
|
))
|
474
482
|
|
475
483
|
|
@@ -549,7 +557,6 @@ class Clause:
|
|
549
557
|
def format(cls, name: str, main: SQLObject) -> str:
|
550
558
|
def is_function() -> bool:
|
551
559
|
diff = main.diff(SELECT, [name.lower()], True)
|
552
|
-
FUNCTION_CLASS = {f.__name__.lower(): f for f in Function.__subclasses__()}
|
553
560
|
return diff.intersection(FUNCTION_CLASS)
|
554
561
|
found = re.findall(r'^_\d', name)
|
555
562
|
if found:
|
@@ -1068,7 +1075,6 @@ class CypherParser(Parser):
|
|
1068
1075
|
Count().As(token, extra_classes).add(pk_field, self.queries[-1])
|
1069
1076
|
return
|
1070
1077
|
else:
|
1071
|
-
FUNCTION_CLASS = {f.__name__.lower(): f for f in Function.__subclasses__()}
|
1072
1078
|
class_list = [ FUNCTION_CLASS[func_name] ]
|
1073
1079
|
class_list += extra_classes
|
1074
1080
|
FieldList(token, class_list).add('', self.queries[-1])
|
@@ -1544,14 +1550,10 @@ def detect(text: str, join_queries: bool = True) -> Select:
|
|
1544
1550
|
|
1545
1551
|
|
1546
1552
|
if __name__ == '__main__':
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
'due_date'
|
1555
|
-
).As('elapsed_time')
|
1556
|
-
).limit(10)
|
1557
|
-
print(query)
|
1553
|
+
query = Select(
|
1554
|
+
'Tips t',
|
1555
|
+
tip=[Field, Lag().over(day=OrderBy).As('last')],
|
1556
|
+
diff=ExpressionField('Round(tip-last, 2) as {f}'),
|
1557
|
+
Row_Number=gt(1)
|
1558
|
+
)
|
1559
|
+
print(query)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sql_blocks
|
3
|
-
Version: 1.25.
|
3
|
+
Version: 1.25.1901
|
4
4
|
Summary: Allows you to create objects for parts of SQL query commands. Also to combine these objects by joining them, adding or removing parts...
|
5
5
|
Home-page: https://github.com/julio-cascalles/sql_blocks
|
6
6
|
Author: Júlio Cascalles
|
@@ -0,0 +1,7 @@
|
|
1
|
+
sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
|
2
|
+
sql_blocks/sql_blocks.py,sha256=U2bcs8SnXcGOlsY9rhB3lpPzzb-W4MsG64N7r0QjKEI,51822
|
3
|
+
sql_blocks-1.25.1901.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
+
sql_blocks-1.25.1901.dist-info/METADATA,sha256=MCkLq9JFvLiVAEJc_IhDLd3rExUKeVa04EtC9IwJwsA,15027
|
5
|
+
sql_blocks-1.25.1901.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
sql_blocks-1.25.1901.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
+
sql_blocks-1.25.1901.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
|
2
|
-
sql_blocks/sql_blocks.py,sha256=iFS3drlQaazFkbBBFIH58RPZt4Lhe6R2Xqi_Ujef7Bg,51893
|
3
|
-
sql_blocks-1.25.1801.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
-
sql_blocks-1.25.1801.dist-info/METADATA,sha256=WnwFnhle4YXNyeC6dBVAnQmUqJiboT1CDhbvRHOmEQY,15027
|
5
|
-
sql_blocks-1.25.1801.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
sql_blocks-1.25.1801.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
-
sql_blocks-1.25.1801.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|