-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
The way we store arrays in SQLite is by converting the values to JSON strings, and then storing them in a text field.
We have this function which converts list values into JSON:
piccolo/piccolo/engine/sqlite.py
Lines 84 to 91 in 0e2ec8a
| def convert_array_in(value: list): | |
| """ | |
| Converts a list value into a string. | |
| """ | |
| if value and type(value[0]) not in [str, int, float, list]: | |
| raise ValueError("Can only serialise str, int, float, and list.") | |
| return dump_json(value) |
We validate the types here to make sure we can serialise it.
The list of types is fairly limited - it excludes Decimal, date, and datetime, because Python's json.dumps is pretty restrictive. We might be able to extend json.dumps to handle these additional types.
Note - if orjson is installed, this is less of a problem, as it serialises far more types.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
Done