Postgres already has support for dict and list types (also) depending on Postgres installation and stuff, so that could be a viable alternative also though it would be different than what SQLite would have to do, which might cause issues, though I'm not sure how often you would really switch from postgres to sqlite or vice versa.
SQLite has similar adapters/converters:
d = DictType()
sqlite3.register_adapter(dict, d.adapt)
sqlite3.register_converter('BINARY', d.convert)
I was thinking of doing something similar to Postgres's binary syntax where the converted values would be prepended with something like \dict or \list and then I would do something similar to the ObjectField where the value is pickled and then base64 encoded. So the converter could check to see if the string started with \dict or whatnot and if it was then it would convert back to the object, this way it could co-exist with other binary or text fields that it gets run against.
in Postgres, this can be accomplished by doing:
Here are the adapting docs and the converting docs.
the register_adapter docs will be handy also.
Postgres already has support for dict and list types (also) depending on Postgres installation and stuff, so that could be a viable alternative also though it would be different than what SQLite would have to do, which might cause issues, though I'm not sure how often you would really switch from postgres to sqlite or vice versa.
SQLite has similar adapters/converters:
I was thinking of doing something similar to Postgres's binary syntax where the converted values would be prepended with something like
\dict
or\list
and then I would do something similar to theObjectField
where the value is pickled and then base64 encoded. So the converter could check to see if the string started with\dict
or whatnot and if it was then it would convert back to the object, this way it could co-exist with other binary or text fields that it gets run against.Really, being able to do:
and having everything just work is something I've always wanted to solve but I've never quite liked any of the solutions I've come up with
.