Opened 8 years ago

Closed 8 years ago

#3618 closed (fixed)

Test fixtures break postgresql_psycopg2 backend

Reported by: Alex Dedul Owned by: adrian
Component: Database layer (models, ORM) Version: master
Severity: Keywords: psycopg2
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I get the following error:

Traceback (most recent call last):

  File "/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py", line 68, in get_response
    callback, callback_args, callback_kwargs = resolver.resolve(request.path)

  File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 162, in resolve
    sub_match = pattern.resolve(new_path)

  File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 162, in resolve
    sub_match = pattern.resolve(new_path)

  File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 118, in resolve
    return self.callback, args, kwargs

  File "/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py", line 129, in _get_callback
    raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))

ViewDoesNotExist: Tried list in module intranet.orders.views.vpn_review. Error was: 'psycopg2._psycopg.cursor' object has no attribute 'dictfetchone'

It started to work for me with this simple patch

Index: django/db/backends/postgresql_psycopg2/base.py
===================================================================
--- django/db/backends/postgresql_psycopg2/base.py  (revision 4659)
+++ django/db/backends/postgresql_psycopg2/base.py  (working copy)
@@ -54,7 +54,7 @@
         global postgres_version
         if not postgres_version:
             cursor.execute("SELECT version()")
-            postgres_version = [int(val) for val in cursor.dictfetchone()['version'].split()[1].split('.')]        
+            postgres_version = [int(val) for val in dictfetchone(cursor)['version'].split()[1].split('.')]        
         if settings.DEBUG:
             return util.CursorDebugWrapper(cursor, self)
         return cursor

Change History (1)

comment:1 Changed 8 years ago by Alex Dedul

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to fixed
  • Status changed from new to closed

Already fixed in [4660].

Note: See TracTickets for help on using tickets.
Back to Top