gtalarico / pyairtable

Python Api Client for Airtable
https://pyairtable.readthedocs.io
MIT License
786 stars 139 forks source link

get_table_schema fails when the api.table is initialized with the table's ID #314

Closed calebclimatecabinet closed 7 months ago

calebclimatecabinet commented 1 year ago

For example

get_table_schema(api.table(base_id, "tblXXXXXXXXXXXXXX"))

returns None but the function works if you use the table's name:

get_table_schema(api.table(base_id, "My Table"))
mesozoic commented 1 year ago

Good catch. I can see that function is comparing to name but not to id.

311 introduces a new set of APIs for retrieving metadata, so I'm generally not inclined to do much maintenance on the existing code (which will be deprecated). But this should be easy enough to fix. Pull requests welcome 😁 otherwise I'll get to this the next chance I have.

calebclimatecabinet commented 1 year ago

Ah no worries – if it'll be depreciated I'm fine letting it slide.

If anyone else comes across this I just wrote my own get_table_schema which only works in the opposite case:

def get_table_schema(table):
    base_schema = get_base_schema(table)
    return next(t for t in base_schema["tables"] if t["id"] == table.name)