问题
Not this question: Ancestor query parse error
I structured it with "IS" properly:
SELECT DISTINCT batch_no FROM Entry WHERE ANCESTOR IS KEY('ag1kZXZ-dHRiLXRhbWVychkLEgdCcmV3ZXJ5IgxCUi1USEVSRURQRUEM')
But still I got the error:
Why is that?
回答1:
In this case, DISTINCT was causing the problem. Remove it and this Query functions no prob.
I think it is somehow implicitly projecting, you cannot access the key, only that property you DISTINCT on; even if you use "*"
Though I think it's fair to say the error message was not obvious on this point.
Google says this in db.Query documentation:
This will only return the first result for entities which have the same values for the properties that are being projected.
And in the GQL documentation
that only completely unique results will be returned in a result set. This will only return the first result for entities which have the same values for the properties that are being projected.
Please moderate this self-answered question if it's duplicative or facile. Thanks.
来源:https://stackoverflow.com/questions/25225368/ancestor-query-parse-error-using-distinct