From 38aadddf7b31ea3561d201b0138e773ac1a2e80c Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 14 Jun 2025 16:09:08 -1000 Subject: [PATCH] dev: Hledger.Query.matchesCommodity: check all query types, not just cur: And default to False (unlike the other match functions. Ok ?) --- hledger-lib/Hledger/Query.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Query.hs b/hledger-lib/Hledger/Query.hs index 430c97cdb..a626dcbf2 100644 --- a/hledger-lib/Hledger/Query.hs +++ b/hledger-lib/Hledger/Query.hs @@ -813,8 +813,14 @@ inAccountQuery (QueryOptInAcct a : _) = Just . Acct $ accountNameToAccountRe -- matching things with queries matchesCommodity :: Query -> CommoditySymbol -> Bool -matchesCommodity (Sym r) = regexMatchText r -matchesCommodity _ = const True +matchesCommodity (Sym r) s = regexMatchText r s +matchesCommodity (Any) _ = True +matchesCommodity (None) _ = False +matchesCommodity (Or qs) s = any (`matchesCommodity` s) qs +matchesCommodity (And qs) s = all (`matchesCommodity` s) qs +matchesCommodity (AnyPosting qs) s = all (`matchesCommodity` s) qs +matchesCommodity (AllPostings qs) s = all (`matchesCommodity` s) qs +matchesCommodity _ _ = False -- | Does the match expression match this (simple) amount ? matchesAmount :: Query -> Amount -> Bool