This rewriter makes sure that all return items in a RETURN clauses are aliased, and moves any ORDER BY to a preceding WITH clause
This rewriter normalizes the scoping structure of a query, ensuring it is able to be correctly processed for semantic checking.
This rewriter normalizes the scoping structure of a query, ensuring it is able to be correctly processed for semantic checking. It makes sure that all return items in a WITH clauses are aliased.
It also replaces expressions and subexpressions in ORDER BY and WHERE to use aliases introduced by the WITH, where possible.
This rewriter depends on normalizeReturnClauses having first been run.
Example:
MATCH n WITH n.prop AS prop ORDER BY n.prop DESC RETURN prop
This rewrite will change the query to:
MATCH n WITH n.prop AS prop ORDER BY prop DESC RETURN prop
This rewriter makes sure that all return items in a RETURN clauses are aliased, and moves any ORDER BY to a preceding WITH clause
Example:
MATCH (n) RETURN n.foo AS foo, n.bar ORDER BY foo
This rewrite will change the query to:
MATCH (n) WITH n.foo AS
FRESHIDxx, n.bar ASFRESHIDnnORDER BYFRESHIDxxRETURNFRESHIDxxAS foo,FRESHIDnnASn.bar