sql-blocks 0.0.7__tar.gz → 0.0.8__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.0.7
3
+ Version: 0.0.8
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.0.7"
3
+ version = "0.0.8"
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.0.7',
6
+ version = '0.0.8',
7
7
  author = 'Júlio Cascalles',
8
8
  author_email = 'julio.cascalles@outlook.com',
9
9
  packages = ['sql_blocks'],
@@ -10,7 +10,7 @@ DISTINCT_SF_PR = f'(DISTINCT|distinct)|{SUFFIX_AND_PRE}'
10
10
  KEYWORD = {
11
11
  'SELECT': (',{}', 'SELECT *', DISTINCT_SF_PR),
12
12
  'FROM': ('{}', '', PATTERN_SUFFIX),
13
- 'WHERE': ('{}AND ', '', f'{PATTERN_PREFIX}| '),
13
+ 'WHERE': ('{}AND ', '', ''),
14
14
  'GROUP BY': (',{}', '', SUFFIX_AND_PRE),
15
15
  'ORDER BY': (',{}', '', SUFFIX_AND_PRE),
16
16
  'LIMIT': (' ', '', ''),
@@ -70,11 +70,17 @@ class SQLObject:
70
70
  return KEYWORD[key][0].format(appendix.get(key, ''))
71
71
 
72
72
  def diff(self, key: str, search_list: list, symmetrical: bool=False) -> set:
73
- pattern = KEYWORD[key][2]
73
+ def cleanup(fld: str) -> str:
74
+ if symmetrical:
75
+ fld = fld.lower()
76
+ return fld.strip()
77
+ pattern = KEYWORD[key][2]
78
+ if key == WHERE and symmetrical:
79
+ pattern = f'{PATTERN_PREFIX}| '
74
80
  separator = self.get_separator(key)
75
81
  def field_set(source: list) -> set:
76
82
  return set(
77
- re.sub(pattern, '', fld.strip()).lower()
83
+ re.sub(pattern, '', cleanup(fld))
78
84
  for string in source
79
85
  for fld in re.split(separator, string)
80
86
  )
@@ -385,16 +391,17 @@ class Select(SQLObject):
385
391
  self.values.setdefault(key, []).append(value)
386
392
 
387
393
  def add(self, name: str, main: SQLObject):
388
- main.update_values(
389
- FROM, [
390
- '{jt}JOIN {tb} {a2} ON ({a1}.{f1} = {a2}.{f2})'.format(
391
- jt=self.join_type.value,
392
- tb=self.table_name,
393
- a1=main.alias, f1=name,
394
- a2=self.alias, f2=self.key_field
395
- )
396
- ] + self.values[FROM][1:]
397
- )
394
+ new_tables = [
395
+ '{jt}JOIN {tb} {a2} ON ({a1}.{f1} = {a2}.{f2})'.format(
396
+ jt=self.join_type.value,
397
+ tb=self.table_name,
398
+ a1=main.alias, f1=name,
399
+ a2=self.alias, f2=self.key_field
400
+ )
401
+ ]
402
+ if new_tables not in main.values.get(FROM, []):
403
+ new_tables += self.values[FROM][1:]
404
+ main.values.setdefault(FROM, []).extend(new_tables)
398
405
  for key in USUAL_KEYS:
399
406
  main.update_values(key, self.values.get(key, []))
400
407
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sql_blocks
3
- Version: 0.0.7
3
+ Version: 0.0.8
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