sql-blocks 1.25.33022122__py3-none-any.whl → 1.25.33022258__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 CHANGED
@@ -1135,7 +1135,13 @@ class CypherParser(Parser):
1135
1135
  Count().As(token, extra_classes).add(pk_field, self.queries[-1])
1136
1136
  return
1137
1137
  else:
1138
- class_list = [ FUNCTION_CLASS[func_name] ]
1138
+ class_type = FUNCTION_CLASS.get(func_name)
1139
+ if not class_type:
1140
+ raise ValueError(f'Unknown function `{func_name}`.')
1141
+ if ':' in token:
1142
+ token, field_alias = token.split(':')
1143
+ class_type = class_type().As(field_alias)
1144
+ class_list = [class_type]
1139
1145
  class_list += extra_classes
1140
1146
  FieldList(token, class_list).add('', self.queries[-1])
1141
1147
 
@@ -1504,7 +1510,7 @@ class CTE(Select):
1504
1510
  justify(q) for q in self.query_list
1505
1511
  ), super().__str__()
1506
1512
  )
1507
- def join(self, pattern: str, fields: list | str, format: str):
1513
+ def join(self, pattern: str, fields: list | str, format: str=''):
1508
1514
  if isinstance(fields, str):
1509
1515
  count = len( fields.split(',') )
1510
1516
  else:
@@ -1699,15 +1705,8 @@ def detect(text: str, join_queries: bool = True, format: str='') -> Select | lis
1699
1705
 
1700
1706
 
1701
1707
  if __name__ == "__main__":
1702
- FLIGHT_FIELDS = 'departure, arrival'
1703
- R = Recursive.create(
1704
- 'Route R', f'Flyght({FLIGHT_FIELDS})',
1705
- '[2] = R.[1]', 'JFK', '.csv'
1706
- ).join(
1707
- 'Airport(*id,name)', FLIGHT_FIELDS, format='.parquet'
1708
- ).counter(
1709
- 'stops', 0
1708
+ CAMPO_MEDIA = 'MEDIA_SALARIAL_DEPTO'
1709
+ employees = detect(
1710
+ f'Employees@department_id(avg$salary:{CAMPO_MEDIA})'
1710
1711
  )
1711
- print(R)
1712
- print('-'*50)
1713
-
1712
+ print(employees)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 1.25.33022122
3
+ Version: 1.25.33022258
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=dGmMtLWiyluRp1ZwPplmBqPs1nDOL-vemRR0gi2htWA,57513
3
+ sql_blocks-1.25.33022258.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
+ sql_blocks-1.25.33022258.dist-info/METADATA,sha256=GsTRa0fLkerPn-D-ourudj9Pve0oP69IzQ-YGHMtRnI,19574
5
+ sql_blocks-1.25.33022258.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ sql_blocks-1.25.33022258.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
+ sql_blocks-1.25.33022258.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
2
- sql_blocks/sql_blocks.py,sha256=Dup1dUwejLXPa694JpegI3Ky6UnEOsxg_FOClP26qdI,57352
3
- sql_blocks-1.25.33022122.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
- sql_blocks-1.25.33022122.dist-info/METADATA,sha256=AknkUf3x_w302D2UiTCCwhMkCOgoP-tQ5HKjsS2pjYE,19574
5
- sql_blocks-1.25.33022122.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- sql_blocks-1.25.33022122.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
- sql_blocks-1.25.33022122.dist-info/RECORD,,