是否可以使用GQL-IN运算符来搜索在列表属性中有项的实体?

2024-09-27 23:18:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我是说,如果你有一个模型,就像这样(Python)

class MahModel(db.Model):

它具有tags属性(例如)

^{pr2}$

我可以在查询中执行类似的操作吗?WHERE 'x' IN tags

如果没有,我可以使用什么样的解决方法?在

我的实际代码如下:
gql广告(“WHERE paid=True AND delivered=False AND''+cat+”',按日期ASC限制1“).get()

boards是一个列表,我想在其中找到一个与cat变量匹配的列表

这给了我一个错误:
ad_ = Ad.gql("WHERE paid = True AND delivered = False AND '" + cat + "' IN boards ORDER BY date ASC LIMIT 1").get()
File "C:\Programme\Google\google_appengine\google\appengine\ext\db\__init__.py", line 1208, in gql
*args, **kwds)
File "C:\Programme\Google\google_appengine\google\appengine\ext\db\__init__.py", line 2296, in __init__
self._proto_query = gql.GQL(query_string, _app=app, namespace=namespace)
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 195, in __init__
if not self.__Select():
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 813, in __Select
return self.__From()
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 834, in __From
return self.__Where()
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 846, in __Where
return self.__FilterList()
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 871, in __FilterList
return self.__FilterList()
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 871, in __FilterList
return self.__FilterList()
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 853, in __FilterList
self.__Error('Invalid WHERE Identifier')
File "C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py", line 738, in __Error
(error_message, self.__symbols[self.__next_symbol]))
BadQueryError: Parse Error: Invalid WHERE Identifier at symbol 'tf2'


Tags: inpyselfreturninitgooglelinewhere

热门问题