sql-blocks 1.20250712__py3-none-any.whl → 1.20250713__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
@@ -2203,14 +2203,25 @@ class CTEFactory:
2203
2203
  Table1(field, `function$`field`:alias`, `group@`) <- Table2(field)
2204
2204
  `...`MainTable(field)
2205
2205
  """
2206
- self.main = None
2207
2206
  if parser_class(txt) == CypherParser:
2208
- if '...' in txt:
2209
- txt, other = txt.split('...')
2210
- self.main = detect(other)
2211
- alias = self.main.table_name
2207
+ txt, main_script = txt.split('...')
2212
2208
  query_list = Select.parse(txt, CypherParser)
2213
- if not self.main:
2209
+ if main_script:
2210
+ main_script = ''.join(main_script)
2211
+ if '(*)' in main_script:
2212
+ field_list = [
2213
+ re.split(
2214
+ r'\bas\b|\bAS\b', field
2215
+ )[-1].strip()
2216
+ for query in query_list
2217
+ for field in query.values.get(SELECT, [])
2218
+ ]
2219
+ main_script = main_script.replace('(*)', '({}, *)'.format(
2220
+ ','.join(field_list)
2221
+ ))
2222
+ self.main = detect(main_script)
2223
+ alias = self.main.table_name
2224
+ else:
2214
2225
  alias = '_'.join(query.table_name for query in query_list)
2215
2226
  self.main = Select(alias)
2216
2227
  self.main.break_lines = False
@@ -2439,6 +2450,6 @@ if __name__ == "__main__":
2439
2450
  # | |
2440
2451
  # +--- The Sales table |
2441
2452
  # Also groups by vendor´s name ------------------+
2442
- "...Annual_Sales_per_Vendor(ref_year, qty_sold, vendors_name, *) -> Goal(year, target)"
2453
+ "...Annual_Sales_per_Vendor(*) -> Goal(year, target)"
2443
2454
  )
2444
2455
  print(cte)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 1.20250712
3
+ Version: 1.20250713
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
@@ -995,7 +995,14 @@ results...
995
995
 
996
996
  #### 17.3.1 - You can also pass a Cypher script like in the example below:
997
997
 
998
- ![image](assets/CTEFactory.png)
998
+ cte = CTEFactory(
999
+ "Sales(year$ref_date:ref_year@, sum$quantity:qty_sold, vendor)"
1000
+ " <- Vendor(id, name:vendors_name@)"
1001
+ "...Annual_Sales_per_Vendor(*) -> Goal(year, target)"
1002
+ )
1003
+ print(cte)
1004
+
1005
+ ![image](https://raw.githubusercontent.com/julio-cascalles/sql_blocks/refs/heads/master/assets/CTEFactory.png)
999
1006
 
1000
1007
  results...
1001
1008
  ```
@@ -0,0 +1,7 @@
1
+ sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
2
+ sql_blocks/sql_blocks.py,sha256=h5toXPu_0Nw9VaifIXAVlLBOKAv1Oz2Iw2kQSVEbk4Y,84392
3
+ sql_blocks-1.20250713.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
+ sql_blocks-1.20250713.dist-info/METADATA,sha256=OnjjmdmJU39ADp7D1IS6FmC020iIqguDP1MbkKCdJtg,25388
5
+ sql_blocks-1.20250713.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ sql_blocks-1.20250713.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
+ sql_blocks-1.20250713.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
2
- sql_blocks/sql_blocks.py,sha256=A-i1B6jUA6_SYRfZAA65mhqHMkSQApXO7NcmIt3O5O8,83911
3
- sql_blocks-1.20250712.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
- sql_blocks-1.20250712.dist-info/METADATA,sha256=Kj2I_aL5fxL2bxn3hoj8hb54kKDt3M510VDn8mGmA7o,25079
5
- sql_blocks-1.20250712.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- sql_blocks-1.20250712.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
- sql_blocks-1.20250712.dist-info/RECORD,,