Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8988,6 +8988,34 @@ <h4>Variable Scope</h4>
</tr>
</tbody>
</table>

<p>
Syntax forms `EXISTS` or `NOT EXISTS` can appear inside
<a href="#rExpression">expressions</a>.
Expressions appear in
<a href="#rFilter">`FILTER`</a>,
<a href="#rHavingClause">`HAVING`</a>,
and places where `AS` is permitted;
(<a href="#rBind">`BIND`</a>,
<a href="#rSelectClause">a select clause</a>,
and <a href="#rGroupClause">`GROUP BY`</a>).
</p>


<!-- @@ remove
<p>
Syntax forms `EXISTS` or `NOT EXISTS` appear inside
Copy link
Contributor

@kasei kasei Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems overly restrictive in suggesting that (not) exists only appears inside filters (and not other places where expressions can be used).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change enough?

"inside a FILTER and filters appear inside group graph patterns."
==>
"inside expressions <link to [127] Expression>."

Or something that enumerates the places that expressions occur, filter, AS, ORDER BY, (GROUP BY and HAVING are allow AS).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expression would be good, I think.

a `FILTER` and filters appear inside group graph patterns.
Let `F` be a syntax form `FILTER`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

F is not used anywhere after. Is it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not intentional. (See Greg's comment).

It is trying to say that scope is modified only for the leaves of the AST that can set variables - BGPs and paths.

From there, the current row variables is in-scope by the usual rules and include the current row.

I'll revise it.

appearing inside group graph pattern `GP`,
then for all
syntax forms `EXISTS {P}` or `NOT EXISTS {P}`,
any variable that is in-scope for `GP` is
also in-scope for all group graph patterns,
basic graph patterns, and paths inside `P`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"...also in-scope for all group graph patterns, basic graph patterns, and paths inside P"
Does this mean only in-scope if P is precisely a group graph pattern, basic graph pattern, or path?
Or does it allow nesting? E.g. within optional or service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nesting - any group graph pattern.

The requirement is to include the variables of the current row at the bottom then they get incorporated all the way up to P by the usual rules.

</p>
-->

<p>The variable `v` must not be in-scope at the point of the
`(expr AS v)` form. The scoping for `(expr AS v)`
applies immediately in `SELECT` expressions.
Expand Down
Loading