]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44041: Add test for sqlite3 column count (GH-25907)
authorErlend Egeberg Aasland <erlend.aasland@innova.no>
Fri, 4 Jun 2021 17:36:08 +0000 (19:36 +0200)
committerGitHub <noreply@github.com>
Fri, 4 Jun 2021 17:36:08 +0000 (18:36 +0100)
Lib/sqlite3/test/dbapi.py

index 77fafe093002eba68f687635830cca2d9dda4351..4bda6aa393e3ffc4b14c3a6c500ac9a49a775479 100644 (file)
@@ -555,6 +555,17 @@ class CursorTests(unittest.TestCase):
         ]
         self.assertEqual(results, expected)
 
+    def test_column_count(self):
+        # Check that column count is updated correctly for cached statements
+        select = "select * from test"
+        res = self.cu.execute(select)
+        old_count = len(res.description)
+        # Add a new column and execute the cached select query again
+        self.cu.execute("alter table test add newcol")
+        res = self.cu.execute(select)
+        new_count = len(res.description)
+        self.assertEqual(new_count - old_count, 1)
+
 
 class ThreadTests(unittest.TestCase):
     def setUp(self):