-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
We should introduce a new section specifying the scoping rules for aliases.
OK, so it's perhaps not completely necessary, since the semantics of the language are defined in terms of how operations act on result lists of labeled structure elements, but it's certainly useful, especially for anyone wanting to do any sort of static analysis of the query. (And existing implementations do work by static analysis.)
Without thinking very hard about it, I believe that the rule is nothing more than: a reference to an alias is legal at any point after the alias is declared, with the following wrinkles:
- the language allows the
selectclause to come first, instead of near the end, just beforeorder by, but this is easy to deal with, we just say that it is treated as if it occurred in its natural position, and - as @beikov has pointed out, the SQL spec has some weird scoping rules around joins, which we missed when we were writing the spec for JPQL all those years ago; rather than trying to reproduce the weird rules, I would just add a note about cases which might not work.
Metadata
Metadata
Assignees
Labels
No labels