Changeset 846 for trunk/tests


Ignore:
Timestamp:
Feb 9, 2016, 2:20:10 AM (3 years ago)
Author:
cito
Message:

Do not reset cursor attributes when cursor is closed

SQLAlchemy for instance checks the rowcount after the cursor is closed.
You will only get an error if you try to fetch rows from a closed cursor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/test_dbapi20.py

    r844 r846  
    495495            self.assertRaises(pgdb.IntegrityError, cur.execute,
    496496                "insert into %s values (1)" % table)
     497        finally:
     498            con.close()
     499
     500    def test_update_rowcount(self):
     501        table = self.table_prefix + 'booze'
     502        con = self._connect()
     503        try:
     504            cur = con.cursor()
     505            cur.execute("create table %s (i int)" % table)
     506            cur.execute("insert into %s values (1)" % table)
     507            cur.execute("update %s set i=2 where i=2 returning i" % table)
     508            self.assertEqual(cur.rowcount, 0)
     509            cur.execute("update %s set i=2 where i=1 returning i" % table)
     510            self.assertEqual(cur.rowcount, 1)
     511            cur.close()
     512            # keep rowcount even if cursor is closed (needed by SQLAlchemy)
     513            self.assertEqual(cur.rowcount, 1)
    497514        finally:
    498515            con.close()
Note: See TracChangeset for help on using the changeset viewer.