latitude
latitude copied to clipboard
Read metadata from supported methods
Describe your changes
In the previous PR, I added a way for the compiler to read some metadata without resolving values or running queries. This approach worked for simple queries. However, it had a limitation: some functions can add crucial information to the query, which in turn affects the metadata. But if these functions aren’t called, we can’t determine their impact on the current query. For example, if a function contains a ref
function, the methods
called in the query (which is information relevant to the metadata) should also contain the methods called in the referenced metadata.
To fix this, I have reworked how supportedMethods
are defined. Now, each supportedMethod
must define two functions: resolve
and readMetadata
, where each function defines how its compiled result, and its metadata..
In addition, I have changed how the methods handle their requirements. Previously, each function checked and handled its requirements manually. Now, I’ve introduced an extra property for supportedMethods
called requirements
. This way, the compiler takes charge of managing the function’s behavior and requirements. We now have three requirements:
-
interpolationPolicy
: Whether or not the results from this function can be interpolated into the query. Possible values areallow
(default),disallow
orrequire
. -
interpolationMethod
: If the result is going to be interpolated into the query, how is it injected? Possible values areraw
orparameterized
(default). -
requireStaticArguments
: Whether or not the function must use only literal values, or if it can use other variables or logic expressions as arguments. it can be eithertrue
orfalse
(default)
The requirements for the ref
method have changed, since now we need its arguments to be static to be able to read the metadata from the referenced query, and we cannot know what's the referenced query when reading metadata if the function argument is not static.
Checklist before requesting a review
- [x] I have added thorough tests
- [ ] I have updated the documentation if necessary
- [x] I have added a human-readable description of the changes for the release notes
- [ ] I have included a recorded video capture of the feature manually tested
🚂 TRENECITO. 🚉 Previous station: #434