Python 3.9 is now generally available.

google.appengine.datastore.datastore_stub_util.CheckQuery

Check a datastore query with normalized filters, orders.

Raises an ApplicationError when any of the following conditions are violated:

  • transactional queries have an ancestor
  • queries that are not too large (sum of filters, orders, ancestor <= max_query_components)
  • ancestor (if any) app and namespace match query app and namespace
  • kindless queries only filter on key and only sort on key ascending
  • multiple inequality (<, <=, >, >=) filters all applied to the same property
  • filters on key compare to a reference in the same app and namespace as the query
  • if an inequality filter on prop X is used, the first order (if any) must be on X

query query to validate
filters normalized (by datastore_index.Normalize) filters from query
orders normalized (by datastore_index.Normalize) orders from query
max_query_components limit on query complexity