开发者

How to debug GQL queries in GAE?

I have some custom user model, and I count the number of users with name Joe:

c = UserModel.all().filter('n开发者_开发问答ame =', 'Joe').count()

Even though I know there is a Joe in the datastore, there is some mistake witch makes c == 0.

This is a problem I'm dealing with, however the biggest problem is that I don't know how to debug this.

I would like to get some query and visualise it somehow, so that I can understand what is there and why Joe is not there:

v = magically_visualise_contents_of(UserModel.all().filter('name =','Joe'))

handler.response.out.write(v)


Try running the query directly in the datastore viewer by GQL.
That usually helps identify minor issues, for example:

 SELECT * FROM UserModel WHERE name = 'Joe'

Also, one common mistake with string matching is whitespace characters in the data, like "Joe ".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜