Improve diff detection for customerID when dealing with CORE API
sometimes it returns int, sometimes str..
This commit is contained in:
parent
3cef682a75
commit
46eec6b781
|
@ -176,9 +176,16 @@ class MemberImporter(ToCoreAPI):
|
|||
if not local_customer:
|
||||
return True
|
||||
|
||||
# we differ if old and new records differ
|
||||
if data_diffs(local_customer, host_customer,
|
||||
fields=self.supported_customer_fields):
|
||||
# we differ if old and new records differ, but...
|
||||
diffs = data_diffs(local_customer, host_customer,
|
||||
fields=self.supported_customer_fields)
|
||||
|
||||
# nb. the customerID field is sometimes int, sometimes str
|
||||
# (?) so we must coerce both sides to str for proper
|
||||
# comparison, otherwise false diffs happen
|
||||
if diffs and (
|
||||
diffs != ['customerID']
|
||||
or str(local_customer['customerID']) != str(host_customer['customerID'])):
|
||||
return True
|
||||
|
||||
# okay, now let's traverse the "old" list
|
||||
|
@ -199,14 +206,14 @@ class MemberImporter(ToCoreAPI):
|
|||
return # new customer
|
||||
|
||||
for local_customer in local_customers:
|
||||
if local_customer['customerID'] == host_customer['customerID']:
|
||||
if str(local_customer['customerID']) == str(host_customer['customerID']):
|
||||
return local_customer
|
||||
|
||||
def find_host_customer(self, host_customers, local_customer):
|
||||
assert 'customerID' in self.supported_customer_fields
|
||||
|
||||
for host_customer in host_customers:
|
||||
if host_customer['customerID'] == local_customer['customerID']:
|
||||
if str(host_customer['customerID']) == str(local_customer['customerID']):
|
||||
return host_customer
|
||||
|
||||
def create_object(self, key, data):
|
||||
|
|
Loading…
Reference in a new issue