sql-blocks 1.2025.630__tar.gz → 1.2025.701__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.
- {sql_blocks-1.2025.630/sql_blocks.egg-info → sql_blocks-1.2025.701}/PKG-INFO +1 -1
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/pyproject.toml +1 -1
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/setup.py +1 -1
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/sql_blocks/sql_blocks.py +31 -11
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701/sql_blocks.egg-info}/PKG-INFO +1 -1
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/LICENSE +0 -0
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/README.md +0 -0
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/setup.cfg +0 -0
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/sql_blocks/__init__.py +0 -0
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/sql_blocks.egg-info/SOURCES.txt +0 -0
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/sql_blocks.egg-info/dependency_links.txt +0 -0
- {sql_blocks-1.2025.630 → sql_blocks-1.2025.701}/sql_blocks.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sql_blocks
|
3
|
-
Version: 1.2025.
|
3
|
+
Version: 1.2025.701
|
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
|
@@ -399,15 +399,15 @@ class Frame:
|
|
399
399
|
keywords = ''
|
400
400
|
for field, obj in args.items():
|
401
401
|
is_valid = any([
|
402
|
-
obj is OrderBy,
|
402
|
+
obj is OrderBy, obj is DescOrderBy,
|
403
403
|
obj is Partition,
|
404
404
|
isinstance(obj, Rows),
|
405
405
|
])
|
406
406
|
if not is_valid:
|
407
407
|
continue
|
408
|
-
keywords += '{}{}
|
408
|
+
keywords += '{}{}'.format(
|
409
409
|
'\n\t\t' if self.break_lines else ' ',
|
410
|
-
obj.cls_to_str(
|
410
|
+
obj.cls_to_str(field if field != '_' else '')
|
411
411
|
)
|
412
412
|
if keywords and self.break_lines:
|
413
413
|
keywords += '\n\t'
|
@@ -777,10 +777,14 @@ class If(Code, Frame):
|
|
777
777
|
super().__init__()
|
778
778
|
|
779
779
|
def format(self, name: str, main: SQLObject) -> str:
|
780
|
-
return '{func}({param})'.format(
|
780
|
+
return '{func}({param}){over}'.format(
|
781
781
|
func=self.func_class.__name__,
|
782
|
-
param=Case(self.field).when(self.condition, f'={name}').else_value(0)
|
782
|
+
param=Case(self.field).when(self.condition, f'={name}').else_value(0),
|
783
|
+
over=self.pattern
|
783
784
|
)
|
785
|
+
|
786
|
+
def get_pattern(self) -> str:
|
787
|
+
return ''
|
784
788
|
|
785
789
|
|
786
790
|
class Options:
|
@@ -881,7 +885,7 @@ class Rows:
|
|
881
885
|
def __init__(self, *rows: list[Row]):
|
882
886
|
self.rows = rows
|
883
887
|
|
884
|
-
def cls_to_str(self) -> str:
|
888
|
+
def cls_to_str(self, field: str='') -> str:
|
885
889
|
return 'ROWS {}{}'.format(
|
886
890
|
'BETWEEN ' if len(self.rows) > 1 else '',
|
887
891
|
' AND '.join(str(row) for row in self.rows)
|
@@ -894,6 +898,11 @@ class DescOrderBy:
|
|
894
898
|
name = Clause.format(name, main)
|
895
899
|
main.values.setdefault(ORDER_BY, []).append(name + SortType.DESC.value)
|
896
900
|
|
901
|
+
@classmethod
|
902
|
+
def cls_to_str(cls, field: str='') -> str:
|
903
|
+
return f"{ORDER_BY} {field} DESC"
|
904
|
+
|
905
|
+
|
897
906
|
class OrderBy(Clause):
|
898
907
|
sort: SortType = SortType.ASC
|
899
908
|
DESC = DescOrderBy
|
@@ -918,14 +927,13 @@ class OrderBy(Clause):
|
|
918
927
|
return super().format(name, main)
|
919
928
|
|
920
929
|
@classmethod
|
921
|
-
def cls_to_str(cls) -> str:
|
922
|
-
return ORDER_BY
|
930
|
+
def cls_to_str(cls, field: str='') -> str:
|
931
|
+
return f"{ORDER_BY} {field}"
|
923
932
|
|
924
|
-
PARTITION_BY = 'PARTITION BY'
|
925
933
|
class Partition:
|
926
934
|
@classmethod
|
927
|
-
def cls_to_str(cls) -> str:
|
928
|
-
return
|
935
|
+
def cls_to_str(cls, field: str) -> str:
|
936
|
+
return f'PARTITION BY {field}'
|
929
937
|
|
930
938
|
|
931
939
|
class GroupBy(Clause):
|
@@ -2322,3 +2330,15 @@ def detect(text: str, join_queries: bool = True, format: str='') -> Select | lis
|
|
2322
2330
|
result += query
|
2323
2331
|
return result
|
2324
2332
|
# ===========================================================================================//
|
2333
|
+
|
2334
|
+
if __name__ == "__main__":
|
2335
|
+
query = Select(
|
2336
|
+
'Emprestimos e',
|
2337
|
+
taxa=If('atraso', gt(0), Sum).over(
|
2338
|
+
mes_ano=OrderBy.DESC,
|
2339
|
+
_=Rows(Current(), Following(5)),
|
2340
|
+
# _=Rows(Preceding(3), Following()),
|
2341
|
+
# _=Rows( Preceding(3) ),
|
2342
|
+
).As('multa')
|
2343
|
+
)
|
2344
|
+
print(query)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sql_blocks
|
3
|
-
Version: 1.2025.
|
3
|
+
Version: 1.2025.701
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|