I recently had to update one of my model’s properties from type StringProperty to TextProperty in order to overcome the restrictive limit (a maximum of 500 characters). That wasn’t a problem till I realized some of my old queries like:
SomeEntity.gql(‘WHERE property1 != :1’,None)
where property1 is a property in the model couldn’t work :-(.
The query previously worked, and it did help me to only fetch those entities that had a value set for property1.
How can I efficiently obtain the same results in this scenario where the type is TextProperty?
You cannot filter or order on a TextProperty. To achieve what you want to do, add a new BooleanProperty ‘has_text’ and filter on that. Then you just have to be sure to set the BooleanProperty whenever you change the TextProperty.
This solution follows Google App Engine’s general convention of pre-computing everything that you want to filter on.