From c0ba74dd885c840c7ca0a1b4abd0d033d2a58092 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Thu, 13 Jun 2013 15:30:59 -0500 Subject: [PATCH] fixed Issue 1526:MongoDBAdapter contains() doesn't work for list:reference types, thanks schlegel --- VERSION | 2 +- gluon/dal.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 7da240bd..d5ec45a4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.5.1-stable+timestamp.2013.06.13.15.20.01 +Version 2.5.1-stable+timestamp.2013.06.13.15.30.17 diff --git a/gluon/dal.py b/gluon/dal.py index 9289442d..6f9e95e8 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -5704,8 +5704,9 @@ class MongoDBAdapter(NoSQLAdapter): # silently ignore, only case sensitive # There is a technical difference, but mongodb doesn't support # that, but the result will be the same - return {self.expand(first) : ('/%s/' % \ - self.expand(second, 'string'))} + val = second if isinstance(second,self.ObjectId) else \ + {' $regex':".*" + re.escape(self.expand(second, 'string')) + ".*"} + return {self.expand(first) : val} def LIKE(self, first, second): import re