Import sqlalchemy's and_ and use it in our select statement
authorChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 26 Feb 2013 16:15:26 +0000 (10:15 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 26 Feb 2013 16:15:26 +0000 (10:15 -0600)
This commit sponsored by Hans-Jörg Dollansky.  Thank you!

mediagoblin/db/migrations.py

index 0a3bf825546a14c5e1b5800cd743a61f1e7c9b7d..e9b4e9ef98c8901ec6896cef4938756f432a07ce 100644 (file)
@@ -21,6 +21,7 @@ from sqlalchemy import (MetaData, Table, Column, Boolean, SmallInteger,
                         ForeignKey)
 from sqlalchemy.exc import ProgrammingError
 from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.sql import and_
 from migrate.changeset.constraint import UniqueConstraint
 
 from mediagoblin.db.migration_tools import RegisterMigration, inspect_table
@@ -218,8 +219,8 @@ def mediaentry_new_slug_era(db):
         # that already exist
         return db.execute(
             media_table.select(
-                media_table.c.uploader==uploader,
-                media_table.c.slug==slug).count()).first().tbl_row_count
+                and_(media_table.c.uploader==uploader,
+                     media_table.c.slug==slug)).count()).first().tbl_row_count
 
     def append_garbage_till_unique(row, new_slug):
         """