Ticket #5411: 0001-Fix-issue-5411-sqlite-connection-closes.patch

File 0001-Fix-issue-5411-sqlite-connection-closes.patch, 2.2 KB (added by ayleph, 9 years ago)
  • mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py

    From 11b5dc71a2bd0679174d4e5b559402237b3608eb Mon Sep 17 00:00:00 2001
    From: Andrew Browning <ayleph@thisshitistemp.com>
    Date: Mon, 22 Feb 2016 19:15:40 -0500
    Subject: [PATCH] Fix issue #5411 sqlite connection closes
    
    This update changes migrations to wrap db.execute results in a list to
    keep the connection from closing for sqlite migrations.
    ---
     .../migrations/versions/101510e3a713_removes_graveyard_items_from_.py  | 3 ++-
     .../versions/8429e33fdf7_remove_the_graveyard_objects_from_.py         | 3 ++-
     2 files changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py b/mediagoblin/db/migrations/versions/101510e3a713_removes_graveyard_items_from_.py
    index 800e044..723100c 100644
    a b def upgrade():  
    3232    collection_items_table = inspect_table(metadata, "core__collection_items")
    3333    graveyard_table = inspect_table(metadata, "core__graveyard")
    3434
    35     for tombstone in db.execute(graveyard_table.select()):
     35    res = list(db.execute(graveyard_table.select()))
     36    for tombstone in res:
    3637        # Get GMR for tombstone
    3738        gmr = db.execute(gmr_table.select().where(and_(
    3839            gmr_table.c.obj_pk == tombstone.id,
  • mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py

    diff --git a/mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py b/mediagoblin/db/migrations/versions/8429e33fdf7_remove_the_graveyard_objects_from_.py
    index 8f222a6..978260d 100644
    a b def upgrade():  
    2828    graveyard_table = inspect_table(metadata, "core__graveyard")
    2929    gmr_table = inspect_table(metadata, "core__generic_model_reference")
    3030   
    31     for tombstone in db.execute(gmr_table.select()):
     31    res = list(db.execute(gmr_table.select()))
     32    for tombstone in res:
    3233        # Look up the gmr for the tombstone8
    3334        gmr = db.execute(gmr_table.select().where(and_(
    3435            gmr_table.c.obj_pk == tombstone.id,