Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 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:

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

Attachments (0)

Change History (4)

comment:1 Changed 4 years ago by Alex

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

comment:2 Changed 4 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 4 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 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.