Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more array types for SQLite #941

Open
dantownsend opened this issue Mar 4, 2024 · 0 comments
Open

Allow more array types for SQLite #941

dantownsend opened this issue Mar 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@dantownsend
Copy link
Member

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:

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.

@dantownsend dantownsend added the enhancement New feature or request label Mar 4, 2024
@dantownsend dantownsend added this to To do in Enhancements via automation Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant