Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support customizing generated ordering e.g. to sort nulls last #82

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

stevelacey
Copy link
Contributor

@stevelacey stevelacey commented Dec 13, 2021

Support sorting nulls last via overriding get_sort_field, not my favorite syntax, but any approach involving view configuration seem to require we either make assumptions or add another view configuration attribute.

    def get_sort_field(self, name, descending=False):
        if name == "my_field" and descending:
            return F(name).desc(nulls_last=True)
        return super().get_sort_field(name, descending=descending)

Where should the reviewer start?

List APIs.

Why is this important, or what issue does this solve?

Sorting nulls last via the sort query param is not really possible without this.

This is a modification of #73.

Tasks

  • This PR increases test coverage
  • I didn't add anything to the docs because I hate it

@stevelacey stevelacey changed the title Support sorting nulls last Support customizing generated ordering e.g. to sort nulls last Dec 15, 2021
@stevelacey stevelacey merged commit cdc9dc3 into master Dec 15, 2021
@stevelacey stevelacey deleted the improvement/sort-nulls-last branch December 15, 2021 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant