Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempts to fix update_change_reason for nullable JSONField fields (issue #1181) #1282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Dec 2, 2023

  1. Attempts to fix update_change_reason for nullable JSONField fields

    As reported in issue jazzband#1181, the implementation of the utility `update_change_reason()`
    method does not work for models with a nullable JSONField. This is caused by the
    slightly more convoluted querying mechanisms that have to be applied for JSONFields,
    please cf. here:
    [django dev documentation](https://docs.djangoproject.com/en/dev/topics/db/queries/#querying-jsonfield)
    
    This attempts to fix this by assuming that
    - a nullable JSONField with a `value` of `None` is not set at all
    - a non-nullable JSONField with a `value` of `None` is actually a
        "NULL" dictionary
    
    I am aware that this is not the only way to handle this. But it is the convention I am
    using in my project and this fixed the issue for me. It may be worthwhile to implement a
    policy switch to decide how to interpret `None` in this specific case.
    martinschwinzerl committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    9b6ec01 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7ea2597 View commit details
    Browse the repository at this point in the history