Using nested order by in a function context produces wrong sql

Description

So the problem is, when you have a multi-level query e.g. a query(L0) with nested subqueries and a subquery(L1) appears in the ORDER BY clause. If that subquery(L1) uses a function e.g. in it's WHERE clause, which receives another subquery(L2) and also has an ORDER BY clause, the generated SQL is wrong. The reason for that is, that the SQL generation does not handle the capturing of the generated SQL expressions properly in the case of nested ORDER BY s.

Environment

None

Status

Assignee

Christian Beikov

Reporter

Christian Beikov

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.4

Priority

Major