edgedb / edgedb

A graph-relational database with declarative schema, built-in migration system, and a next-generation query language
https://edgedb.com
Apache License 2.0
13.09k stars 402 forks source link

Document path factoring behavior #4441

Closed msullivan closed 1 year ago

msullivan commented 2 years ago

In EdgeQL, common paths are "factored" to the closest surrounding subquery.

This is what allows

select User.first_name ++ ' ' ++ User.last_name

to return one row per user, as well as causing

select (User.name, count(User))

to always report 1 as the count, as well as letting

select (User.name, count(User.friends))

return each user's number of friends.

I don't believe that this is currently documented anywhere but https://www.edgedb.com/docs/reference/edgeql/eval, which does not explain it at all, it just shows how to define it.

vpetrovykh commented 1 year ago

The PR #4959 (mentioned above) adds a section on path resolution to the docs.