pyairtable icon indicating copy to clipboard operation
pyairtable copied to clipboard

Flagging computed fields in ORM

Open larsakerson opened this issue 3 years ago • 2 comments
trafficstars

Add flag for computed fields in orm.fields.Field and use this attribute to resolve error on record updates in orm.model.Model.save()

larsakerson avatar Sep 09 '22 01:09 larsakerson

Thanks for the quick turn around.

This looks good to me. Just need a few more things to make it ready to ship:

  • Can you add a unit test in the orm test suite?
  • maybe a note in the orm docs?

gtalarico avatar Sep 09 '22 02:09 gtalarico

Wouldnt it make sense to rename this parameter to something else? I was thinking about this, as I need to download images via airtable: https://github.com/gtalarico/pyairtable/issues/179

Now if we want to add this image implementation, I think it could be tricky to get it right to support download and upload. I think for the first run a download-only option would make sense, and then this PR comes into play:

In this case the image fields are not computed, but we rather want to treat it read-only. So maybe a more generic name would be read_only in this case?

NicoHood avatar Sep 10 '22 09:09 NicoHood

Your suggestion makes sense to me, @NicoHood. I've updated the parameter name to read_only.

@gtalarico I'm not very familiar with pytest 😬 but I added a test and updated the test suite for this feature and they pass. Might be worth another set of eyes on the code, though.

larsakerson avatar Sep 27 '22 15:09 larsakerson

Sorry for the delay here @larsakerson will review this and incorporate it

gtalarico avatar Oct 26 '22 14:10 gtalarico

My apologies. I've incorporated the suggestions; let me know if anything else is needed here, @gtalarico

larsakerson avatar Feb 28 '23 01:02 larsakerson