-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
More powerful expr: queries ? #2095
Comments
|
I am interested in querying transactions consisting of postings that are tagged with certain key=value pairs exclusively. The
If I want to query specifically ious in transactions involving bob and steve, I can simply filter the journal because -- in this case -- multiple tag queries seem to implicitly AND.
However, I am struggling to query what bob owes me without consideration to steve. That is, I can't figure out how to filter for transactions exclusively matching the I have to filter with |
Hi, here are two options -
Use eg register or balance, which match individual postings rather than transactions, so are more precise.
Or use different accounts for steve and bob. A:receivable:steve and :bob would be more correct.
|
Thank you for your quick response, Simon. The bookkeeping in this example could certainly be better, I use it here as one case where querying for related postings might be useful. Using e.g. bob and I are usually lenient with each-other, but when I pay steve I want to be sure bob pays his share. For this senario, my suggested However, when I want to see bob's iou balance for when bob and steve and nobody other than bob and steve are involved in the transactions, I have had to filter the journal with an unwieldy number of not: prefixes. Good news! While writing this response I found my answer. I forgot that queries interpret regular expressions. So, to see bob and only bob simply write
This doesn't necessarily scale effortlessly, but it's certainly better than selective exclusion. I still wonder if some shorthand query syntax could be added as a convenience for this sort of thing.
EDIT: This would be specific to commands that return whole transactions. perhaps an |
upon further reflection, I think the existing query syntax is completely sufficient. There's more power in explicitly written regexps e.g. Also, expanding the query interface adds more opportunities to mess up a report. I'd be happy to contribute an example like this to the documentation if you consider it appropriate. |
Hi @pmiam .. I see, you're looking for a way to "match whole transactions which contain only the specified values for this tag and no others". Your regexps above seem to be to be using character classes, not quite correctly - and yet they're working here too in my quick tests, and just now I don't understand why. Negative lookahead would (might ?) help with this, but hledger's regexps don't support them at present. (After playing around with it, I agree this is quite a hard query to achieve otherwise.) |
We added the more expressive "expr:" queries recently, but they don't give as much extra power as you'd think; eg they don't let us select whole transactions by the amount posted to a particular account (real world example). Eg it would be nice to be able to
print
whole transactions which post between $100 and $200 to assets:foo.The text was updated successfully, but these errors were encountered: