Skip to content

Instantly share code, notes, and snippets.

@jgeewax
Created February 23, 2013 18:33
Show Gist options
  • Save jgeewax/5020801 to your computer and use it in GitHub Desktop.
Save jgeewax/5020801 to your computer and use it in GitHub Desktop.
class BaseModel(db.Expando):
@classmethod
def filter_prefix(cls, property_name, prefix):
query = cls.all()
query.filter("%s >= " % property_name, u"%s" % prefix)
query.filter("%s < " % property_name, u"%s\xEF\xBF\xBD" % prefix)
return query
# Might return TJ if he's in our database.
Person.filter_prefix("name", "Thomas Jefferso").get()
db.GqlQuery("SELECT * FROM MyModel WHERE prop >= :1 AND prop < :2", "abc", u"abc" + u"\xEF\xBF\xBD")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment