Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32714 closed Bug (fixed)

Model meta ordering with nulls_last resulting in constantly needing new migrations

Reported by: Kevin Marsh Owned by: Simon Charette
Component: Migrations Version: 3.2
Severity: Release blocker Keywords:
Cc: Johannes Maron Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Just upgraded from Django 3.2. to 3.2.1 and now makemigrations always shows the same change. The issue seems to be if you have:

class SampleModel(models.Model):

    name = models.CharField(null=True, max_length=255)

    class Meta:
        ordering = [F('name').asc(nulls_last=True)]

Running makemigrations always results in the ordering changing for SampleModel, think maybe this was introduced when trying to solve #32632 since for:

a = F('name').asc(nulls_last=True)
b = F('name').asc(nulls_last=True)

In Django 3.2 a == b but in Django 3.2.1 a != b

Change History (8)

comment:1 by Simon Charette, 4 years ago

Owner: changed from nobody to Simon Charette
Severity: NormalRelease blocker
Status: newassigned

comment:2 by Simon Charette, 4 years ago

Has patch: set
Triage Stage: UnreviewedAccepted
Last edited 4 years ago by Mariusz Felisiak (previous) (diff)

comment:3 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 96f55ccf:

Fixed #32714 -- Prevented recreation of migration for Meta.ordering with OrderBy expressions.

Regression in c8b659430556dca0b2fe27cf2ea0f8290dbafecd.

Thanks Kevin Marsh for the report.

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 364098fd:

[3.2.x] Fixed #32714 -- Prevented recreation of migration for Meta.ordering with OrderBy expressions.

Regression in c8b659430556dca0b2fe27cf2ea0f8290dbafecd.

Thanks Kevin Marsh for the report.

Backport of 96f55ccf798c7592a1203f798a4dffaf173a9263 from main

comment:6 by Johannes Maron, 4 years ago

Mariusz, any chance to speed up release. I'm having trouble to apply the patch for CVE-2021-31542 without this change. And seeing that the patch for CVE-2021-31542 is rather large, I don't really want to backport it.

comment:7 by Mariusz Felisiak, 4 years ago

Johannes, a set of releases will be issued tomorrow.

comment:8 by Johannes Maron, 4 years ago

Cc: Johannes Maron added

👍

Note: See TracTickets for help on using tickets.
Back to Top