Re: [Django] #34486: SearchHeadline crashes without an active connection. (was: SearchVector.as_sql causes AttributeError)

5 views
Skip to first unread message

Django

unread,
Apr 12, 2023, 5:54:09 AM4/12/23
to django-...@googlegroups.com
#34486: SearchHeadline crashes without an active connection.
----------------------------------+------------------------------------
Reporter: Scott Macpherson | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: 4.2
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* status: closed => new
* severity: Normal => Release blocker
* cc: Florian Apolloner, Daniele Varrazzo (added)
* resolution: duplicate =>
* stage: Unreviewed => Accepted


Comment:

Great catch! We should ensure an active connection in `mogrify()` with
`psycopg` version 3, e.g.
{{{#!diff
diff --git a/django/db/backends/postgresql/psycopg_any.py
b/django/db/backends/postgresql/psycopg_any.py
index 579104dead..1fe6b15caf 100644
--- a/django/db/backends/postgresql/psycopg_any.py
+++ b/django/db/backends/postgresql/psycopg_any.py
@@ -18,7 +18,8 @@ try:
TSTZRANGE_OID = types["tstzrange"].oid

def mogrify(sql, params, connection):
- return ClientCursor(connection.connection).mogrify(sql, params)
+ with connection.cursor() as cursor:
+ return ClientCursor(cursor.connection).mogrify(sql, params)

# Adapters.
class BaseTzLoader(TimestamptzLoader):
}}}

Would you like to prepare a patch (via GitHub PR)? a regression test is
required.

--
Ticket URL: <https://code.djangoproject.com/ticket/34486#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages