Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "beancount" result set renderer #188

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dnicolodi
Copy link
Collaborator

I'm opening this PR mostly to record some thoughts. What it is implemented here is the bare minimum that would be required to make the PRINT statement a special case of SELECT with format set to beancount. This works:

.set format beancount
SELECT entry FROM #postings WHERE date > 2024-01-01

and prints all transactions in the beancount syntax. Actually, all transactions are printed one for every posting they contain. This could be solved with a DISTINCT clause, but entries are not hashable, thus

SELECT DISTINCT entry FROM #postings WHERE date > 2024-01-01

results in an error. This should probably be solved. Entries can be easily make hashable assuming that they are immutable.

However, when selecting for an account, this already does what is expected when filtering for an account:

.set format beancount
SELECT entry FROM #posting WHERE date > 2024-01-01 AND account = 'Assets:Foo'

and may already be useful to solve what @tbm was asking for in #123.

It is more tricky to make this work for tables that do not have a beancount entry type column. The best I can come up with is to use the ROW() construct. For example:

.set format beancount
SELECT ROW(*) FROM #entries WHERE date > 2024-01-01

@dnicolodi dnicolodi marked this pull request as draft June 16, 2024 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant