Small optimization in getForFields
authorSverre Rabbelier <srabbelier@gmail.com>
Fri, 06 Mar 2009 22:30:12 +0000
changeset 1696 7b120f7f9a7a
parent 1695 d0f8d033cf3c
child 1697 ffda5c32283b
Small optimization in getForFields If the value is a list with only one element, make it a value instead. Patch by: Sverre Rabbelier
app/soc/logic/models/base.py
--- a/app/soc/logic/models/base.py	Fri Mar 06 19:06:22 2009 +0000
+++ b/app/soc/logic/models/base.py	Fri Mar 06 22:30:12 2009 +0000
@@ -317,6 +317,8 @@
     query = db.Query(self._model)
 
     for key, value in filter.iteritems():
+      if isinstance(value, list) and len(value) == 1:
+        value = value[0]
       if isinstance(value, list):
         op = '%s IN' % key
         query.filter(op, value)