GQL IN 运算符是否可用于搜索列表属性中具有项目的实体?
我的意思是,如果你有一个模型,就像这样(Python),
class MahModel(db.Model):
它有一个标签属性(例如)
tags = db.StringListProperty()
我可以在查询中做这样的事情吗? WHERE 'x' IN 标签
如果没有,我可以使用什么样的解决方法?
我的实际代码如下:
Ad.gql("WHEREpaid=TrueANDdelivered=FalseAND'"+cat+"'INboardsORDERBYdateASCLIMIT1").get()
boards是一个列表,我想在其中与猫匹配变量
这给了我这个错误:ad_ = Ad.gql("WHEREpaid = True AND Delivered = False AND '" + cat + "' IN Board ORDER BY date ASC LIMIT 1").get()
文件“C:\Programme\Google\google_appengine\google\appengine\ext\db\__init__.py”,第 1208 行,gql
*参数,**kwds)
文件“C:\Programme\Google\google_appengine\google\appengine\ext\db\__init__.py”,第 2296 行,位于 __init__
self._proto_query = gql.GQL(query_string, _app=app, 命名空间=命名空间)
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 195 行,位于 __init__
如果不是 self.__Select():
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 813 行,位于 __Select
返回 self.__From()
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 834 行,位于 __From
返回 self.__Where()
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 846 行,位于 __Where
返回 self.__FilterList()
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 871 行,位于 __FilterList
返回 self.__FilterList()
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 871 行,位于 __FilterList
返回 self.__FilterList()
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 853 行,位于 __FilterList
self.__Error('无效的 WHERE 标识符')
文件“C:\Programme\Google\google_appengine\google\appengine\ext\gql\__init__.py”,第 738 行,位于 __Error
(错误消息,self.__symbols[self.__next_symbol]))
BadQueryError:解析错误:符号“tf2”处的 WHERE 标识符无效
I mean, if you have a model, just like this (Python)
class MahModel(db.Model):
which has a tags property(for instance)
tags = db.StringListProperty()
Can I do something like this in a query? WHERE 'x' IN tags
If not, what kind of workaround could I use?
My actual code is like follows:
Ad.gql("WHERE paid = True AND delivered = False AND '" + cat + "' IN boards ORDER BY date ASC LIMIT 1").get()
boards is a list, in which I wanna get a match with the cat variable
That gives me this error: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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将返回列表中至少有一次具有“x”的任何实体。
will return any entities that have 'x' at least once in the list.