Commit 4e4c9a63 authored by Pontus Melke's avatar Pontus Melke
Browse files

Fix bug with scoping with * followed by aggregation and order by

Queries with `WITH *, count(a) AS c ORDER BY c RETURN c` was failing with `no variable c in scope`.
parent c13e7715
Showing with 1 addition and 1 deletion
+1 -1
......@@ -669,7 +669,7 @@ sealed trait ProjectionClause extends HorizonClause {
// can see both variables from before the WITH and variables introduced by the WITH
// (SKIP and LIMIT clauses are not allowed to access variables anyway, so they do not need to be included in this condition even when they are standalone)
val specialScopeForSubClausesNeeded = orderBy.isDefined || where.isDefined
val canSeePreviousScope = !(returnItems.containsAggregate | distinct)
val canSeePreviousScope = (!(returnItems.containsAggregate || distinct)) || returnItems.includeExisting
if (specialScopeForSubClausesNeeded && canSeePreviousScope) {
/*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment