Google AppEngine complex WHERE condition

I want to have a condition something like

  • start_time <= start_time_input <= end_time
  • OR
  • start_time <= end_time_input <= end_time
  • OR
  • (start_time_input <= start_time AND end_time <= end_time_input )

The 2 ways as identified in the docs ( http://code.google.com/appengine/docs/python/datastore/queries.html and http://code.google.com/appengine/docs/python/datastore/gqlqueryclass.html)as I understood are :

filter_trips = db.GqlQuery("SELECT key FROM Trips WHERE ( start_time <= :start_time_input AND end_time >= :start_time_input ) OR (start_time <= :end_time_input AND end_time >=:end_time_input ) OR ( start_time >= :start_time_input AND end_time <= :end_time_input )" , start_time_input = start_time_input , end_time_input = end_time_input )

error: Parse Error: Invalid WHERE Identifier at symbol (

OR

filter_trips = db.GqlQuery("SELECT key FROM Trips WHERE start_time <= :start_time_input <= end_time OR start_time <= :end_time_input <= end_time OR (:start_time_input <= start_time AND end_time <= :end_time_input )" , start_time_input = start_time_input , end_time_input = end_time_input )

error: Parse Error: Expected no additional symbols at symbol <=

Please help!

pythongoogle-app-enginewhere-clausegqlgqlquery

Answers

answered 7 years ago Dave W. Smith #1

GQL doesn't have an OR. See http://code.google.com/appengine/docs/python/datastore/gqlreference.html

You'll need to do this as multiple queries.

comments powered by Disqus