-
Notifications
You must be signed in to change notification settings - Fork 403
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
Add equivalent to psycopg2 register_adapter
#1186
Comments
register_adapter
register_adapter
asyncpg normally relies on duck typing when accepting inputs, e.g if an argument is an integer, asyncpg will happily accept an object that implements |
What I have is a class which inherits from Pydantic Adding
It looks like the difference is that Fixing this to work more like psycopg2 would fix my issue, as would a feature like |
In psycopg2,
register_adapter
along with utility functions provides a useful way to map custom Python classes into valid representations, often by relatively simple behaviors such as casting tostr
. There is no equivalent in asyncpg meaning moving from psycopg2 to asyncpg requires adding lots ofstr()
casts to add and select queries.The closest equivalent is
set_type_codec
but this only works for types that are registered with Postgres, not custom Python classes.The text was updated successfully, but these errors were encountered: