开发者

query to app engine database coming up blank

i have this issue with app engine's datastore. In interactive console, I always get no entities when i ask if a url already exists in my db. When I execute the following code....

from google.appengine.ext import db    
class shortURL(db.Model):
    url = db.TextProperty()
    date = db.DateTimeProperty(auto_now_add=True)
q = shortURL.all()
#q.filter("url =", "httphello")
print q.count()
for item in q:
    print item.url

i get the this response, which is fine

6
httphello 
www.boston.com
http://www.boston.com 
httphello
w开发者_Go百科ww.boston.com 
http://www.boston.com

But when I uncomment the line "q.filter("url =", "httphello")", i get no entities at all (a response of 0). I know its something ultra simple, but I just can't see it! help.


TextProperty values are not indexed, and cannot be used in filters or sort orders.
You might want to try with StringProperty if you don't need more than 500 characters.


I think .fetch() is missing . you can do a fetch before you do some manipulation on a model.

Also. I don't think you need db.TextProperty() for this, you can use db.StringProperty().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜