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

Field set to Now() expression doesn't appear as dirty. #176

Open
LincolnPuzey opened this issue Apr 7, 2021 · 0 comments
Open

Field set to Now() expression doesn't appear as dirty. #176

LincolnPuzey opened this issue Apr 7, 2021 · 0 comments

Comments

@LincolnPuzey
Copy link
Collaborator

Originally reported by @lestatcheb in #117

Test case that currently fails:

class DatetimeModelStandard(DirtyFieldsMixin, models.Model):
    datetime_field = models.DateTimeField(blank=True, null=True)

@pytest.mark.django_db
def test_dirty_fields_field_now():
    tm = DatetimeModelStandard.objects.create()

    assert tm.get_dirty_fields() == {}

    tm.datetime_field = Now()

    assert tm.get_dirty_fields() == {'datetime_field': None}
E       AssertionError: assert {} == {'datetime_field': None}
E         Right contains 1 more item:
E         {'datetime_field': None}
E         Full diff:
E         - {'datetime_field': None}
E         + {}

I think this is a case that should pass. The Now() expression represents a value that is different to the database, so the field is dirty.

Ideally a solution should work for the different database expression objects available, not just Now().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant