Commits

Alex Gaynor  committed 3a9ce32

DML queries don't have a description.

  • Participants
  • Parent commits d2a47f3

Comments (0)

Files changed (2)

File lib-python/modified-2.7.0/sqlite3/test/regression.py

         """
         self.assertRaises(sqlite.Warning, self.con, 1)
 
+    def CheckUpdateDescriptionNone(self):
+        """
+        Call Cursor.update with an UPDATE query and check that it sets the
+        cursor's description to be None.
+        """
+        cur = self.con.cursor()
+        cur.execute("CREATE TABLE foo (id INTEGER)")
+        cur.execute("UPDATE foo SET id = 3 WHERE id = 1")
+        self.assertEqual(cur.description, None)
+
 def suite():
     regression_suite = unittest.makeSuite(RegressionTests, "Check")
     return unittest.TestSuite((regression_suite,))

File lib_pypy/_sqlite3.py

 from threading import _get_ident as thread_get_ident
 
 names = "sqlite3.dll libsqlite3.so.0 libsqlite3.so libsqlite3.dylib".split()
-for name in names: 
+for name in names:
     try:
-        sqlite = cdll.LoadLibrary(name) 
+        sqlite = cdll.LoadLibrary(name)
         break
     except OSError:
         continue
         self.statement = None
 
     def _get_description(self):
+        if self.kind == "DML":
+            return None
         desc = []
         for i in xrange(sqlite.sqlite3_column_count(self.statement)):
             name = sqlite.sqlite3_column_name(self.statement, i).split("[")[0].strip()
 
 def _convert_result(con, val):
     if val is None:
-        sqlite.sqlite3_result_null(con)        
+        sqlite.sqlite3_result_null(con)
     elif isinstance(val, (bool, int, long)):
         sqlite.sqlite3_result_int64(con, int(val))
     elif isinstance(val, str):