• 
      

    Fix comparing constructed and deserialized UniqueConstraints.

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

    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.

    Summary ID
    Fix comparing constructed and deserialized UniqueConstraints.
    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.
    32ac5c1dd5f63e3db4ac22251c217a5d17518dd8
    Description From Last Updated

    I don't think the hyphen is necessary here.

    daviddavid

    I don't think the hyphen is necessary here.

    daviddavid
    david
    1. 
        
    2. django_evolution/signature.py (Diff revision 1)
       
       
      Show all issues

      I don't think the hyphen is necessary here.

    3. django_evolution/signature.py (Diff revision 1)
       
       
      Show all issues

      I don't think the hyphen is necessary here.

    4. 
        
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-2.x (1e058de)