cloudoll 2.2.28__tar.gz → 2.2.30__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.
- {cloudoll-2.2.28 → cloudoll-2.2.30}/PKG-INFO +1 -1
- cloudoll-2.2.30/cloudoll/__init__.py +1 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/field.py +89 -8
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/utils/m2d.py +1 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/web/__init__.py +1 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll.egg-info/PKG-INFO +1 -1
- cloudoll-2.2.28/cloudoll/__init__.py +0 -1
- {cloudoll-2.2.28 → cloudoll-2.2.30}/LICENSE +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/README.md +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/__main__.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/cli.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/error/__init__.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/error/errors.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/__init__.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/base.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/err.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/model.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/mysql.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/parse.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/orm/postgres.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/robot/__init__.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/robot/dingtalk.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/robot/feishu.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/robot/slack.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/utils/common.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/utils/patch_loop.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/utils/snowflake.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/utils/watch.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/web/exception.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/web/html.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/web/http.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/web/jwt.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll/web/settings.py +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll.egg-info/requires.txt +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/setup.cfg +0 -0
- {cloudoll-2.2.28 → cloudoll-2.2.30}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.30"
|
|
@@ -31,6 +31,8 @@ OP = objdict(
|
|
|
31
31
|
AVG="AVG",
|
|
32
32
|
AS="AS",
|
|
33
33
|
SUM="SUM",
|
|
34
|
+
MAX="MAX",
|
|
35
|
+
MIN="MIN",
|
|
34
36
|
IS_TODAY="IS_TODAY",
|
|
35
37
|
IS_THIS_WEEK="THIS_WEEK",
|
|
36
38
|
IS_THIS_MONTH="THIS_MONTH",
|
|
@@ -50,8 +52,13 @@ OP = objdict(
|
|
|
50
52
|
DATE_FORMAT="DATE_FORMAT",
|
|
51
53
|
JSON_CONTAINS_OBJECT="JSON_CONTAINS_OBJECT",
|
|
52
54
|
JSON_CONTAINS_ARRAY="JSON_CONTAINS_ARRAY",
|
|
55
|
+
GROUP_CONCAT='GROUP_CONCAT',
|
|
53
56
|
COUNT="COUNT",
|
|
54
57
|
COUNT_WHEN="COUNT_WHEN",
|
|
58
|
+
SUM_WHEN="SUM_WHEN",
|
|
59
|
+
MAX_WHEN="MAX_WHEN",
|
|
60
|
+
MIN_WHEN="MIN_WHEN",
|
|
61
|
+
AVG_WHEN="AVG_WHEN",
|
|
55
62
|
IS_NOT="IS NOT",
|
|
56
63
|
IS_NOT_NULL="IS NOT NULL",
|
|
57
64
|
IS_NULL="IS NULL",
|
|
@@ -119,15 +126,53 @@ class FieldBase(object):
|
|
|
119
126
|
def count(self):
|
|
120
127
|
return Function(self, OP.COUNT)
|
|
121
128
|
|
|
122
|
-
def count_when(self,
|
|
123
|
-
|
|
129
|
+
def count_when(self, *arg):
|
|
130
|
+
"""
|
|
131
|
+
input: count_when(A.field > 10 ,1 , 0) \n
|
|
132
|
+
output: count(case when A.field > 10 then 1 else 0 end)
|
|
133
|
+
"""
|
|
134
|
+
return Function(self, OP.COUNT_WHEN, arg)
|
|
135
|
+
|
|
136
|
+
def max(self):
|
|
137
|
+
return Function(self, OP.MAX)
|
|
138
|
+
|
|
139
|
+
def max_when(self, *arg):
|
|
140
|
+
"""
|
|
141
|
+
input: max_when(A.field > 10 ,A.field) \n
|
|
142
|
+
output: max(case when A.field > 10 then A.field end)
|
|
143
|
+
"""
|
|
144
|
+
return Function(self, OP.MAX_WHEN, arg)
|
|
145
|
+
|
|
146
|
+
def min(self):
|
|
147
|
+
return Function(self, OP.MIN)
|
|
148
|
+
|
|
149
|
+
def min_when(self, *arg):
|
|
150
|
+
"""
|
|
151
|
+
input: min_when(A.field > 10 ,A.field) \n
|
|
152
|
+
output: min(case when A.field > 10 then A.field end)
|
|
153
|
+
"""
|
|
154
|
+
return Function(self, OP.MIN_WHEN, arg)
|
|
124
155
|
|
|
125
156
|
def sum(self):
|
|
126
157
|
return Function(self, OP.SUM)
|
|
127
158
|
|
|
159
|
+
def sum_when(self, *arg):
|
|
160
|
+
"""
|
|
161
|
+
input: sum_when(A.field > 10 ,1 , 0)\n
|
|
162
|
+
output: sum(case when A.field > 10 then 1 else 0 end)
|
|
163
|
+
"""
|
|
164
|
+
return Function(self, OP.SUM_WHEN, arg)
|
|
165
|
+
|
|
128
166
|
def avg(self):
|
|
129
167
|
return Function(self, OP.AVG)
|
|
130
168
|
|
|
169
|
+
def avg_when(self, *arg):
|
|
170
|
+
"""
|
|
171
|
+
input: avg_when(A.field > 10 , A.field)\n
|
|
172
|
+
output: avg(case when A.field > 10 then A.field end)
|
|
173
|
+
"""
|
|
174
|
+
return Function(self, OP.AVG_WHEN, arg)
|
|
175
|
+
|
|
131
176
|
def date_format(self, args):
|
|
132
177
|
return Function(self, OP.DATE_FORMAT, args)
|
|
133
178
|
|
|
@@ -237,6 +282,20 @@ class ExpList(FieldBase):
|
|
|
237
282
|
# return f"{lpt.sql() if isinstance(lpt,Expression) else lpt} {self.op} {rpt.sql() if isinstance(rpt,Expression) else rpt}"
|
|
238
283
|
|
|
239
284
|
|
|
285
|
+
def deconstruct(args):
|
|
286
|
+
f = args[0] if len(args) > 0 else None
|
|
287
|
+
v1 = args[1] if len(args) > 1 else 1
|
|
288
|
+
v2 = args[2] if len(args) > 2 and args[2] is not None else 'NULL'
|
|
289
|
+
c = None
|
|
290
|
+
v = None
|
|
291
|
+
if isinstance(f, FieldBase):
|
|
292
|
+
c = f"{f.lhs.full_name} {f.op} ?"
|
|
293
|
+
v = f.rhs
|
|
294
|
+
if isinstance(v1, FieldBase):
|
|
295
|
+
v1 = v1.name
|
|
296
|
+
return c, v, v1, v2
|
|
297
|
+
|
|
298
|
+
|
|
240
299
|
class Function(FieldBase):
|
|
241
300
|
def __init__(self, col, op, rpt=None):
|
|
242
301
|
self.col = col
|
|
@@ -284,22 +343,44 @@ class Function(FieldBase):
|
|
|
284
343
|
return f"{col_name} < NOW() - INTERVAL {self.rpt} MINUTE", None
|
|
285
344
|
elif op == OP.BEFORE_SECONDS:
|
|
286
345
|
return f"{col_name} < NOW() - INTERVAL {self.rpt} SECOND", None
|
|
287
|
-
|
|
346
|
+
elif op == OP.CONTAINS:
|
|
347
|
+
return f"{col_name} LIKE CONCAT('%%',?,'%%')", [self.rpt]
|
|
348
|
+
# return f"CONTAINS({col_name},?)", [self.rpt]
|
|
288
349
|
elif op == OP.JSON_CONTAINS_OBJECT:
|
|
289
350
|
_k, _v = self.rpt
|
|
290
351
|
key = _k.full_name if isinstance(_k, Field) else f"'{_k}'"
|
|
291
352
|
return f"json_contains({col_name},json_object({key},?))", [_v]
|
|
292
353
|
elif op == OP.JSON_CONTAINS_ARRAY:
|
|
293
354
|
if is_field:
|
|
294
|
-
return (
|
|
295
|
-
f"json_contains({col_name},json_array({self.rpt.full_name}))",
|
|
296
|
-
None,
|
|
297
|
-
)
|
|
355
|
+
return f"json_contains({col_name},json_array({self.rpt.full_name}))", None
|
|
298
356
|
return f"json_contains({col_name},json_array(?))", [self.rpt]
|
|
299
357
|
elif op == OP.COUNT:
|
|
300
358
|
return f"COUNT({col_name})", None
|
|
301
359
|
elif op == OP.COUNT_WHEN:
|
|
302
|
-
|
|
360
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
361
|
+
return f"COUNT(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
362
|
+
elif op == OP.SUM:
|
|
363
|
+
return f"SUM({col_name})", None
|
|
364
|
+
elif op == OP.SUM_WHEN:
|
|
365
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
366
|
+
return f"SUM(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
367
|
+
elif op == OP.AVG:
|
|
368
|
+
return f"AVG({col_name})", None
|
|
369
|
+
elif op == OP.AVG_WHEN:
|
|
370
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
371
|
+
return f"AVG(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
372
|
+
elif op == OP.MAX:
|
|
373
|
+
return f"MAX({col_name})", None
|
|
374
|
+
elif op == OP.MAX_WHEN:
|
|
375
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
376
|
+
return f"MAX(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
377
|
+
elif op == OP.MIN:
|
|
378
|
+
return f"MIN({col_name})", None
|
|
379
|
+
elif op == OP.MIN_WHEN:
|
|
380
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
381
|
+
return f"MIN(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
382
|
+
elif op == OP.GROUP_CONCAT:
|
|
383
|
+
return f"GROUP_CONCAT({col_name})", None
|
|
303
384
|
|
|
304
385
|
|
|
305
386
|
class Expression(FieldBase):
|
|
@@ -201,6 +201,7 @@ def get_col(field, driver="mysql"):
|
|
|
201
201
|
"default": field["Default"],
|
|
202
202
|
"charset": field["Collation"],
|
|
203
203
|
"max_length": None,
|
|
204
|
+
"scale_length":None,
|
|
204
205
|
"auto_increment": field["Extra"] == "auto_increment",
|
|
205
206
|
"NOT_NULL": field["Null"] == "NO",
|
|
206
207
|
"created_generated": "DEFAULT_GENERATED" == field["Extra"],
|
|
@@ -234,6 +234,7 @@ class Application(object):
|
|
|
234
234
|
self.app.on_startup.append(self._init_database)
|
|
235
235
|
self.app.on_cleanup.append(self._close_database)
|
|
236
236
|
self.app.config = config
|
|
237
|
+
self.app.env = env
|
|
237
238
|
self.app.jwt_encode = self.jwt_encode
|
|
238
239
|
self.app.jwt_decode = self.jwt_decode
|
|
239
240
|
# session
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.28"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|