writeable_schema = False
cu = connection.cursor()
+ cu.row_factory = None # Make sure we get predictable results.
# Disable foreign key constraints, if there is any foreign key violation.
violations = cu.execute("PRAGMA foreign_key_check").fetchall()
if violations:
got = list(self.cx.iterdump())
self.assertEqual(expected, got)
+ def test_dump_custom_row_factory(self):
+ # gh-118221: iterdump should be able to cope with custom row factories.
+ def dict_factory(cu, row):
+ fields = [col[0] for col in cu.description]
+ return dict(zip(fields, row))
+
+ self.cx.row_factory = dict_factory
+ CREATE_TABLE = "CREATE TABLE test(t);"
+ expected = ["BEGIN TRANSACTION;", CREATE_TABLE, "COMMIT;"]
+
+ self.cu.execute(CREATE_TABLE)
+ actual = list(self.cx.iterdump())
+ self.assertEqual(expected, actual)
+ self.assertEqual(self.cx.row_factory, dict_factory)
+
def test_dump_virtual_tables(self):
# gh-64662
expected = [