What to replace open_meta()
and commodity_meta()
and similar with
#97
Labels
proposal
Request for comment on proposed changes
Working toward the goal on making beanquery a general purpose SQL-like query language for arbitrary data and make the BQL language more regular, we need to decide what to do with the current BQL function that depend on the row context, in particular the
open_meta()
,commodity_meta()
and similar functions.In an unpublished branch I already implemented structured types (or composite types in PostgreSQL parlance https://www.postgresql.org/docs/14/rowtypes.html) thus one way to solve the problem would be to make accounts and commodities their own structured types and allow a syntax similar to
Another way is to rely on sub-queries to do the lookup:
A solution based on a join
would not work because commodities is a table of all the commodities definitions, and not all the commodities used in a Beancount ledger need to defined, thus the above query would return only a subset of the postings.
The BQL syntax for the first solution is definitely more attractive but it is less flexible and would require making the BQL types system more complex to allow accounts and commodities to be at the same time strings and structured types, unless explicit type conversions are required. Something like
is not horrible but feels a bit redundant. Going the other way around:
is not much better.
The syntax for the second solution is verbose, but it is the most explicit and it allows for the most flexibility.
Comments?
The text was updated successfully, but these errors were encountered: