Fix comparing constructed and deserialized UniqueConstraints.

Review Request #14528 — Created July 29, 2025 and submitted — Latest diff uploaded

Information

Django Evolution
release-2.x

Reviewers

When constructing a UniqueConstraint, several attributes (fields,
include, expressions) get converted from a list to a tuple.

When deserializing a UniqueConstraint from JSON, those attributes come
in as a list.

The resulting ConstraintSignature takes on the types used from either
the constructed or deserialized object. Due to these type differences,
this means two constraints never compare to the same value, even if they
have the same content.

To address this, we now normalize the attributes to convert any tuples
to lists for the signature representation, allowing them to compare
equally.

Unit tests pass with all versions of Django.

Tested that this fixed an upgrade condition I dealt with locally
during development.

Commits

Files