-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
Pad directive fails to add metadata to postings. Causes beanquery any_meta() to assert in queries. #767
Comments
These functions need to handle the meta field to be None because transactions inserted by Beancount for pad directives have postings which the meta field set to None instead than to an empty dictionary. See beancount/beancount#767.
These functions need to handle the meta field to be None because transactions inserted by Beancount for pad directives have postings which the meta field set to None instead than to an empty dictionary. See beancount/beancount#767.
I've just pushed a fix for beanquery to handle this gracefully. However, this is a bug in Beancount: the |
Also, in passing, I would like to point out that the The postings table gained a new The postings table also gained a Combining these two, |
- Add test case for None Meta on pads. - Fix the missing metadata in pad postings.
- Add test case for None Meta on pads. - Fix the missing metadata in pad postings.
- Add test case for None Meta on pads. - Fix the missing metadata in pad postings.
- Add test case for None Meta on pads. - Fix the missing metadata in pad postings.
Ensure there is (empty) metadata on postings when generating pad transaction #767
Description
TL;DR:
bean-query
(standalone) throws an uncaught TypeError if you useany_meta()
in the query and have apad
directive in the ledger.This is an interesting bug because while I thought the problem was with the latest
beanquery
while chasing it I think the root cause was a lack of metadata on the postings created by thePad
directive within beancount v2 (lines 139 and 144).One could argue that (if there is no invariant for metadata on a posting) this is only a bug in the new
beanquery
code. In which case simply mark this wont_fix and I'll pursue the fix in beanquery's repo.Repro
I've created a repro test case in my fork of
beanquery
that fails when run against thev2
release of beancount.This same test passes when run against my fork of
beancount
where I add metadata to the `Postings' for the transaction generated by the Pad directive. I chose to copy the directive's metadata but equally it could be set to being empty (vs None).Environment
test.bc
.Input File
Command to Run
Discussion
I see a few options for resolving this and would like the maintainer's opinion on which is more acceptable (there are likely other options).
AnyMeta
to deal with the metadata beingNone
- likely by adding TypeError to the 'safe' exceptions.I have a test case and fix for case 1 but it might be more general a problem if there are other places in beancount where we create postings without metadata. I also have a test case for 2 (haven't implemented the trivial fix yet).
The test case and fix for 2 is also quite simple but would be done in
beanquery
notbeancount
's repository.The text was updated successfully, but these errors were encountered: