sql-blocks 1.25.414021502__py3-none-any.whl → 1.25.420021312__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 +30 -1
- {sql_blocks-1.25.414021502.dist-info → sql_blocks-1.25.420021312.dist-info}/METADATA +8 -2
- sql_blocks-1.25.420021312.dist-info/RECORD +7 -0
- sql_blocks-1.25.414021502.dist-info/RECORD +0 -7
- {sql_blocks-1.25.414021502.dist-info → sql_blocks-1.25.420021312.dist-info}/LICENSE +0 -0
- {sql_blocks-1.25.414021502.dist-info → sql_blocks-1.25.420021312.dist-info}/WHEEL +0 -0
- {sql_blocks-1.25.414021502.dist-info → sql_blocks-1.25.420021312.dist-info}/top_level.txt +0 -0
sql_blocks/sql_blocks.py
CHANGED
@@ -829,7 +829,7 @@ class QueryLanguage:
|
|
829
829
|
return self.join_with_tabs(values, ' AND ')
|
830
830
|
|
831
831
|
def sort_by(self, values: list) -> str:
|
832
|
-
return self.join_with_tabs(values)
|
832
|
+
return self.join_with_tabs(values, ',')
|
833
833
|
|
834
834
|
def set_group(self, values: list) -> str:
|
835
835
|
return self.join_with_tabs(values, ',')
|
@@ -1720,6 +1720,8 @@ class RuleDateFuncReplace(Rule):
|
|
1720
1720
|
@classmethod
|
1721
1721
|
def apply(cls, target: Select):
|
1722
1722
|
for i, condition in enumerate(target.values.get(WHERE, [])):
|
1723
|
+
if not '(' in condition:
|
1724
|
+
continue
|
1723
1725
|
tokens = [
|
1724
1726
|
t.strip() for t in cls.REGEX.split(condition) if t.strip()
|
1725
1727
|
]
|
@@ -1797,3 +1799,30 @@ def detect(text: str, join_queries: bool = True, format: str='') -> Select | lis
|
|
1797
1799
|
result += query
|
1798
1800
|
return result
|
1799
1801
|
# ===========================================================================================//
|
1802
|
+
|
1803
|
+
|
1804
|
+
if __name__ == "__main__":
|
1805
|
+
query = Select(
|
1806
|
+
'Matricula M',
|
1807
|
+
aluno_id=Select(
|
1808
|
+
'Aluno A',
|
1809
|
+
nome=NamedField('nome_aluno'),
|
1810
|
+
id=PrimaryKey
|
1811
|
+
),
|
1812
|
+
curso=Select(
|
1813
|
+
'Curso C',
|
1814
|
+
nome=NamedField('nome_curso'),
|
1815
|
+
id=PrimaryKey
|
1816
|
+
)
|
1817
|
+
)
|
1818
|
+
print('='*50)
|
1819
|
+
print(query)
|
1820
|
+
print('-'*50)
|
1821
|
+
m, c, a = Select.parse( str(query) )
|
1822
|
+
m(inicio=[Not.gt('2024-11-15'), Field])
|
1823
|
+
query = m + a
|
1824
|
+
print(query)
|
1825
|
+
print('-'*50)
|
1826
|
+
query.optimize()
|
1827
|
+
print(query)
|
1828
|
+
print('='*50)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sql_blocks
|
3
|
-
Version: 1.25.
|
3
|
+
Version: 1.25.420021312
|
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
|
@@ -52,6 +52,12 @@ You can specify your own alias: `a = Select('Actor a')`
|
|
52
52
|
...should return:
|
53
53
|
**SELECT extract(year from due_date) as YEAR_ref...**
|
54
54
|
|
55
|
+
Possible tags in ExpressionField:
|
56
|
+
* {f} - The field name;
|
57
|
+
* {af} - The field name preceded by the table alias;
|
58
|
+
> Can be written as {a.f} or %
|
59
|
+
* {t} - The table name;
|
60
|
+
* {a} - Only the table alias.
|
55
61
|
---
|
56
62
|
|
57
63
|
### 3 - To set conditions, use **Where**:
|
@@ -450,7 +456,7 @@ WHERE
|
|
450
456
|
query = Select('post p')
|
451
457
|
query.add_fields(
|
452
458
|
'user_id, created_at',
|
453
|
-
|
459
|
+
[OrderBy, GroupBy]
|
454
460
|
)
|
455
461
|
```
|
456
462
|
...is the same as...
|
@@ -0,0 +1,7 @@
|
|
1
|
+
sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
|
2
|
+
sql_blocks/sql_blocks.py,sha256=WkFmxphTnqT74MgGX6JCKLMRmxwDPGXdDmZ8DU-qObs,60834
|
3
|
+
sql_blocks-1.25.420021312.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
+
sql_blocks-1.25.420021312.dist-info/METADATA,sha256=qCiTXUBNpwkwBGWXLROxIVo2tz5XgLr5yLJeoYQKAmQ,20708
|
5
|
+
sql_blocks-1.25.420021312.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
sql_blocks-1.25.420021312.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
+
sql_blocks-1.25.420021312.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
|
2
|
-
sql_blocks/sql_blocks.py,sha256=HUDdXrSDuippY7buAAMuFyYS9mRetAu7woy_6yBUQ7c,60161
|
3
|
-
sql_blocks-1.25.414021502.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
-
sql_blocks-1.25.414021502.dist-info/METADATA,sha256=3GGtGw0pl-9zIqwCZM2AH0GHykI1Sawkb0fpfpsLMlc,20512
|
5
|
-
sql_blocks-1.25.414021502.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
sql_blocks-1.25.414021502.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
-
sql_blocks-1.25.414021502.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|