sql-blocks 1.25.1901__py3-none-any.whl → 1.25.19011745__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
@@ -472,9 +472,14 @@ class Where:
472
472
 
473
473
  def add(self, name: str, main: SQLObject):
474
474
  func_type = FUNCTION_CLASS.get(name.lower())
475
+ exists = any(
476
+ main.is_named_field(fld, SELECT)
477
+ for fld in main.values.get(SELECT, [])
478
+ if name in fld
479
+ )
475
480
  if func_type:
476
481
  name = func_type.format('*', main)
477
- else:
482
+ elif not exists:
478
483
  name = Field.format(name, main)
479
484
  main.values.setdefault(WHERE, []).append('{}{} {}'.format(
480
485
  self.prefix, name, self.expr
@@ -1553,7 +1558,9 @@ if __name__ == '__main__':
1553
1558
  query = Select(
1554
1559
  'Tips t',
1555
1560
  tip=[Field, Lag().over(day=OrderBy).As('last')],
1556
- diff=ExpressionField('Round(tip-last, 2) as {f}'),
1557
- Row_Number=gt(1)
1561
+ diff=[
1562
+ ExpressionField('Round(tip-last, 2) as {f}'),
1563
+ Not.is_null()
1564
+ ]
1558
1565
  )
1559
1566
  print(query)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 1.25.1901
3
+ Version: 1.25.19011745
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=lPUpYOLHjvx84EVjlydJK03rm7qG1DWotRtqyldKqvo,52020
3
+ sql_blocks-1.25.19011745.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
4
+ sql_blocks-1.25.19011745.dist-info/METADATA,sha256=KPw30aPiITpjBHpfWU9yAuTtr8aQ5cW5cdIdzM4iD0k,15031
5
+ sql_blocks-1.25.19011745.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ sql_blocks-1.25.19011745.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
7
+ sql_blocks-1.25.19011745.dist-info/RECORD,,
@@ -1,7 +0,0 @@
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,,