Fix issue #5411 sqlite connection closes
authorAndrew Browning <ayleph@thisshitistemp.com>
Tue, 23 Feb 2016 00:15:40 +0000 (19:15 -0500)
committerBoris Bobrov <breton@cynicmansion.ru>
Tue, 23 Feb 2016 00:32:34 +0000 (03:32 +0300)
This update changes migrations to wrap db.execute results in a list to
keep the connection from closing for sqlite migrations.

mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py
mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py

index 800e044862ff8b039352b626f6e7c279db34687c..723100c55b356afa9e863e2380b2e993a1446918 100644 (file)
@@ -32,7 +32,8 @@ def upgrade():
     collection_items_table = inspect_table(metadata, "core__collection_items")
     graveyard_table = inspect_table(metadata, "core__graveyard")
 
-    for tombstone in db.execute(graveyard_table.select()):
+    res = list(db.execute(graveyard_table.select()))
+    for tombstone in res:
         # Get GMR for tombstone
         gmr = db.execute(gmr_table.select().where(and_(
             gmr_table.c.obj_pk == tombstone.id,
index 8f222a6ae59131472ef26e8bbba3b77cf1bb395a..978260df3eacb735491f303508e21de0c87887e1 100644 (file)
@@ -28,7 +28,8 @@ def upgrade():
     graveyard_table = inspect_table(metadata, "core__graveyard")
     gmr_table = inspect_table(metadata, "core__generic_model_reference")
     
-    for tombstone in db.execute(gmr_table.select()):
+    res = list(db.execute(gmr_table.select()))
+    for tombstone in res:
         # Look up the gmr for the tombstone8
         gmr = db.execute(gmr_table.select().where(and_(
             gmr_table.c.obj_pk == tombstone.id,