﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34466	Django 4.2 overwrites user-specified psycopg cursor_factory	Anders Kaseorg	Anders Kaseorg	"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.)"	Bug	closed	Database layer (models, ORM)	4.2	Release blocker	fixed		Daniele Varrazzo Florian Apolloner	Ready for checkin	1	0	0	0	0	0
