Thing: Add in_ operator.

This commit is contained in:
bsimpson63
2012-11-18 13:58:18 -05:00
parent b9afde3e1a
commit 9723a6fc9f
2 changed files with 6 additions and 0 deletions

View File

@@ -50,6 +50,7 @@ class lt(op): pass
class lte(op): pass
class gt(op): pass
class gte(op): pass
class in_(op): pass
class Slot(object):
def __init__(self, lval):
@@ -80,6 +81,9 @@ class Slot(object):
def __ge__(self, other):
return gte(self, self.name, other)
def in_(self, other):
return in_(self, self.name, other)
class Slots(object):
def __getattr__(self, attr):
return Slot(attr)

View File

@@ -726,6 +726,8 @@ def sa_op(op):
fn = lambda x,y: x >= y
elif isinstance(op, operators.lte):
fn = lambda x,y: x <= y
elif isinstance(op, operators.in_):
return sa.or_(op.lval.in_(op.rval))
rval = tup(op.rval)