Surprisingly, after having done a lot of queries without problem. I've run into the first strange GQL problem.
Following are the properties of a model called Feedback:
content date title type votes_count written_by
and following are configured in index.yaml:
- kind: Feedback
properties:
- name: type
- name: date
direction: desc
When I queried for all Feedback data, sorted by date, it returns me all the results:
query = GqlQuery("SELECT __key__ FROM Feedback ORDER BY date DESC")
The type property is stored in type = db.IntegerProperty(default=1, required=False, indexed=True), and there are 8 rows of Feedback data with type of integer 1.
However, when I queried:
query = GqlQuery("SELECT __key__ FROM Feedback WHERE type = :1 ORDER BY date DESC", type)
It kept returning me empty results. What has gone wrong ?
Update
def get_keys_by_feedback_type(type_type):
if type_type == FeedbackCode.ALL:
query = GqlQuery("SELECT __key__ FROM Feedback ORDER BY date DESC")
else:
query = GqlQuery("SELECT __key__ FROM Feedback WHERE type = :1 ORDER BY date DESC", type_type)
return query
results = Feedback.get_keys_by_feedback_type(int(feedback_type_filter))
for feedback_key in results:
# iterate the query results
The index is serving:
Feedback
type ▲ , date ▼ Serving