#34466: Django 4.2 overwrites user-specified psycopg cursor_factory
-------------------------------------+-------------------------------------
Reporter: Anders | Owner: nobody
Kaseorg |
Type: Bug | Status: new
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Zulip
[https://github.com/zulip/zulip/blob/7c023042cfbbd8817d5ba3adfca365734500a0e2/zproject/computed_settings.py#L285
configures] a custom `cursor_factory` that
[https://github.com/zulip/zulip/blob/7c023042cfbbd8817d5ba3adfca365734500a0e2/zerver/lib/db.py#L31
wraps] `psycopg2.extensions.cursor` to collect timing statistics for
logging. But this no longer works in Django 4.2 due to
09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca (#33308) and
0e2649fdf40cedc5be7e2c0e5f7711f315e36b84 (#34255) because
`DatabaseWrapper.get_new_connection` now unconditionally overwrites
`connection.cursor_factory` (even for psycopg2).
The configured `cursor_factory` is being passed to `get_new_connection` as
`conn_params["cursor_factory"]`. `get_new_connection` should leave that
alone if it’s set. (And if it’s not, it might also be cleaner for to pass
the default `cursor_factory` via a keyword argument to
`psycopg[2].connect` too, rather than mutating it later.)
--
Ticket URL: <https://code.djangoproject.com/ticket/34466>
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/0107018758113deb-91df768d-39bc-4482-934b-49d346fa1803-000000%40eu-central-1.amazonses.com.