move-coop / parsons

A python library of connectors for the progressive community.
https://www.parsonsproject.org/
Other
257 stars 125 forks source link

Fix airtable.insert_records table arg type #906

Closed codygordon closed 9 months ago

codygordon commented 9 months ago

It seems that airtable.batch_insert was used without any conversion to a list from the table arg, and expects a raw list, but this parsons method expects a parsons table. So, either sending a table or list in would cause an error, though sending the list would actually insert the rows into Airtable but throw the error on the final table.num_rows log.

This PR allows for either to work!

Errors for reference:

Table source:

  File "/root/.pyenv/versions/letters-comments-vetting-ve/lib/python3.9/site-packages/airtable/airtable.py", line 154, in _chunk
    for i in range(0, len(iterable), chunk_size):
TypeError: object of type 'Table' has no len()

list source:

  File "/root/.pyenv/versions/letters-comments-vetting-ve/lib/python3.9/site-packages/parsons/airtable/airtable.py", line 147, in insert_records
    logger.info(f'{table.num_rows} records inserted.')
AttributeError: 'list' object has no attribute 'num_rows'