1

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!

Gaurav Toshniwal
  • 3,552
  • 2
  • 24
  • 23

1 Answers1

3

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.

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46
  • KK i understood that , but why the error **Expected no additional symbols at symbol <=** ? any error with that part?? – Gaurav Toshniwal May 22 '11 at 05:28
  • Ok, so `("SELECT __key__ FROM Trips WHERE start_time <= :start_time_input <= end_time" , start_time_input = start_time_input , end_time_input = end_time_input )` query also gives me **BadQueryError: Parse Error: Expected no additional symbols at symbol <=** – Gaurav Toshniwal May 22 '11 at 06:34
  • @Gaurav `a < b < c` is not a valid expression in GQL. GQL syntax is documented at the pages you linked to. – Nick Johnson May 22 '11 at 18:54
  • @nick hmm read that.....Basiclly read that as a method of comparison for python.... Now how do I simulate the condition, as I can use inequality only for one field in an appengine – Gaurav Toshniwal May 23 '11 at 13:32
  • @Gaurav b >= a AND b < c is equivalent. – Nick Johnson May 28 '11 at 23:04