在 RethinkDB 的数据浏览器中,我使用 javascript 成功运行了这个查询:
r.db('my_db').table('my_table').filter(function(row){return row('some_key').match(".sometext.")})
但是当我像这样在python中相应地运行它时:
r.db('my_db').table('my_table').filter(lambda row: row('some_key').match(".sometext."))
我收到以下错误:
TypeError: 'Var' object is not callable
In [16]: rql = r.db('my_db').table('my_table').filter(lambda row: row('some_key').match(".sometext."))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-16-09fcb943624a> in <module>()
----> 1 rql = r.db('my_db').table('my_table').filter(lambda row: row('some_key').match(".sometext."))
/usr/lib64/python2.7/site-packages/rethinkdb/ast.pyc in filter(self, func, default)
348
349 def filter(self, func, default=()):
--> 350 return Filter(self, func_wrap(func), default=default)
351
352 def concat_map(self, func):
/usr/lib64/python2.7/site-packages/rethinkdb/ast.pyc in func_wrap(val)
1161 # Called on arguments that should be functions
1162 def func_wrap(val):
-> 1163 val = expr(val)
1164
1165 # Scan for IMPLICIT_VAR or JS
/usr/lib64/python2.7/site-packages/rethinkdb/ast.pyc in expr(val, nesting_depth)
43 return MakeObj(obj)
44 elif isinstance(val, collections.Callable):
---> 45 return Func(val)
46 else:
47 return Datum(val)
/usr/lib64/python2.7/site-packages/rethinkdb/ast.pyc in __init__(self, lmbd)
1198
1199 self.vrs = vrs
-> 1200 self.args = [MakeArray(*vrids), expr(lmbd(*vrs))]
1201 self.optargs = {}
为什么..?