Vladimir Keleshev
Vladimir Keleshev

Reputation: 14245

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('name =', '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)

Upvotes: 1

Views: 283

Answers (1)

Nick Gotch
Nick Gotch

Reputation: 9407

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 ".

Upvotes: 1

Related Questions