diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-01-10 11:13:34 -0500 |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-01-10 11:13:34 -0500 |
commit | 7bd04867e53d78ddb0f5e8f78b9256298d41fadd (patch) | |
tree | c6d529a2ceb6a8ec7335f74d53f8d20af6629e4f /Lib/sqlite3/test | |
parent | 8eee081d4041a59b3c8088cba8dcaafc22a88c00 (diff) | |
parent | b52312923bee35b86fc072ec546cc3e588ae64c9 (diff) | |
download | cpython-git-7bd04867e53d78ddb0f5e8f78b9256298d41fadd.tar.gz |
merge #15545: fix sqlite3.iterdump regression on unsortable row_factory objects.
The fix for issue 9750 introduced a regression by sorting the row objects
returned by fetchall. But if a row_factory such as sqlite3.Row is used, the
rows may not be sortable (in Python3), which leads to an exception. The
sorting is still a nice idea, so the patch moves the sort into the sql.
Fix and test by Peter Otten.
Diffstat (limited to 'Lib/sqlite3/test')
-rw-r--r-- | Lib/sqlite3/test/dump.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py index b200333afa..a1f45a46dc 100644 --- a/Lib/sqlite3/test/dump.py +++ b/Lib/sqlite3/test/dump.py @@ -49,6 +49,27 @@ class DumpTests(unittest.TestCase): [self.assertEqual(expected_sqls[i], actual_sqls[i]) for i in range(len(expected_sqls))] + def CheckUnorderableRow(self): + # iterdump() should be able to cope with unorderable row types (issue #15545) + class UnorderableRow: + def __init__(self, cursor, row): + self.row = row + def __getitem__(self, index): + return self.row[index] + self.cx.row_factory = UnorderableRow + CREATE_ALPHA = """CREATE TABLE "alpha" ("one");""" + CREATE_BETA = """CREATE TABLE "beta" ("two");""" + expected = [ + "BEGIN TRANSACTION;", + CREATE_ALPHA, + CREATE_BETA, + "COMMIT;" + ] + self.cu.execute(CREATE_BETA) + self.cu.execute(CREATE_ALPHA) + got = list(self.cx.iterdump()) + self.assertEqual(expected, got) + def suite(): return unittest.TestSuite(unittest.makeSuite(DumpTests, "Check")) |