#33548: Use -> operator to implement KeyTransform on SQLite 3.38+
-------------------------------------+-------------------------------------
Reporter: Sage Abdullah | Owner:
Type: | rajdesai24
Cleanup/optimization | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: sqlite jsonfield | Triage Stage: Accepted
keytransform |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by rajdesai24):
I am quite new to this topic but based on what I can understand how about
we put a simple version check and return the value accordingly
something like the following which checks the version and returns the
value accordingly.
{{{
if connection.sqlite_version >= '3.38':
return (
"(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) "
"THEN JSON_TYPE(%s, %%s) ELSE (%s ->> %%s) END)"
) % (lhs, datatype_values, lhs, lhs), (tuple(params) +
(json_path,)) * 3
else:
return (
"(CASE WHEN JSON_TYPE(%s, %%s) IN (%s) "
"THEN JSON_TYPE(%s, %%s) ELSE JSON_EXTRACT(%s, %%s) END)"
) % (lhs, datatype_values, lhs, lhs), (tuple(params) +
(json_path,)) * 3
}}}
This might make it redundant but please let me know of any suggestions.
Till then I will dive deeper
--
Ticket URL: <https://code.djangoproject.com/ticket/33548#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701863d083ebe-9452f15f-9e82-48ff-bc55-3c4d4da5f5a0-000000%40eu-central-1.amazonses.com.