sql-blocks 1.25.1__py3-none-any.whl → 1.25.13__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 -23
- {sql_blocks-1.25.1.dist-info → sql_blocks-1.25.13.dist-info}/METADATA +1 -1
- sql_blocks-1.25.13.dist-info/RECORD +7 -0
- sql_blocks-1.25.1.dist-info/RECORD +0 -7
- {sql_blocks-1.25.1.dist-info → sql_blocks-1.25.13.dist-info}/LICENSE +0 -0
- {sql_blocks-1.25.1.dist-info → sql_blocks-1.25.13.dist-info}/WHEEL +0 -0
- {sql_blocks-1.25.1.dist-info → sql_blocks-1.25.13.dist-info}/top_level.txt +0 -0
sql_blocks/sql_blocks.py
CHANGED
@@ -151,49 +151,47 @@ class NamedField:
|
|
151
151
|
|
152
152
|
|
153
153
|
class Function:
|
154
|
-
instance: dict = {}
|
155
|
-
|
156
154
|
def __init__(self, *params: list):
|
157
|
-
|
158
|
-
|
155
|
+
# --- Replace class methods by instance methods: ------
|
156
|
+
self.add = self.__add
|
157
|
+
self.format = self.__format
|
158
|
+
# -----------------------------------------------------
|
159
159
|
self.params = [str(p) for p in params]
|
160
|
-
self.
|
160
|
+
self.field_class = Field
|
161
161
|
self.pattern = '{}({})'
|
162
162
|
self.extra = {}
|
163
163
|
|
164
164
|
def As(self, field_alias: str, modifiers=None):
|
165
165
|
if modifiers:
|
166
166
|
self.extra[field_alias] = TO_LIST(modifiers)
|
167
|
-
self.
|
167
|
+
self.field_class = NamedField(field_alias)
|
168
168
|
return self
|
169
169
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
170
|
+
def __format(self, name: str, main: SQLObject) -> str:
|
171
|
+
if name in '*_' and self.params:
|
172
|
+
params = self.params
|
173
|
+
else:
|
174
|
+
params = [
|
175
|
+
Field.format(name, main)
|
176
|
+
] + self.params
|
177
|
+
return self.pattern.format(
|
178
|
+
self.__class__.__name__,
|
178
179
|
', '.join(params)
|
179
180
|
)
|
180
181
|
|
182
|
+
@classmethod
|
183
|
+
def format(cls, name: str, main: SQLObject):
|
184
|
+
return cls().__format(name, main)
|
185
|
+
|
181
186
|
def __add(self, name: str, main: SQLObject):
|
182
187
|
name = self.format(name, main)
|
183
|
-
self.
|
188
|
+
self.field_class.add(name, main)
|
184
189
|
if self.extra:
|
185
190
|
main.__call__(**self.extra)
|
186
191
|
|
187
|
-
@classmethod
|
188
|
-
def get_instance(cls):
|
189
|
-
obj = Function.instance.get(cls.__name__)
|
190
|
-
if not obj:
|
191
|
-
obj = cls()
|
192
|
-
return obj
|
193
|
-
|
194
192
|
@classmethod
|
195
193
|
def add(cls, name: str, main: SQLObject):
|
196
|
-
cls
|
194
|
+
cls().__add(name, main)
|
197
195
|
|
198
196
|
|
199
197
|
# ---- String Functions: ---------------------------------
|
@@ -1356,3 +1354,12 @@ def detect(text: str) -> Select:
|
|
1356
1354
|
for query in query_list[1:]:
|
1357
1355
|
result += query
|
1358
1356
|
return result
|
1357
|
+
|
1358
|
+
if __name__ == "__main__":
|
1359
|
+
OrderBy.sort = SortType.DESC
|
1360
|
+
query = Select(
|
1361
|
+
'order_Detail d',
|
1362
|
+
customer_id=GroupBy,
|
1363
|
+
_=Sum('d.unitPrice * d.quantity').As('total', OrderBy)
|
1364
|
+
)
|
1365
|
+
print(query)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sql_blocks
|
3
|
-
Version: 1.25.
|
3
|
+
Version: 1.25.13
|
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=P5yp0Ug4PD56xklmQOtpNLKm9hfhHBNb8TDkOneNAHw,45783
|
3
|
+
sql_blocks-1.25.13.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
+
sql_blocks-1.25.13.dist-info/METADATA,sha256=tahTyaVcsa4ROoxQSMK41W6m20bVlDs6_kh9b9mkgoc,13424
|
5
|
+
sql_blocks-1.25.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
sql_blocks-1.25.13.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
+
sql_blocks-1.25.13.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
sql_blocks/__init__.py,sha256=5ItzGCyqqa6kwY8wvF9kapyHsAiWJ7KEXCcC-OtdXKg,37
|
2
|
-
sql_blocks/sql_blocks.py,sha256=JYATgw-J3SzAVCYZpdNGyc7rK700jHJtOWbK9gxywu4,45466
|
3
|
-
sql_blocks-1.25.1.dist-info/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
4
|
-
sql_blocks-1.25.1.dist-info/METADATA,sha256=k6Xd3FtNhl3KHAOzVA0zkx5TvQdcb2P5st6-fEm7r4M,13423
|
5
|
-
sql_blocks-1.25.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
sql_blocks-1.25.1.dist-info/top_level.txt,sha256=57AbUvUjYNy4m1EqDaU3WHeP-uyIAfV0n8GAUp1a1YQ,11
|
7
|
-
sql_blocks-1.25.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|