sql-blocks 1.20250713__tar.gz → 1.20250714__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.20250713
3
+ Version: 1.20250714
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.20250713"
3
+ version = "1.20250714"
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.20250713',
6
+ version = '1.20250714',
7
7
  author = 'Júlio Cascalles',
8
8
  author_email = 'julio.cascalles@outlook.com',
9
9
  packages = ['sql_blocks'],
@@ -945,15 +945,16 @@ class OrderBy(Clause):
945
945
 
946
946
  @classmethod
947
947
  def format(cls, name: str, main: SQLObject) -> str:
948
- if cls.ascending(name):
949
- cls.sort = SortType.ASC
950
- else:
948
+ # if cls.ascending(name):
949
+ # cls.sort = SortType.ASC
950
+ # else:
951
+ if not cls.ascending(name):
951
952
  cls.sort = SortType.DESC
952
953
  return super().format(name, main)
953
954
 
954
955
  @classmethod
955
956
  def cls_to_str(cls, field: str='') -> str:
956
- return f"{ORDER_BY} {field}"
957
+ return f"{ORDER_BY} {field}{cls.sort.value}"
957
958
 
958
959
  class Partition:
959
960
  @classmethod
@@ -1064,7 +1065,8 @@ class QueryLanguage:
1064
1065
  return self.join_with_tabs(values, ' AND ')
1065
1066
 
1066
1067
  def sort_by(self, values: list) -> str:
1067
- if OrderBy.sort == SortType.DESC and OrderBy.ascending(values[-1]):
1068
+ is_ascending = OrderBy.ascending(values[-1]) if values else False
1069
+ if OrderBy.sort == SortType.DESC and is_ascending:
1068
1070
  values[-1] += ' DESC'
1069
1071
  return self.join_with_tabs(values, ',')
1070
1072
 
@@ -2436,7 +2438,9 @@ def detect(text: str, join_method = join_queries, format: str='') -> Select | li
2436
2438
  return result
2437
2439
  # ===========================================================================================//
2438
2440
 
2441
+
2439
2442
  if __name__ == "__main__":
2443
+ OrderBy.sort = SortType.DESC
2440
2444
  cte = CTEFactory(
2441
2445
  "Sales(year$ref_date:ref_year@, sum$quantity:qty_sold, vendor) <- Vendor(id, name:vendors_name@)"
2442
2446
  # ^^^ ^^^ ^^^
@@ -2450,6 +2454,6 @@ if __name__ == "__main__":
2450
2454
  # | |
2451
2455
  # +--- The Sales table |
2452
2456
  # Also groups by vendor´s name ------------------+
2453
- "...Annual_Sales_per_Vendor(*) -> Goal(year, target)"
2457
+ "...Annual_Sales_per_Vendor(*) -> Goal(^year, target)"
2454
2458
  )
2455
2459
  print(cte)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 1.20250713
3
+ Version: 1.20250714
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