sql-blocks 0.31.13__py3-none-any.whl → 0.31.21__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 +17 -6
- {sql_blocks-0.31.13.dist-info → sql_blocks-0.31.21.dist-info}/METADATA +1 -1
- sql_blocks-0.31.21.dist-info/RECORD +7 -0
- sql_blocks-0.31.13.dist-info/RECORD +0 -7
- {sql_blocks-0.31.13.dist-info → sql_blocks-0.31.21.dist-info}/LICENSE +0 -0
- {sql_blocks-0.31.13.dist-info → sql_blocks-0.31.21.dist-info}/WHEEL +0 -0
- {sql_blocks-0.31.13.dist-info → sql_blocks-0.31.21.dist-info}/top_level.txt +0 -0
sql_blocks/sql_blocks.py
CHANGED
@@ -63,7 +63,7 @@ class SQLObject:
|
|
63
63
|
|
64
64
|
@staticmethod
|
65
65
|
def get_separator(key: str) -> str:
|
66
|
-
appendix = {WHERE: 'and
|
66
|
+
appendix = {WHERE: r'\s+and\s+|', FROM: r'\s+join\s+|\s+JOIN\s+'}
|
67
67
|
return KEYWORD[key][0].format(appendix.get(key, ''))
|
68
68
|
|
69
69
|
def diff(self, key: str, search_list: list, exact: bool=False) -> set:
|
@@ -79,7 +79,7 @@ class SQLObject:
|
|
79
79
|
fld = fld.lower()
|
80
80
|
return fld.strip()
|
81
81
|
def is_named_field(fld: str) -> bool:
|
82
|
-
return key == SELECT and re.search('
|
82
|
+
return key == SELECT and re.search(r'\s+as\s+|\s+AS\s+', fld)
|
83
83
|
def field_set(source: list) -> set:
|
84
84
|
return set(
|
85
85
|
(
|
@@ -476,6 +476,10 @@ class QueryLanguage:
|
|
476
476
|
if not method or (not values and not self.has_default[key]):
|
477
477
|
self.result[ref] = ''
|
478
478
|
continue
|
479
|
+
if key == FROM:
|
480
|
+
values[0] = '{} {}'.format(
|
481
|
+
self.target.aka(), self.target.alias
|
482
|
+
).strip()
|
479
483
|
text = method(values)
|
480
484
|
self.result[ref] = self.prefix(key) + text
|
481
485
|
return self.pattern.format(**self.result).strip()
|
@@ -767,7 +771,7 @@ class CypherParser(Parser):
|
|
767
771
|
REGEX = {}
|
768
772
|
CHAR_SET = r'[(,?)^{}[\]]'
|
769
773
|
KEYWORDS = '|'.join(
|
770
|
-
fr'\
|
774
|
+
fr'\b{word}\b'
|
771
775
|
for word in "where return WHERE RETURN and AND".split()
|
772
776
|
)
|
773
777
|
|
@@ -1040,12 +1044,16 @@ class Select(SQLObject):
|
|
1040
1044
|
for value in self.diff(key, new_values):
|
1041
1045
|
self.values.setdefault(key, []).append(value)
|
1042
1046
|
|
1047
|
+
def aka(self) -> str:
|
1048
|
+
result = self.table_name
|
1049
|
+
return self.EQUIVALENT_NAMES.get(result, result)
|
1050
|
+
|
1043
1051
|
def add(self, name: str, main: SQLObject):
|
1044
1052
|
old_tables = main.values.get(FROM, [])
|
1045
1053
|
new_tables = set([
|
1046
1054
|
'{jt}JOIN {tb} {a2} ON ({a1}.{f1} = {a2}.{f2})'.format(
|
1047
1055
|
jt=self.join_type.value,
|
1048
|
-
tb=self.
|
1056
|
+
tb=self.aka(),
|
1049
1057
|
a1=main.alias, f1=name,
|
1050
1058
|
a2=self.alias, f2=self.key_field
|
1051
1059
|
)
|
@@ -1249,7 +1257,10 @@ def detect(text: str) -> Select:
|
|
1249
1257
|
if __name__ == "__main__":
|
1250
1258
|
print('@'*100)
|
1251
1259
|
print( detect(
|
1252
|
-
|
1253
|
-
|
1260
|
+
'''
|
1261
|
+
Company(?jobs > 10, id)
|
1262
|
+
<- Person(work_at ^name, friend_of) ->
|
1263
|
+
Person(id ?skill="pANDas")
|
1264
|
+
''' # ^^^---- Test for confusion with the AND operator
|
1254
1265
|
) )
|
1255
1266
|
print('@'*100)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sql_blocks
|
3
|
-
Version: 0.31.
|
3
|
+
Version: 0.31.21
|
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=jtK4yfyLCQZYrom2Aj_En6Hvlc3mbvAI1TOnC4AK72U,42823
|
3
|
+
sql_blocks-0.31.21.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
+
sql_blocks-0.31.21.dist-info/METADATA,sha256=lDrOFqAT1hC8lEp9plVXngNJ7m_2ZnJ8qRywx_PVUCo,12195
|
5
|
+
sql_blocks-0.31.21.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
sql_blocks-0.31.21.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
+
sql_blocks-0.31.21.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
|
2
|
-
sql_blocks/sql_blocks.py,sha256=AcA-AOZ4XSXD5srMNsnv43ljPF06_DInTu9ljrzQQMQ,42496
|
3
|
-
sql_blocks-0.31.13.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
-
sql_blocks-0.31.13.dist-info/METADATA,sha256=6Ckz7aC4I8tQ1JU-hX_AIMsyw1rw2MzwXRQvOAZ7KII,12195
|
5
|
-
sql_blocks-0.31.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
sql_blocks-0.31.13.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
-
sql_blocks-0.31.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|