mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 16:28:01 -05:00
Thing: Add in_ operator.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user