Skip to content

ORDER BY of a set operation is ignored for some positions and for expressions over output columns #3147

Backlog

Description

@mathiasrw
alasql('CREATE TABLE A (a INT); INSERT INTO A VALUES (1),(3)');
alasql('CREATE TABLE B (a INT); INSERT INTO B VALUES (2)');
alasql('SELECT a AS k FROM A UNION SELECT a FROM B ORDER BY 1 DESC');
alasql('SELECT a + 0 FROM A UNION SELECT a + 0 FROM B ORDER BY 1 DESC');
alasql('SELECT * FROM A UNION SELECT * FROM B ORDER BY 1 DESC');
alasql('SELECT a FROM A UNION SELECT a FROM B ORDER BY a * -1');

Each gives the rows in the order 2, 1, 3, without an error.

Each should give 3, 2, 1. SQLite gives 3, 2, 1 for the first three and refuses the expression in the last.

Fixed by #2693.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions