summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/sqlite3/dump.py3
-rw-r--r--Lib/sqlite3/test/dump.py21
-rw-r--r--Misc/NEWS4
3 files changed, 27 insertions, 1 deletions
diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py
index da6be68..de9c368 100644
--- a/Lib/sqlite3/dump.py
+++ b/Lib/sqlite3/dump.py
@@ -25,9 +25,10 @@ def _iterdump(connection):
FROM "sqlite_master"
WHERE "sql" NOT NULL AND
"type" == 'table'
+ ORDER BY "name"
"""
schema_res = cu.execute(q)
- for table_name, type, sql in sorted(schema_res.fetchall()):
+ for table_name, type, sql in schema_res.fetchall():
if table_name == 'sqlite_sequence':
yield('DELETE FROM "sqlite_sequence";')
elif table_name == 'sqlite_stat1':
diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py
index b200333..a1f45a4 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"))
diff --git a/Misc/NEWS b/Misc/NEWS
index 4aabffe..f0b569c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -142,6 +142,10 @@ Core and Builtins
Library
-------
+- Issue #15545: Fix regression in sqlite3's iterdump method where it was
+ failing if the connection used a row factory (such as sqlite3.Row) that
+ produced unsortable objects. (Regression was introduced by fix for 9750).
+
- Issue #16491: IDLE now prints chained exception tracebacks.
- Issue #15972: Fix error messages when os functions expecting a file name or