Opened 7 months ago

Closed 7 months ago

Last modified 7 months 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 Changed 7 months ago by Simon Charette

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

comment:2 Changed 7 months ago by Simon Charette

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

comment:3 Changed 7 months ago by Mariusz Felisiak

Triage Stage: AcceptedReady for checkin

comment:4 Changed 7 months ago by Mariusz Felisiak <felisiak.mariusz@…>

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 Changed 7 months ago by Mariusz Felisiak <felisiak.mariusz@…>

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 Changed 7 months ago by Johannes Maron

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 Changed 7 months ago by Mariusz Felisiak

Johannes, a set of releases will be issued tomorrow.

comment:8 Changed 7 months ago by Johannes Maron

Cc: Johannes Maron added

👍

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