From: Nathan Yergler Date: Tue, 27 Nov 2012 04:24:30 +0000 (-0800) Subject: Ensure query_dict is a dict after the contents have been modified. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=afe0afdb88727de854de48909e4eb28c1ff57c66;p=mediagoblin.git Ensure query_dict is a dict after the contents have been modified. _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. --- diff --git a/mediagoblin/db/sql/base.py b/mediagoblin/db/sql/base.py index e10e7739..ca0c8166 100644 --- a/mediagoblin/db/sql/base.py +++ b/mediagoblin/db/sql/base.py @@ -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()