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

Throw an error in FieldTracker when using untracked field with .previous #324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

furious-luke
Copy link

Problem

Previously if previous was called on a field tracker and the field was not being tracked it would return None. Having consistent behavior between previous and has_changed would seem to make sense, but there may be a reason why this is not so?

Solution

I've moved the FieldError exception into previous from has_changed; has_changed calles previous so the exception will still be used from has_changed.

Commandments

  • Write PEP8 compliant code.
  • Cover it with tests.
  • Update CHANGES.rst file to describe the changes, and quote according issue with GH-<issue_number>.
  • Pay attention to backward compatibility, or if it breaks it, explain why.
  • Update documentation (if relevant).

I can add a test for this if you think it's worth merging?

@furious-luke furious-luke changed the title Throw an error when using missing field in previous Throw an error in FieldTracker when using missing field in .previous Apr 30, 2018
@furious-luke furious-luke changed the title Throw an error in FieldTracker when using missing field in .previous Throw an error in FieldTracker when using untracked field with .previous Apr 30, 2018
@lucaswiman
Copy link
Contributor

@furious-luke The test failures look related to these changes.

@@ -66,14 +66,14 @@ def current(self, fields=None):

def has_changed(self, field):
"""Returns ``True`` if field has changed from currently saved value"""
if field in self.fields:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@furious-luke shall we keep the if in both methods? Can you add a test for your change?

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

Successfully merging this pull request may close these issues.

3 participants