Skip to content

Smarter sorting that doesn't keep nesting the sorts #135

@simonw

Description

@simonw

Currently if you click "sort ascending" and then "sort descending" in the cog menu you get SQL something like this:

select * from (
  select * from (
    select id, slug, link_url, link_title, via_url, via_title, commentary, created, metadata, search_document, import_ref, card_image from blog_blogmark
  ) as results order by "link_title"
) as results order by "link_url" desc

Each sort wraps the previous sorted query in another nested query.

We can do better than this! Sorting really complex queries with with (...) in them and suchlike is hard, but we can at least notice if the query we are re-sorting ends with order by X already and replace that clause rather than wrapping the whole thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions