cloudoll 2.2.29__tar.gz → 2.2.31__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.29 → cloudoll-2.2.31}/PKG-INFO +1 -1
- cloudoll-2.2.31/cloudoll/__init__.py +1 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/field.py +88 -10
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll.egg-info/PKG-INFO +1 -1
- cloudoll-2.2.29/cloudoll/__init__.py +0 -1
- {cloudoll-2.2.29 → cloudoll-2.2.31}/LICENSE +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/README.md +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/__main__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/cli.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/error/__init__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/error/errors.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/logging/__init__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/mail/__init__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/mail/smtp.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/__init__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/base.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/err.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/model.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/mysql.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/parse.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/orm/postgres.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/robot/__init__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/robot/dingtalk.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/robot/feishu.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/robot/slack.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/utils/__init__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/utils/common.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/utils/m2d.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/utils/patch_loop.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/utils/snowflake.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/utils/watch.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/web/__init__.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/web/exception.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/web/html.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/web/http.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/web/jwt.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll/web/settings.py +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll.egg-info/SOURCES.txt +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll.egg-info/dependency_links.txt +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll.egg-info/entry_points.txt +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll.egg-info/requires.txt +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/cloudoll.egg-info/top_level.txt +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/setup.cfg +0 -0
- {cloudoll-2.2.29 → cloudoll-2.2.31}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.31"
|
|
@@ -52,9 +52,12 @@ OP = objdict(
|
|
|
52
52
|
DATE_FORMAT="DATE_FORMAT",
|
|
53
53
|
JSON_CONTAINS_OBJECT="JSON_CONTAINS_OBJECT",
|
|
54
54
|
JSON_CONTAINS_ARRAY="JSON_CONTAINS_ARRAY",
|
|
55
|
-
GROUP_CONCAT='GROUP_CONCAT',
|
|
56
55
|
COUNT="COUNT",
|
|
57
56
|
COUNT_WHEN="COUNT_WHEN",
|
|
57
|
+
SUM_WHEN="SUM_WHEN",
|
|
58
|
+
MAX_WHEN="MAX_WHEN",
|
|
59
|
+
MIN_WHEN="MIN_WHEN",
|
|
60
|
+
AVG_WHEN="AVG_WHEN",
|
|
58
61
|
IS_NOT="IS NOT",
|
|
59
62
|
IS_NOT_NULL="IS NOT NULL",
|
|
60
63
|
IS_NULL="IS NULL",
|
|
@@ -66,6 +69,7 @@ OP = objdict(
|
|
|
66
69
|
NOT_BETWEEN="NOT BETWEEN",
|
|
67
70
|
REGEXP="REGEXP",
|
|
68
71
|
IREGEXP="IREGEXP",
|
|
72
|
+
GROUP_CONCAT="GROUP_CONCAT",
|
|
69
73
|
DISTINCT="DISTINCT",
|
|
70
74
|
CONCAT="||",
|
|
71
75
|
BITWISE_NEGATION="~",
|
|
@@ -110,8 +114,11 @@ class FieldBase(object):
|
|
|
110
114
|
ilike = _op(OP.ILIKE) # ilike for pg
|
|
111
115
|
not_like = _op(OP.NOT_LIKE) # not like
|
|
112
116
|
|
|
117
|
+
def group_concat(self, *arg):
|
|
118
|
+
return Function(self, OP.GROUP_CONCAT, arg)
|
|
119
|
+
|
|
113
120
|
def distinct(self, *arg):
|
|
114
|
-
return
|
|
121
|
+
return Function(self, OP.DISTINCT, arg)
|
|
115
122
|
|
|
116
123
|
def desc(self):
|
|
117
124
|
return Expression(self, OP.DESC, None)
|
|
@@ -122,18 +129,53 @@ class FieldBase(object):
|
|
|
122
129
|
def count(self):
|
|
123
130
|
return Function(self, OP.COUNT)
|
|
124
131
|
|
|
132
|
+
def count_when(self, *arg):
|
|
133
|
+
"""
|
|
134
|
+
input: count_when(A.field > 10 ,1 , 0) \n
|
|
135
|
+
output: count(case when A.field > 10 then 1 else 0 end)
|
|
136
|
+
"""
|
|
137
|
+
return Function(self, OP.COUNT_WHEN, arg)
|
|
138
|
+
|
|
125
139
|
def max(self):
|
|
126
140
|
return Function(self, OP.MAX)
|
|
127
141
|
|
|
128
|
-
def
|
|
129
|
-
|
|
142
|
+
def max_when(self, *arg):
|
|
143
|
+
"""
|
|
144
|
+
input: max_when(A.field > 10 ,A.field) \n
|
|
145
|
+
output: max(case when A.field > 10 then A.field end)
|
|
146
|
+
"""
|
|
147
|
+
return Function(self, OP.MAX_WHEN, arg)
|
|
148
|
+
|
|
149
|
+
def min(self):
|
|
150
|
+
return Function(self, OP.MIN)
|
|
151
|
+
|
|
152
|
+
def min_when(self, *arg):
|
|
153
|
+
"""
|
|
154
|
+
input: min_when(A.field > 10 ,A.field) \n
|
|
155
|
+
output: min(case when A.field > 10 then A.field end)
|
|
156
|
+
"""
|
|
157
|
+
return Function(self, OP.MIN_WHEN, arg)
|
|
130
158
|
|
|
131
159
|
def sum(self):
|
|
132
160
|
return Function(self, OP.SUM)
|
|
133
161
|
|
|
162
|
+
def sum_when(self, *arg):
|
|
163
|
+
"""
|
|
164
|
+
input: sum_when(A.field > 10 ,1 , 0)\n
|
|
165
|
+
output: sum(case when A.field > 10 then 1 else 0 end)
|
|
166
|
+
"""
|
|
167
|
+
return Function(self, OP.SUM_WHEN, arg)
|
|
168
|
+
|
|
134
169
|
def avg(self):
|
|
135
170
|
return Function(self, OP.AVG)
|
|
136
171
|
|
|
172
|
+
def avg_when(self, *arg):
|
|
173
|
+
"""
|
|
174
|
+
input: avg_when(A.field > 10 , A.field)\n
|
|
175
|
+
output: avg(case when A.field > 10 then A.field end)
|
|
176
|
+
"""
|
|
177
|
+
return Function(self, OP.AVG_WHEN, arg)
|
|
178
|
+
|
|
137
179
|
def date_format(self, args):
|
|
138
180
|
return Function(self, OP.DATE_FORMAT, args)
|
|
139
181
|
|
|
@@ -243,6 +285,20 @@ class ExpList(FieldBase):
|
|
|
243
285
|
# return f"{lpt.sql() if isinstance(lpt,Expression) else lpt} {self.op} {rpt.sql() if isinstance(rpt,Expression) else rpt}"
|
|
244
286
|
|
|
245
287
|
|
|
288
|
+
def deconstruct(args):
|
|
289
|
+
f = args[0] if len(args) > 0 else None
|
|
290
|
+
v1 = args[1] if len(args) > 1 else 1
|
|
291
|
+
v2 = args[2] if len(args) > 2 and args[2] is not None else 'NULL'
|
|
292
|
+
c = None
|
|
293
|
+
v = None
|
|
294
|
+
if isinstance(f, FieldBase):
|
|
295
|
+
c = f"{f.lhs.full_name} {f.op} ?"
|
|
296
|
+
v = f.rhs
|
|
297
|
+
if isinstance(v1, FieldBase):
|
|
298
|
+
v1 = v1.name
|
|
299
|
+
return c, v, v1, v2
|
|
300
|
+
|
|
301
|
+
|
|
246
302
|
class Function(FieldBase):
|
|
247
303
|
def __init__(self, col, op, rpt=None):
|
|
248
304
|
self.col = col
|
|
@@ -299,25 +355,47 @@ class Function(FieldBase):
|
|
|
299
355
|
return f"json_contains({col_name},json_object({key},?))", [_v]
|
|
300
356
|
elif op == OP.JSON_CONTAINS_ARRAY:
|
|
301
357
|
if is_field:
|
|
302
|
-
return (
|
|
303
|
-
f"json_contains({col_name},json_array({self.rpt.full_name}))",
|
|
304
|
-
None,
|
|
305
|
-
)
|
|
358
|
+
return f"json_contains({col_name},json_array({self.rpt.full_name}))", None
|
|
306
359
|
return f"json_contains({col_name},json_array(?))", [self.rpt]
|
|
307
360
|
elif op == OP.COUNT:
|
|
308
361
|
return f"COUNT({col_name})", None
|
|
309
362
|
elif op == OP.COUNT_WHEN:
|
|
310
|
-
|
|
363
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
364
|
+
return f"COUNT(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
311
365
|
elif op == OP.SUM:
|
|
312
366
|
return f"SUM({col_name})", None
|
|
367
|
+
elif op == OP.SUM_WHEN:
|
|
368
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
369
|
+
return f"SUM(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
313
370
|
elif op == OP.AVG:
|
|
314
371
|
return f"AVG({col_name})", None
|
|
372
|
+
elif op == OP.AVG_WHEN:
|
|
373
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
374
|
+
return f"AVG(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
315
375
|
elif op == OP.MAX:
|
|
316
376
|
return f"MAX({col_name})", None
|
|
377
|
+
elif op == OP.MAX_WHEN:
|
|
378
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
379
|
+
return f"MAX(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
317
380
|
elif op == OP.MIN:
|
|
318
381
|
return f"MIN({col_name})", None
|
|
382
|
+
elif op == OP.MIN_WHEN:
|
|
383
|
+
c, v, v1, v2 = deconstruct(self.rpt)
|
|
384
|
+
return f"MIN(CASE WHEN {c} THEN {v1} ELSE {v2} END)", [v]
|
|
319
385
|
elif op == OP.GROUP_CONCAT:
|
|
320
|
-
|
|
386
|
+
arg = self.rpt
|
|
387
|
+
extra = None
|
|
388
|
+
if len(arg) == 0:
|
|
389
|
+
extra = col_name
|
|
390
|
+
elif len(arg) == 1 and isinstance(arg[0], FieldBase):
|
|
391
|
+
extra = f"{arg[0].op} {arg[0].col.name}"
|
|
392
|
+
else:
|
|
393
|
+
# todo : DISTINCT name ORDER BY name ASC SEPARATOR '; '
|
|
394
|
+
extra = col_name
|
|
395
|
+
|
|
396
|
+
return f"GROUP_CONCAT({extra})", None
|
|
397
|
+
elif op == OP.DISTINCT:
|
|
398
|
+
return f"DISTINCT {col_name}", None
|
|
321
399
|
|
|
322
400
|
|
|
323
401
|
class Expression(FieldBase):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.29"
|
|
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
|
|
File without changes
|
|
File without changes
|