Created
February 23, 2013 18:33
-
-
Save jgeewax/5020801 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Might return TJ if he's in our database. | |
Person.filter_prefix("name", "Thomas Jefferso").get() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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