Reputation: 1681
I have a model like this:
class Users(db.Model):
email = db.EmailProperty(required=True, indexed=True)
user_name = db.StringProperty(required=True, indexed=True)
api_key = db.StringProperty(required=False, indexed=False)
active = db.BooleanProperty(required=True, indexed=False)
real_name = db.StringProperty(required=False, indexed=False)
...etc
When I tried to make a query like this:
user = db.GqlQuery("SELECT email, api_key, active FROM Users WHERE user_name = :1", username).get()
It's returning None, but when I use this query:
user = db.GqlQuery("SELECT * FROM Users WHERE user_name = :1", username).get()
It's ok, returns everything. But why I can't use the first query?
Upvotes: 3
Views: 811
Reputation: 8189
You cannot project unindexed properties. As stated in the documentation
There are some limitations on what properties can be projected: You can only project indexed properties. This means that projecting Text, Blob or other properties explicitly marked as unindexed is not supported.
You can find out what indexes are required by running your query in the Datastore Viewer in the Admin Console.
Upvotes: 7