views:

260

answers:

2

I'm playing with GAE, and need to make a query with something like this:

select from models.Post as p where (p.votesUp + p.votesDown > 10)

But I get this error: App Engine datastore does not support operator +

Which could be a good approach to replace that query?

+4  A: 

The obvious thing that leaps out at me is to put a method on p that has a p.netVotes and query on that.

But I'm not familiar enough with App Engine (I just started looking at it) to be sure that that works.

Yishai
Thanks Yishai. That's the best solution I think :)
Damian
+1  A: 

This sounds similar to the issue with counters in app engine. The simplest solution off the top of my head is to add a votesTotal attribute that is updated every time votesUp and votesDown is updated. Thus there's no large computation when you query for votesTotal > foo_val.

fuentesjr