Closed BAPCon closed 2 weeks ago
I understand what you're going for here, but I would still prefer the approach of tracking changes to fields behind-the-scenes (so that callers don't need to keep track of which fields they're modifying). I can't think of any other use cases where you'd want to avoid saving field values that were changed on the model, and adding this kwarg to the API will create debt that we'll need to support indefinitely.
If you really need this behavior today, you can do something like:
update_fields = orm_obj.to_record(only_writable=True)["fields"]
update_fields = {k: v for (k, v) in update_fields.items() if k in SAVE_FIELDS}
orm_obj.meta.table.update(orm_obj.id, update_fields)
I've posted #381 as an alternate proposal to address the issue. Open to questions or comments there.
Introduces enhancements requested in #378 to the
Model.save
method, allowing specific field updates to a record rather than the entire record.ORM attribute name vs Airtable field name
I think the fields should be specified via their ORM attribute name:
first_name
,last_name
. This would maintain consistency and be more Pythonic.