-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fixes for whether existing Identifier objects are preserved or not #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from some naming pedantry and a request for an extra test this looks good.
@@ -573,14 +577,22 @@ def create_identifier(self, popit_collection, popit_id, django_object): | |||
identifier=popit_id, | |||
) | |||
|
|||
def preserve_related(self, django_main_model, related_object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preserve_related
sounds like an action, I think something more like should_preserve_related
makes it a little clearer what this is doing.
) | ||
existing_person.identifiers.create( | ||
scheme='preserve-me', | ||
identifier="data-that-should-be-kept" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem like a helpful name here given the test output.
person.identifiers.order_by('scheme').values_list('scheme', 'identifier'), | ||
[(u'popolo:person', u'a1b2')] | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there should be a near identical test with identifiers set to [] to show that they do the same thing?
We're refactoring this in order to make it easier subsequently to allow users of this class to specify additional Identifier schemes to preserve.
If 'identifiers' was missing from a person, the old Identifier objects associated with a Person would all be preserved, but if instead identifiers was [] it would remove all Identifier objects associated with that Person except for the one that preserved the Django ID for them. This change makes the behaviour consistent between those two very similar cases - unknown identifiers are removed when syncing from the source. (This is what happens for contact details, etc. as well.)
ad332c1
to
b9f3c1d
Compare
Thanks, @struan, I've made the changes you suggested. |
This pull request addresses two problems:
it was empty had confusingly different behaviour. This makes the 'missing'
case consistent with the empty array and existing handling of other related
objects.
identifiers that should be preserved; this pull request adds that facility.