Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#12759 closed (fixed)

raw_query tests fail with psycopg1 backend

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


Failure is:

ERROR: testAnnotations (modeltests.raw_query.tests.RawQueryTests)
Traceback (most recent call last):
  File "D:\u\kmt\django\trunk\tests\modeltests\raw_query\", line 160, in testAnnotations
    self.assertSuccessfulRawQuery(Author, query, authors, expected_annotations)
  File "D:\u\kmt\django\trunk\tests\modeltests\raw_query\", line 13, in assertSuccessfulRawQuery
    results = list(model.objects.raw(query, params=params, translations=translations))
  File "d:\u\kmt\django\trunk\django\db\models\", line 1331, in __iter__
    for row in self.query:
  File "d:\u\kmt\django\trunk\django\db\models\sql\", line 58, in __iter__
    return iter(self.cursor)
  File "d:\u\kmt\django\trunk\django\db\backends\postgresql\", 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 Changed 6 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by thejaswi_puthraya

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 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:4 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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