Question

I'm studying the Google Cloud Datastore GQL grammar - specifically the HAS ANCESTOR and HAS DESCENDANT comparison operators.

Giving the following Person entities:

  • Amy
  • Fred, parent = Amy
  • Laura, parent = Amy
  • Paul
  • Agnes ...

Would the GQL queries below produce the same output?

SELECT * FROM Person WHERE key_name='Fred' HAS ANCESTOR KEY('Person', 'Amy')

SELECT * FROM Person WHERE KEY('Person', 'Amy') HAS DESCENDANT key_name='Fred'

If so, I don't understand the existence of HAS DESCENDANT clause.

Thanks in advance!

Was it helpful?

Solution

These two GQL queries should produce identical results:

SELECT * FROM Person WHERE __key__ HAS ANCESTOR KEY('Person', 'Amy')
SELECT * FROM Person WHERE KEY('Person', 'Amy') HAS DESCENDANT __key__
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top