-
Notifications
You must be signed in to change notification settings - Fork 405
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
How to override json encode/decode? #73
Comments
Connection.set_type_codec now allows overriding codecs for builtin types. Per complaint in #73.
Current
There's no defined
There's no formal documentation AFAIK. Read |
Thanks, your merge has all the info I needed for now. Likewise thanks for the additional detail re: _new_connection. |
Any plans to push it to master branch ? |
by the way, I use to get this error: unsupported jsonb version number 34
so I updated my encoder to
\x01 helped but I'm not sure if that a right solution |
Connection.set_type_codec now allows overriding codecs for builtin types. Per complaint in #73.
#75 has been merged. Closing. |
BTW, in asyncpg 0.10.0 (about to be released) you shouldn't override |
(if locally, which version of Cython was used)?: wheel
uvloop?: yes
I'd like to override json's encode/decode to avoid the need to dumps/loads my data-structure myself. However, I don't see any examples of how to override an existing codec so I end using connection pool's setup flag (as it's the only way I see to call
set_type_codec
). I end up with something like:This doesn't seem to do anything. So I add the
binary=True
flag and get:Since this runs on every
.acquire
(and, I guess, since there's an existing codec). I'd need to somehow prevent that since I only need to call it once per connection creation. So, I tried using a weakvaluedictionary:But this isn't permitted since connections don't have a
__weakref__
attribute due to the use of__slots__
:https://docs.python.org/3.6/reference/datamodel.html#notes-on-using-slots
So this is really a few questions:
The text was updated successfully, but these errors were encountered: