Chad
Chad

Reputation: 13

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
www.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.

Upvotes: 1

Views: 128

Answers (2)

systempuntoout
systempuntoout

Reputation: 74054

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.

Upvotes: 1

Abdul Kader
Abdul Kader

Reputation: 5842

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().

Upvotes: 0

Related Questions