Damian
Damian

Reputation: 5561

Google App Engine datastore does not support operator +

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?

Upvotes: 1

Views: 572

Answers (2)

fuentesjr
fuentesjr

Reputation: 52318

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.

Upvotes: 1

Yishai
Yishai

Reputation: 91871

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.

Upvotes: 4

Related Questions