sql-blocks 0.1.2__tar.gz → 0.1.3__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: 0.1.2
3
+ Version: 0.1.3
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 = "0.1.2"
3
+ version = "0.1.3"
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 = '0.1.2',
6
+ version = '0.1.3',
7
7
  author = 'Júlio Cascalles',
8
8
  author_email = 'julio.cascalles@outlook.com',
9
9
  packages = ['sql_blocks'],
@@ -5,10 +5,10 @@ import re
5
5
  PATTERN_PREFIX = '([^0-9 ]+[.])'
6
6
  PATTERN_SUFFIX = '( [A-Za-z_]+)'
7
7
  SUFFIX_AND_PRE = f'{PATTERN_SUFFIX}|{PATTERN_PREFIX}'
8
- DISTINCT_SF_PR = f'(DISTINCT|distinct)|{SUFFIX_AND_PRE}'
8
+ DISTINCT_PREFX = f'(DISTINCT|distinct)|{PATTERN_PREFIX}'
9
9
 
10
10
  KEYWORD = {
11
- 'SELECT': (',{}', 'SELECT *', DISTINCT_SF_PR),
11
+ 'SELECT': (',{}', 'SELECT *', DISTINCT_PREFX),
12
12
  'FROM': ('{}', '', PATTERN_SUFFIX),
13
13
  'WHERE': ('{}AND ', '', ''),
14
14
  'GROUP BY': (',{}', '', SUFFIX_AND_PRE),
@@ -74,6 +74,7 @@ class SQLObject:
74
74
  if symmetrical:
75
75
  fld = fld.lower()
76
76
  return fld.strip()
77
+ # if key == SELECT and re.search(' as | AS ', fld)
77
78
  pattern = KEYWORD[key][2]
78
79
  if key == WHERE and symmetrical:
79
80
  pattern = f'{PATTERN_PREFIX}| '
@@ -405,8 +406,6 @@ class Select(SQLObject):
405
406
  self.break_lines = True
406
407
 
407
408
  def update_values(self, key: str, new_values: list):
408
- if key == SELECT:
409
- new_values = [re.split(' as | AS ', val)[-1] for val in new_values]
410
409
  for value in self.diff(key, new_values):
411
410
  self.values.setdefault(key, []).append(value)
412
411
 
@@ -639,15 +638,3 @@ class RuleDateFuncReplace(Rule):
639
638
  temp = Select(f'{target.table_name} {target.alias}')
640
639
  Between(f'{year}-01-01', f'{year}-12-31').add(field, temp)
641
640
  target.values[WHERE][i] = ' AND '.join(temp.values[WHERE])
642
-
643
-
644
- if __name__ == "__main__":
645
- query = Select(
646
- 'Cast c',
647
- actor_id=Select(
648
- 'Actor a',
649
- name=NamedField('actors_name'),
650
- id=PrimaryKey
651
- )
652
- )
653
- print(query)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 0.1.2
3
+ Version: 0.1.3
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
File without changes
File without changes