gtalarico / pyairtable

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

Rewrite of pyairtable.formulas #329

Closed mesozoic closed 7 months ago

mesozoic commented 9 months ago

This is a breaking change to the pyairtable.formulas module, so it would have to be released as 3.0, but it introduces a more thorough way for library users to construct formulas and chain them together.

This module allows for complex nested expressions that are built up through chaining; for example:

>>> formula = match({"Customer": "Alice"})
>>> formula
EQ(Field('Customer'), 'Alice')
>>> complex = formula & Field('Delivery Date').gte(TODAY())
>>> complex
AND(EQ(Field('Customer'), 'Alice'), GTE(Field('Delivery Date'), TODAY()))
>>> str(complex)
"AND({Customer}='Alice', {Delivery Date}>=TODAY())"

The way all of the functions are exposed is a bit janky, and relies on code generation running against a text file that must be refreshed whenever Airtable releases new functions. I'll look to incorporate the approach laid out in #328 for reading those from the formula playground instead.

A summary of changes:

Resolves #304 Resolves #305 Resolves #324 Resolves #328

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.95%. Comparing base (b676bf0) to head (be844ec).

:exclamation: Current head be844ec differs from pull request most recent head 2744c67. Consider uploading reports for the commit 2744c67 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #329 +/- ## ========================================== + Coverage 99.60% 99.95% +0.35% ========================================== Files 25 25 Lines 2025 2307 +282 ========================================== + Hits 2017 2306 +289 + Misses 8 1 -7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.