-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
update_redcap_record compares and old record object with a new one, attempting to update any fields that have changed, and then passing the updated object to the vbr_client.update_row for updating the database:
python-vbr/src/vbr/api/redcap.py
Lines 48 to 57 in 6641b13
| def update_redcap_record( | |
| self, redcap_form_name: str, redcap_record: RcapTable, rcap_row: RcapTable | |
| ) -> RcapTable: | |
| """Update RedCap row based on RedCap API response""" | |
| for k,v in redcap_record.dict().items(): | |
| old_value = rcap_row.dict().get(k,None) | |
| if old_value is not None and old_value != v: | |
| setattr(rcap_row,k,v) | |
| rcap_row = self.vbr_client.update_row(rcap_row) | |
| return rcap_row |
But the comparison of old vs new values prevents updating when the old values were None (e.g., can't fill a previously NULL value)
if old_value is not None and old_value != v:I think this should be something like
if (
(old_value is None and v is not None)
or (old_value is not None and v is None)
or (old_value != v)
):Metadata
Metadata
Assignees
Labels
No labels