sql-blocks 1.2025.630__tar.gz → 1.2025.702__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.1
2
2
  Name: sql_blocks
3
- Version: 1.2025.630
3
+ Version: 1.2025.702
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sql_blocks"
3
- version = "1.2025.0630"
3
+ version = "1.2025.0702"
4
4
  authors = [
5
5
  { name="Julio Cascalles", email="julio.cascalles@outlook.com" },
6
6
  ]
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
 
4
4
  setup(
5
5
  name = 'sql_blocks',
6
- version = '1.2025.0630',
6
+ version = '1.2025.0702',
7
7
  author = 'Júlio Cascalles',
8
8
  author_email = 'julio.cascalles@outlook.com',
9
9
  packages = ['sql_blocks'],
@@ -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 += '{}{} {}'.format(
408
+ keywords += '{}{}'.format(
409
409
  '\n\t\t' if self.break_lines else ' ',
410
- obj.cls_to_str(), field if field != '_' else ''
410
+ obj.cls_to_str(field if field != '_' else '')
411
411
  )
412
412
  if keywords and self.break_lines:
413
413
  keywords += '\n\t'
@@ -774,13 +774,18 @@ class If(Code, Frame):
774
774
  self.field = field
775
775
  self.condition = condition
776
776
  self.func_class = func_class
777
+ self.pattern = ''
777
778
  super().__init__()
778
779
 
779
780
  def format(self, name: str, main: SQLObject) -> str:
780
- return '{func}({param})'.format(
781
+ return '{func}({param}){over}'.format(
781
782
  func=self.func_class.__name__,
782
- param=Case(self.field).when(self.condition, f'={name}').else_value(0)
783
+ param=Case(self.field).when(self.condition, f'={name}').else_value(0),
784
+ over=self.pattern
783
785
  )
786
+
787
+ def get_pattern(self) -> str:
788
+ return ''
784
789
 
785
790
 
786
791
  class Options:
@@ -881,7 +886,7 @@ class Rows:
881
886
  def __init__(self, *rows: list[Row]):
882
887
  self.rows = rows
883
888
 
884
- def cls_to_str(self) -> str:
889
+ def cls_to_str(self, field: str='') -> str:
885
890
  return 'ROWS {}{}'.format(
886
891
  'BETWEEN ' if len(self.rows) > 1 else '',
887
892
  ' AND '.join(str(row) for row in self.rows)
@@ -894,6 +899,11 @@ class DescOrderBy:
894
899
  name = Clause.format(name, main)
895
900
  main.values.setdefault(ORDER_BY, []).append(name + SortType.DESC.value)
896
901
 
902
+ @classmethod
903
+ def cls_to_str(cls, field: str='') -> str:
904
+ return f"{ORDER_BY} {field} DESC"
905
+
906
+
897
907
  class OrderBy(Clause):
898
908
  sort: SortType = SortType.ASC
899
909
  DESC = DescOrderBy
@@ -918,14 +928,13 @@ class OrderBy(Clause):
918
928
  return super().format(name, main)
919
929
 
920
930
  @classmethod
921
- def cls_to_str(cls) -> str:
922
- return ORDER_BY
931
+ def cls_to_str(cls, field: str='') -> str:
932
+ return f"{ORDER_BY} {field}"
923
933
 
924
- PARTITION_BY = 'PARTITION BY'
925
934
  class Partition:
926
935
  @classmethod
927
- def cls_to_str(cls) -> str:
928
- return PARTITION_BY
936
+ def cls_to_str(cls, field: str) -> str:
937
+ return f'PARTITION BY {field}'
929
938
 
930
939
 
931
940
  class GroupBy(Clause):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 1.2025.630
3
+ Version: 1.2025.702
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