Reputation: 249
I'm running a GQLQuery to lookup if a user entered the correct credentials:
class User(db.Model):
UserName = db.TextProperty();
Password = db.TextProperty();
Ticket = db.TextProperty();
class Authentication(webapp.RequestHandler):
def post(self):
str_user = self.request.get('user')
str_password = self.request.get('password')
user = db.GqlQuery("SELECT * FROM User WHERE UserName = :1 AND Password = :2",str_user, str_password)
self.response.out.write(str_user)
self.response.out.write(str_password)
self.response.out.write(str([u.UserName for u in user]))
if user.count() > 0:
ticket = str(uuid.uuid4())
user.Ticket = ticket
self.response.out.write(ticket)
else:
self.response.out.write('Not authorized!')
The query always return an empty result set (with the "WHERE"-clause) although I'm sure that I've passed the correct parameters.
I've tried to concat my own query string but the result remains the same. If I remove the "WHERE"-clause i get all the users of the db, so I guess the db-connection is okay.
Upvotes: 1
Views: 244
Reputation: 14497
This is probably because you use TextProperty
on your fields. TextProperty
is for multi-line texts and is not indexed. You can't lookup for non-indexed values in query. You should use StringProperty
for single-line text values.
Upvotes: 3