Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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:
formula=
kwargs now accept eitherstr
or an instance ofFormula
Formula
class has subclassesComparison
andFunctionCall
match()
function signature remains the same, though it returns aFormula
class instead ofstr
to_airtable_value()
is removed, and replaced with a similar (but not same)to_formula_str()
field_name()
replaces theFIELD()
functionEQ
,NE
,GT
,GTE
,LT
,LTE
replace equivalent functions (EQUAL()
, etc.)AND()
andOR()
now returnComparison
(a subclass ofFormula
) instead ofstr
FunctionCall
(a subclass ofFormula
).eq()
, etc. convenience methods for producing formulas.Resolves #304
Resolves #305
Resolves #324
Resolves #328