Skip to content

Membership drops the TimeStamped ordering its siblings keep #335

Open

Description

@codingjoe

Membership drops the ordering that every other TimeStamped model keeps. Membership.objects.latest() raises as a result.

Work reference: branch codingjoe-weekly-digest, commits 2ace45d to 6f28eac, weekly sending digest (superJoe crew, out of scope for that change).

side quest: accounts.models.Membership.Meta does not inherit TimeStamped.Meta, so Membership silently drops the modified_at/created_at ordering and get_latest_by that every sibling model keeps. [accounts/models.py]:L83

abstract.models.TimeStamped.Meta sets ordering = ("-modified_at", "-created_at") and get_latest_by = "created_at" (abstract/models.py:31-34). Membership.Meta declares only the unique constraint. The model therefore has no default ordering, while every other TimeStamped child inherits one. Membership.objects.latest() raises.

The change is one line, but it alters the ordering of any unordered membership queryset. It needs a check of its callers, not a drive-by fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCorrectnessside questOut-of-scope finding, deferred to its own issue

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions