|
1 | 1 | from typing import Any
|
2 | 2 |
|
3 |
| -from arango.typings import Headers, Json, Jsons |
| 3 | +from arango.typings import Headers, Json |
4 | 4 |
|
5 | 5 |
|
6 | 6 | def verify_format(_: Any, res: Json) -> Json:
|
@@ -210,49 +210,17 @@ def format_collection(body: Json) -> Json:
|
210 | 210 |
|
211 | 211 | # New in 3.10
|
212 | 212 | if "computedValues" in body:
|
213 |
| - result["computedValues"] = format_collection_computed_values(body["computedValues"]) |
214 |
| - |
215 |
| - return verify_format(body, result) |
216 |
| - |
217 |
| - |
218 |
| -def format_collection_computed_values(body: Jsons) -> Jsons: |
219 |
| - """Format collection computed values data. |
220 |
| -
|
221 |
| - :param body: Input body. |
222 |
| - :type body: dict |
223 |
| - :return: Formatted body. |
224 |
| - :rtype: dict |
225 |
| - """ |
226 |
| - result: Jsons = [] |
227 |
| - |
228 |
| - for item in body: |
229 |
| - result.append(format_collection_computed_value_item(item)) |
230 |
| - |
231 |
| - return verify_format(body, result) |
232 |
| - |
233 |
| - |
234 |
| -def format_collection_computed_value_item(body: Json) -> Json: |
235 |
| - """Format a computed value item for a collection. |
236 |
| -
|
237 |
| - :param body: Input body. |
238 |
| - :type body: dict |
239 |
| - :return: Formatted body. |
240 |
| - :rtype: dict |
241 |
| - """ |
242 |
| - result: Json = {} |
243 |
| - |
244 |
| - if "name" in body: |
245 |
| - result["name"] = body["name"] |
246 |
| - if "expression" in body: |
247 |
| - result["expression"] = body["expression"] |
248 |
| - if "overwrite" in body: |
249 |
| - result["overwrite"] = body["overwrite"] |
250 |
| - if "computedOn" in body: |
251 |
| - result["computedOn"] = body["computedOn"] |
252 |
| - if "keepNull" in body: |
253 |
| - result["keepNull"] = body["keepNull"] |
254 |
| - if "failOnWarning" in body: |
255 |
| - result["failOnWarning"] = body["failOnWarning"] |
| 213 | + result["computedValues"] = [ |
| 214 | + { |
| 215 | + "name": cv["name"], |
| 216 | + "expression": cv["expression"], |
| 217 | + "overwrite": cv["overwrite"], |
| 218 | + "computedOn": cv["computedOn"], |
| 219 | + "keepNull": cv["keepNull"], |
| 220 | + "failOnWarning": cv["failOnWarning"], |
| 221 | + } |
| 222 | + for cv in body["computedValues"] |
| 223 | + ] |
256 | 224 |
|
257 | 225 | return verify_format(body, result)
|
258 | 226 |
|
|
0 commit comments