I have a user in my system who has created an entity which I'd like to retrieve. I'm attempting to do this using a filter because it's supposed to be faster than a call to the gql method. However, the filter returns no 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 any reason why the filter would return an empty list and the gql call would return the proper results?

有帮助吗?

解决方案

When using filter(), you are required to have a space between the field name and the operator. To get your filter() call to 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)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top