Ensure query_dict is a dict after the contents have been modified.
authorNathan Yergler <nathan@yergler.net>
Tue, 27 Nov 2012 04:24:30 +0000 (20:24 -0800)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Mon, 10 Dec 2012 11:30:04 +0000 (12:30 +0100)
_fix_query_dict modifies its argument in place. Ensure that the
argument passed in has a local name and will be passed into the
subsequent filter_by call.

mediagoblin/db/sql/base.py

index e10e7739d4194dedf54a389deb3b8133e3d7a0a8..ca0c8166e262be4e9a52b656661834d25fbfafce 100644 (file)
@@ -51,12 +51,18 @@ class GMGTableBase(object):
     query = Session.query_property()
 
     @classmethod
-    def find(cls, query_dict={}):
+    def find(cls, query_dict=None):
+        if query_dict is None:
+            query_dict = {}
+
         _fix_query_dict(query_dict)
         return cls.query.filter_by(**query_dict)
 
     @classmethod
-    def find_one(cls, query_dict={}):
+    def find_one(cls, query_dict=None):
+        if query_dict is None:
+            query_dict = {}
+
         _fix_query_dict(query_dict)
         return cls.query.filter_by(**query_dict).first()