nlbone 0.7.23__py3-none-any.whl → 0.7.24__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.
- nlbone/utils/flatten_sqlalchemy_result.py +26 -0
- {nlbone-0.7.23.dist-info → nlbone-0.7.24.dist-info}/METADATA +1 -1
- {nlbone-0.7.23.dist-info → nlbone-0.7.24.dist-info}/RECORD +6 -5
- {nlbone-0.7.23.dist-info → nlbone-0.7.24.dist-info}/WHEEL +0 -0
- {nlbone-0.7.23.dist-info → nlbone-0.7.24.dist-info}/entry_points.txt +0 -0
- {nlbone-0.7.23.dist-info → nlbone-0.7.24.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from typing import List, Any
|
|
2
|
+
from sqlalchemy import Row
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def flatten_sqlalchemy_result(items: List[Any]) -> List[Any]:
|
|
6
|
+
"""
|
|
7
|
+
Converts a list of SQLAlchemy Rows (tuples) into a flat list of entities
|
|
8
|
+
with extra fields injected as attributes.
|
|
9
|
+
"""
|
|
10
|
+
if not items:
|
|
11
|
+
return []
|
|
12
|
+
|
|
13
|
+
if not isinstance(items[0], Row):
|
|
14
|
+
return items
|
|
15
|
+
|
|
16
|
+
normalized = []
|
|
17
|
+
for row in items:
|
|
18
|
+
entity = row[0]
|
|
19
|
+
|
|
20
|
+
for key, value in row._mapping.items():
|
|
21
|
+
if not isinstance(value, type(entity)):
|
|
22
|
+
setattr(entity, key, value)
|
|
23
|
+
|
|
24
|
+
normalized.append(entity)
|
|
25
|
+
|
|
26
|
+
return normalized
|
|
@@ -109,12 +109,13 @@ nlbone/utils/cache_keys.py,sha256=Y2YSellHTbUOcoaNbl1jaD4r485VU_e4KXsfBWhYTBo,10
|
|
|
109
109
|
nlbone/utils/cache_registry.py,sha256=3FWYyhujW8oPBiVUPzk1CqJ3jJfxs9729Sbb1pQ5Fag,707
|
|
110
110
|
nlbone/utils/context.py,sha256=TXZtORxyWcBiZozNzmXeZhXxDCXXuM91JfrQj-SkFK8,1851
|
|
111
111
|
nlbone/utils/crypto.py,sha256=PX0Tlf2nqXcGbuv16J26MoUPzo2c4xcD4sZBXxhBXgQ,746
|
|
112
|
+
nlbone/utils/flatten_sqlalchemy_result.py,sha256=JGwQEauoJVjhzvXrOtqabj3wQ7zp2-OPwhuh44sUdUE,625
|
|
112
113
|
nlbone/utils/http.py,sha256=0yeI34j5FfelqvX3PJnKknSXji1jl15VYbVIIvrSbXg,997
|
|
113
114
|
nlbone/utils/normalize_mobile.py,sha256=sGH4tV9gX-6eVKozviNWJhm1DN1J28Nj-ERldCYkS_E,732
|
|
114
115
|
nlbone/utils/redactor.py,sha256=-V4HrHmHwPi3Kez587Ek1uJlgK35qGSrwBOvcbw8Jas,1279
|
|
115
116
|
nlbone/utils/time.py,sha256=DjjyQ9GLsfXoT6NK8RDW2rOlJg3e6sF04Jw6PBUrSvg,1268
|
|
116
|
-
nlbone-0.7.
|
|
117
|
-
nlbone-0.7.
|
|
118
|
-
nlbone-0.7.
|
|
119
|
-
nlbone-0.7.
|
|
120
|
-
nlbone-0.7.
|
|
117
|
+
nlbone-0.7.24.dist-info/METADATA,sha256=TALHyRIYFLxc26D-cl3aTYM6-E1TSNfiUcEgHjfg9lA,2295
|
|
118
|
+
nlbone-0.7.24.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
119
|
+
nlbone-0.7.24.dist-info/entry_points.txt,sha256=CpIL45t5nbhl1dGQPhfIIDfqqak3teK0SxPGBBr7YCk,59
|
|
120
|
+
nlbone-0.7.24.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
121
|
+
nlbone-0.7.24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|