diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-17 06:20:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 06:20:56 (GMT) |
commit | f669581a9527afb0d2325f9845a86715c0ba365d (patch) | |
tree | 964f3dd5596e65d33e5349497025b44e070f33b9 /Lib/sqlite3 | |
parent | dfd34a9cd58e8150c324190f746de919e140abe8 (diff) | |
download | cpython-f669581a9527afb0d2325f9845a86715c0ba365d.zip cpython-f669581a9527afb0d2325f9845a86715c0ba365d.tar.gz cpython-f669581a9527afb0d2325f9845a86715c0ba365d.tar.bz2 |
bpo-38185: Fixed case-insensitive string comparison in sqlite3.Row indexing. (GH-16190)
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/test/factory.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py index f103211..95dd24b 100644 --- a/Lib/sqlite3/test/factory.py +++ b/Lib/sqlite3/test/factory.py @@ -98,16 +98,14 @@ class RowFactoryTests(unittest.TestCase): def CheckSqliteRowIndex(self): self.con.row_factory = sqlite.Row - row = self.con.execute("select 1 as a, 2 as b").fetchone() + row = self.con.execute("select 1 as a_1, 2 as b").fetchone() self.assertIsInstance(row, sqlite.Row) - col1, col2 = row["a"], row["b"] - self.assertEqual(col1, 1, "by name: wrong result for column 'a'") - self.assertEqual(col2, 2, "by name: wrong result for column 'a'") + self.assertEqual(row["a_1"], 1, "by name: wrong result for column 'a_1'") + self.assertEqual(row["b"], 2, "by name: wrong result for column 'b'") - col1, col2 = row["A"], row["B"] - self.assertEqual(col1, 1, "by name: wrong result for column 'A'") - self.assertEqual(col2, 2, "by name: wrong result for column 'B'") + self.assertEqual(row["A_1"], 1, "by name: wrong result for column 'A_1'") + self.assertEqual(row["B"], 2, "by name: wrong result for column 'B'") self.assertEqual(row[0], 1, "by index: wrong result for column 0") self.assertEqual(row[1], 2, "by index: wrong result for column 1") @@ -117,12 +115,25 @@ class RowFactoryTests(unittest.TestCase): with self.assertRaises(IndexError): row['c'] with self.assertRaises(IndexError): + row['a_\x11'] + with self.assertRaises(IndexError): + row['a\x7f1'] + with self.assertRaises(IndexError): row[2] with self.assertRaises(IndexError): row[-3] with self.assertRaises(IndexError): row[2**1000] + def CheckSqliteRowIndexUnicode(self): + self.con.row_factory = sqlite.Row + row = self.con.execute("select 1 as \xff").fetchone() + self.assertEqual(row["\xff"], 1) + with self.assertRaises(IndexError): + row['\u0178'] + with self.assertRaises(IndexError): + row['\xdf'] + def CheckSqliteRowSlice(self): # A sqlite.Row can be sliced like a list. self.con.row_factory = sqlite.Row |