sql-blocks 0.0.7__py3-none-any.whl → 0.0.8__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 +20 -13
- {sql_blocks-0.0.7.dist-info → sql_blocks-0.0.8.dist-info}/METADATA +1 -1
- sql_blocks-0.0.8.dist-info/RECORD +7 -0
- sql_blocks-0.0.7.dist-info/RECORD +0 -7
- {sql_blocks-0.0.7.dist-info → sql_blocks-0.0.8.dist-info}/LICENSE +0 -0
- {sql_blocks-0.0.7.dist-info → sql_blocks-0.0.8.dist-info}/WHEEL +0 -0
- {sql_blocks-0.0.7.dist-info → sql_blocks-0.0.8.dist-info}/top_level.txt +0 -0
sql_blocks/sql_blocks.py
CHANGED
@@ -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 ', '',
|
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
|
-
|
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
|
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
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
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.
|
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
|
@@ -0,0 +1,7 @@
|
|
1
|
+
sql_blocks/__init__.py,sha256=TodC5q-UEdYEz9v1RRoogVqqRcsKnZRY1WDGinrI2zo,26
|
2
|
+
sql_blocks/sql_blocks.py,sha256=mC8TTgAXrGL0X_Zn5GPv2HytlaRKm9jpcUyaSnepFOs,19963
|
3
|
+
sql_blocks-0.0.8.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
+
sql_blocks-0.0.8.dist-info/METADATA,sha256=B7L8E2UI-0GWHsDVPWibQsMrp69wzP4XRfXOOfg5GV4,8190
|
5
|
+
sql_blocks-0.0.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
sql_blocks-0.0.8.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
+
sql_blocks-0.0.8.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
sql_blocks/__init__.py,sha256=TodC5q-UEdYEz9v1RRoogVqqRcsKnZRY1WDGinrI2zo,26
|
2
|
-
sql_blocks/sql_blocks.py,sha256=w8vI-UxyBXj_YD09zKF3AKzJlmGN1wIRJgzbcCh6rmU,19684
|
3
|
-
sql_blocks-0.0.7.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
-
sql_blocks-0.0.7.dist-info/METADATA,sha256=2WFDh50ro70p_8f850VxyXQx82MY7BIq1nZEE-EY8Jk,8190
|
5
|
-
sql_blocks-0.0.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
sql_blocks-0.0.7.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
-
sql_blocks-0.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|