NDB accepts set, list and tuple, thanks Quint

This commit is contained in:
Massimo
2013-11-19 17:07:19 -06:00
parent 6868ddeed5
commit df2f9e7119
2 changed files with 6 additions and 5 deletions

View File

@@ -1 +1 @@
Version 2.7.4-stable+timestamp.2013.11.18.15.40.40
Version 2.7.4-stable+timestamp.2013.11.19.17.05.52

View File

@@ -4949,11 +4949,12 @@ class GoogleDatastoreAdapter(NoSQLAdapter):
def BELONGS(self,first,second=None):
if not isinstance(second,(list, tuple, set)):
raise SyntaxError("Not supported")
if first.type != 'id':
return [GAEF(first.name,'in',self.represent(second,first.type),lambda a,b:a in b)]
else:
if not self.use_ndb:
if isinstance(second,set):
second = list(second)
if first.type == 'id':
second = [Key.from_path(first._tablename, int(i)) for i in second]
return [GAEF(first.name,'in',second,lambda a,b:a in b)]
return [GAEF(first.name,'in',second,lambda a,b:a in b)]
def CONTAINS(self,first,second,case_sensitive=False):
# silently ignoring: GAE can only do case sensitive matches!