我在尝试在JSONB对象中包含的数据上执行无烧瓶 - 静止的API查询很难。我会猜到这是因为基础查询不知道如何投放数据字段,因此它不知道如何正确生成查询,但我不确定。
我执行Ajax搜索时正在运行的查询:
http://192.168.163.129:1080/api/subscribers?page=1&results_per_page=10&q={"filters":[{"name":"data","op":"has","val":{"name":"full_name","op":"eq","val":"%Steve%"}}],"order_by":[{"field":"created","direction":"asc"}]}
这是我运行查询时得到的追溯。
2016-12-29 22:26:33,068 - app - ERROR - mapper
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/flask_restless/views.py", line 1172, in _search
result = search(self.session, self.model, search_params)
File "/usr/local/lib/python2.7/dist-packages/flask_restless/search.py", line 587, in search
query = create_query(session, model, search_params, _ignore_order_by)
File "/usr/local/lib/python2.7/dist-packages/flask_restless/search.py", line 549, in create_query
_ignore_order_by)
File "/usr/local/lib/python2.7/dist-packages/flask_restless/search.py", line 480, in create_query
filters = [create_filt(model, filt) for filt in search_params.filters]
File "/usr/local/lib/python2.7/dist-packages/flask_restless/search.py", line 438, in _create_filter
return create_op(model, fname, filt.operator, val, relation)
File "/usr/local/lib/python2.7/dist-packages/flask_restless/search.py", line 411, in _create_operation
return opfunc(field, argument, fieldname)
File "/usr/local/lib/python2.7/dist-packages/flask_restless/search.py", line 106, in <lambda>
'has': lambda f, a, fn: f.has(_sub_operator(f, a, fn)),
File "/usr/local/lib/python2.7/dist-packages/flask_restless/search.py", line 37, in _sub_operator
submodel = model.property.mapper.class_
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 833, in __getattr__
return self._fallback_getattr(key)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 811, in _fallback_getattr
raise AttributeError(key)
AttributeError: mapper
API代码:
manager.create_api(Subscribers, methods=['GET'], results_per_page=10,
preprocessors=dict(GET_SINGLE=[subscribers_preprocessor],
GET_MANY=[subscribers_preprocessor]))
预处理器是一个简单的身份验证处理器。
任何想法如何正确格式化用于在JSONB Postgres字段上过滤的过滤器?
此时的答案是,您不能像以下
我做了一些修改以使其无烧结,以拆分特殊格式的查询字符串,并正确施放JSONB的查询。有点痛苦,可能无法扩展。
它标记为在无烧瓶中提高无烧伤。
https://github.com/jfinkels/flask-restless/issues/623