#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.

-- 
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/0107018774e2feaf-81362aa6-4fa7-4bd9-9a57-dbbdfa76bdb7-000000%40eu-central-1.amazonses.com.

Reply via email to