Simplifying the test for whether or not a user and slug combo exists.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Wed, 27 Feb 2013 15:56:56 +0000 (09:56 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Wed, 27 Feb 2013 15:56:56 +0000 (09:56 -0600)
Thanks to tchernobog for catching this (it was breaking on postgres)
and Elrond for the suggestion on how to fix it.

This commit sponsored by Caleb Cooper.  Thanks Caleb!

mediagoblin/db/migrations.py

index e9b4e9ef98c8901ec6896cef4938756f432a07ce..167c4f87d3e72d077758d16e4c4c9a2e9ea223e9 100644 (file)
@@ -215,12 +215,10 @@ def mediaentry_new_slug_era(db):
     import uuid
 
     def slug_and_user_combo_exists(slug, uploader):
-        # Technically returns the number of entries with this slug and user
-        # that already exist
         return db.execute(
             media_table.select(
                 and_(media_table.c.uploader==uploader,
-                     media_table.c.slug==slug)).count()).first().tbl_row_count
+                     media_table.c.slug==slug))).first() is not None
 
     def append_garbage_till_unique(row, new_slug):
         """