• 
      

    Update DataGrid.load_extra_state to return lists of modified fields.

    Review Request #12315 — Created May 31, 2022 and submitted

    Information

    Djblets
    release-3.x

    Reviewers

    DataGrid.load_extra_state() allows a subclass to load state from a
    profile into the grid, or to store data into the profile. If the
    subclass makes use of profile objects, and has modifications to make, it
    has historically returned a boolean value, which indicates whether the
    object should be saved.

    This save operation runs the risk of overriding fields set elsewhere,
    since it's an all-or-nothing. That can have many side-effects.

    To avoid this, load_extra_state() is now expected to return a list of
    fields that were modified on the provided profile. This can be an empty
    list (equivalent of False before). DataGrid will take the list and
    pass it to save(update_fields=...), minimizing the changes written to
    the database.

    The old boolean support still exists for now, but will be removed in
    Djblets 4.0.

    Unit tests pass.

    Made use of this in the equivalent change for Review Board.

    Summary ID
    Update DataGrid.load_extra_state to return lists of modified fields.
    `DataGrid.load_extra_state()` allows a subclass to load state from a profile into the grid, or to store data into the profile. If the subclass makes use of profile objects, and has modifications to make, it has historically returned a boolean value, which indicates whether the object should be saved. This save operation runs the risk of overriding fields set elsewhere, since it's an all-or-nothing. That can have many side-effects. To avoid this, `load_extra_state()` is now expected to return a list of fields that were modified on the provided profile. This can be an empty list (equivalent of `False` before). `DataGrid` will take the list and pass it to `save(update_fields=...)`, minimizing the changes written to the database. The old boolean support still exists for now, but will be removed in Djblets 4.0.
    2b027743f5d67641f7f1df1a75d7af17a0a5d408
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.x (a162c7b)