smarted BELONGS, thanks Jonathan
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.6.0-development+timestamp.2013.08.09.04.48.26
|
Version 2.6.0-development+timestamp.2013.08.09.11.04.59
|
||||||
|
|||||||
+11
-6
@@ -1263,12 +1263,17 @@ class BaseAdapter(ConnectionPool):
|
|||||||
return '(%s OR %s)' % (self.expand(first), self.expand(second))
|
return '(%s OR %s)' % (self.expand(first), self.expand(second))
|
||||||
|
|
||||||
def BELONGS(self, first, second):
|
def BELONGS(self, first, second):
|
||||||
if isinstance(second, str):
|
if isinstance(second, str):
|
||||||
return '(%s IN (%s))' % (self.expand(first), second[:-1])
|
return '(%s IN (%s))' % (self.expand(first), second[:-1])
|
||||||
elif not second:
|
if not second:
|
||||||
return '(1=0)'
|
return '(1=0)'
|
||||||
items = ','.join(self.expand(item, first.type) for item in second)
|
if isinstance(second, (list,tuple,frozenset)):
|
||||||
return '(%s IN (%s))' % (self.expand(first), items)
|
second = set(second) # remove duplicates, make mutable
|
||||||
|
if isinstance(second, set) and None in second:
|
||||||
|
second = second.remove(None)
|
||||||
|
return self.OR(self.EQ(first, None), self.BELONGS(first, second))
|
||||||
|
items = ','.join(self.expand(item, first.type) for item in second)
|
||||||
|
return '(%s IN (%s))' % (self.expand(first), items)
|
||||||
|
|
||||||
def REGEXP(self, first, second):
|
def REGEXP(self, first, second):
|
||||||
"regular expression operator"
|
"regular expression operator"
|
||||||
|
|||||||
Reference in New Issue
Block a user