Author: johannes
Date: 2005-07-08 03:12:18 -0500 (Fri, 08 Jul 2005)
New Revision: 7709

Modified:
   trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py
Log:
Catch broken row counts which are not reported by the drivers


Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py       
2005-07-08 07:57:10 UTC (rev 7708)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/ResultSet.py       
2005-07-08 08:12:18 UTC (rev 7709)
@@ -23,10 +23,23 @@
 
 __all__ = ['ResultSet']
 
+from gnue.common.apps import errors
 from gnue.common.datasources.drivers import Base
 
 
 # =============================================================================
+# Exceptions
+# =============================================================================
+
+class InvalidRowCountError (errors.SystemError):
+  def __init__ (self, drivername, value):
+    msg = u_("The driver '%(driver)s' returned an invalid row " \
+             "count '%(count)s'") \
+          % {'driver': drivername, 'count': value}
+    errors.SystemError.__init__ (self, msg)
+
+
+# =============================================================================
 # ResultSet class
 # =============================================================================
 
@@ -105,6 +118,11 @@
     if not connection._broken_rowcount_:
       self.__count = self.__cursor.rowcount
 
+    # If the driver has a broken rowcount, but does not report it as broken,
+    # protect clients from behaving very strange
+    if self.__count is None or self.__count < 0:
+      raise InvalidRowCountError, (connection._drivername_, self.__count)
+
     self.__connection = connection
     self.__fieldnames = fieldnames
 



_______________________________________________
Commit-gnue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/commit-gnue

Reply via email to