Can not reproduce this error on local devserver (1.5.0) but when we deploy code to google, it starts popping up? Is it a bug in the current online version of GAE?
Here is the problem. If we first do this:
proj = Project(created_by=users.User(email='test@sample.com'))
proj.put()
user = users.get_current_user()
print user.email() #this prints test@sample.com (actual email not used)
This fetches 0 results:
projs = Project.all().filter('created_by', user).fetch(500)
But this fetches the result that should actually be fetched:
projs = GqlQuery("SELECT * FROM Project where created_by = USER('%s')"%user.email()).fetch(500)
Any idea whats going on here?
As i could see you are creating a user object and persisting that into created_by.
i.e
here you are creating a users.User object with email ‘test@sample.com’. You are persisting the same into Projects’ created_by. Where as you are comparing that with
users.get_current_user()which gets the current logged in user object.That’s why it’s not fetching any object. Whereas in gql you are again creating a User object with the passed email which obviously will match the persisted user object in project.i would say you should do something like this