set .rowcount properly

master
baztian 2011-04-20 18:06:26 +02:00
parent b99a82157a
commit cca02219f7
3 changed files with 23 additions and 1 deletions

View File

@ -155,6 +155,10 @@ distribution for details.
Changelog
=========
- 0.1.4
- Set ``.rowcount`` properly.
- 0.1.3
- Fixed DB-API_ violation: Use ``curs.execute('foo ?', (bar, baz))``

View File

@ -268,10 +268,12 @@ class Cursor(object):
self._prep = self._connection.jconn.prepareStatement(operation)
self._set_stmt_parms(self._prep, parameters)
is_rs = self._prep.execute()
self.update_count = self._prep.getUpdateCount()
if is_rs:
self._rs = self._prep.getResultSet()
self._meta = self._rs.getMetaData()
self.rowcount = -1
else:
self.rowcount = self._prep.getUpdateCount()
# self._prep.getWarnings() ???
def executemany(self, operation, seq_of_parameters):

View File

@ -224,3 +224,19 @@ class IntegrationTest(TestCase):
cursor.close()
value = result[0]
assert 'abcdef' == value
def test_execute_different_rowcounts(self):
cursor = self.conn.cursor()
stmt = "insert into ACCOUNT (ACCOUNT_ID, ACCOUNT_NO, BALANCE) " \
"values (?, ?, ?)"
parms = (
( '2009-09-11 14:15:22.123450', 20, 13.1 ),
( '2009-09-11 14:15:22.123452', 22, 13.3 ),
)
cursor.executemany(stmt, parms)
assert cursor.rowcount == 2
parms = ( '2009-09-11 14:15:22.123451', 21, 13.2 )
cursor.execute(stmt, parms)
assert cursor.rowcount == 1
cursor.execute("select * from ACCOUNT")
assert cursor.rowcount == -1