2011-08-04 17 views
0

我的意思是,如果你有一個模型,就像這樣(Python)的可能使用GQL IN操作符來搜索列表中包含項目的實體?

class MahModel(db.Model): 

具有標籤屬性(例如)

tags = db.StringListProperty() 

我可以做這樣的事情在查詢? WHERE 'x' IN tags

如果不是,我可以使用什麼樣的解決方法?

我的實際代碼如下所示:
Ad.gql( 「WHERE支付=真並且交付=虛假和「」 +貓+「'板卡ORDER BY日期ASC LIMIT 1" )獲得()

板是一個列表,在其中我想獲得與貓變

這給了我這個錯誤匹配:
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'

+0

當你嘗試它時會發生什麼? – SingleNegationElimination

+0

給我一個奇怪的錯誤...讓我碰它:BadQueryError:解析錯誤:無效WHERE標識符在符號'x' – Souseiseki

+0

請通過編輯您的問題添加關於您的問題的新信息。 – SingleNegationElimination

回答

1
WHERE tags = 'x' 

將返回任何實體「 x'至少在列表中有一次。

+0

哇,真的嗎?這比我預期的O.O要容易得多,謝謝 – Souseiseki

相關問題