Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#12759 closed (fixed)

raw_query tests fail with psycopg1 backend

Reported by: Karen Tracey Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Failure is:

======================================================================
ERROR: testAnnotations (modeltests.raw_query.tests.RawQueryTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\u\kmt\django\trunk\tests\modeltests\raw_query\tests.py", line 160, in testAnnotations
    self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations)
  File "D:\u\kmt\django\trunk\tests\modeltests\raw_query\tests.py", line 13, in assertSuccessfulRawQuery
    results = list(model.objects.raw(query, params=params, translations=translations))
  File "d:\u\kmt\django\trunk\django\db\models\query.py", line 1331, in __iter__
    for row in self.query:
  File "d:\u\kmt\django\trunk\django\db\models\sql\query.py", line 58, in __iter__
    return iter(self.cursor)
  File "d:\u\kmt\django\trunk\django\db\backends\postgresql\base.py", line 79, in __iter__
    return iter(self.cursor)
TypeError: 'cursor' object is not iterable

----------------------------------------------------------------------
Ran 152 tests in 40.608s

FAILED (errors=1)

(Thhis was with --failfast specified so tests stopped after first failure.)

Change History (4)

comment:1 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Thejaswi Puthraya, 15 years ago

Just for the record, the psycopg cursor does not implement any 'dunder' (double-underscore) methods...

>>> import psycopg, psycopg2
>>>
>>> conn1=psycopg.connect("user=username password=pwd")
>>> conn2=psycopg2.connect("user=username password=pwd")
 
>>> cur1=conn1.cursor()
>>> iter(cur1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'cursor' object is not iterable
 
>>> cur2=conn2.cursor()
>>> iter(cur2)
<cursor object at 0x86c35dc; closed: 0>
 
>>> dir(cur1)
['arraysize', 'autocommit', 'callproc', 'close', 'commit', 'copy_from', 'copy_to', 'description', 'dictfetchall', 'dictfetchmany', 'dictfetchone', 'execute', 'executemany', 'fetchall', 'fetchmany', 'fetchone', 'fileno', 'lastoid', 'lastrowid', 'nextset', 'notifies', 'rollback', 'rowcount', 'scroll', 'setinputsizes', 'setoutputsize', 'statusmessage']
 
>>> dir(cur2)
['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'arraysize', 'binary_types', 'callproc', 'close', 'closed', 'connection', 'copy_expert', 'copy_from', 'copy_to', 'description', 'execute', 'executemany', 'fetchall', 'fetchmany', 'fetchone', 'fileno', 'isready', 'lastrowid', 'mogrify', 'name', 'next', 'nextset', 'query', 'row_factory', 'rowcount', 'rownumber', 'scroll', 'setinputsizes', 'setoutputsize', 'statusmessage', 'string_types', 'typecaster', 'tzinfo_factory']

comment:3 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

(In [12845]) Fixed #12759 -- Fixed the iterator method on psycopg1 cursors, which was preventing the raw_query tests from passing.

comment:4 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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