开发者

How to debug GQL queries in GAE?

开发者 https://www.devze.com 2023-02-11 11:31 出处:网络
I have some custom user model, and I count the number of users with name Joe: c = UserModel.all().filter(\'n开发者_开发问答ame =\', \'Joe\').count()

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

精彩评论

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