App Engine filter versus gql methods

I have a user on my system who created an object that I would like to receive. I am trying to do this using filter , because it should be faster than calling the gql method . However, the filter does not return any results and gql works.

randy_res = Vote.all().filter('created_by=', randy).fetch(limit=10)
randy_res = Vote.gql('WHERE created_by=:1', randy)

Is there a reason the filter will return an empty list and calling gql will return the correct results?

+5
source share
1 answer

When used filter(), you should have a space between the field name and the operator. For your call to filter()work as intended, you just need to insert a space before the equal sign:

randy_res = Vote.all().filter('created_by =', randy).fetch(limit=10)
+12

All Articles