-
Notifications
You must be signed in to change notification settings - Fork 514
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
Make sure get_dsn_parameters
is an actual function
#2441
Conversation
Some non-standard DB backends have their own __getattr__, which renders our check for attributes useless.
get_dsn_params
is an actual functionget_dsn_parameters
is an actual function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question about coroutines (i am soo messed up by async python...)
and hasattr(cursor_or_db.connection, "get_dsn_parameters") | ||
else db.get_connection_params() | ||
) | ||
and inspect.isfunction(cursor_or_db.connection.get_dsn_parameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a world where this could be a coroutine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be, that's a psycopg2 sync function.
Btw, sidenote to this. Something I learned while looking at this is that newer Django uses psycopg (i.e., psycopg 3) instead of psycopg2. psycopg doesn't have this function. So this condition will always fall back to using get_connection_params
instead. This is relevant because we added the get_dsn_parameters
part to bypass calling get_connection_params
for postgres.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hunch was correct 😞 Reopened the original issue: #2303
Some non-standard Django DB connectors (djongo/pymongo) define their own
__getattr__
, which renders our check for attributes trivially True, only to explode when actually trying to call the attribute as a function.Patch tested with
Closes #2438