From 2fa7656627d8d21eb5a8305f5044fb6a35169510 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Dec 2022 14:26:35 -0400 Subject: [PATCH] switch to readMaybe to handle values with leading number followed by non-number readish ignores a trailing string after a number, but to support values like "YYYY:MM:DD" which it makes sense to compare lexographically, require the whole string to be parsed as a number in order to enable numeric comparison. Sponsored-by: Max Thoursie on Patreon --- Annex/MetaData.hs | 3 ++- ...comment_3_9c298fbda8d395fe9b8395105708c3bd._comment | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 doc/todo/--metadata_fieldname__62____61__VALUE_string_comparison/comment_3_9c298fbda8d395fe9b8395105708c3bd._comment diff --git a/Annex/MetaData.hs b/Annex/MetaData.hs index 2263e3e0c6..8379a6df8d 100644 --- a/Annex/MetaData.hs +++ b/Annex/MetaData.hs @@ -26,6 +26,7 @@ import qualified Data.Text as T import Data.Time.Calendar import Data.Time.Clock import Data.Time.Clock.POSIX +import Text.Read {- Adds metadata for a file that has just been ingested into the - annex, but has not yet been committed to git. @@ -117,4 +118,4 @@ parseMetaDataMatcher p = (,) in case (doubleval v, doubleval v') of (Just d, Just d') -> d' `cmp` d _ -> v' `cmp'` v - doubleval v = readish v :: Maybe Double + doubleval v = readMaybe v :: Maybe Double diff --git a/doc/todo/--metadata_fieldname__62____61__VALUE_string_comparison/comment_3_9c298fbda8d395fe9b8395105708c3bd._comment b/doc/todo/--metadata_fieldname__62____61__VALUE_string_comparison/comment_3_9c298fbda8d395fe9b8395105708c3bd._comment new file mode 100644 index 0000000000..d27c4641b5 --- /dev/null +++ b/doc/todo/--metadata_fieldname__62____61__VALUE_string_comparison/comment_3_9c298fbda8d395fe9b8395105708c3bd._comment @@ -0,0 +1,10 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 3""" + date="2022-12-22T18:30:46Z" + content=""" +Thanks for double-checking. I have not tried your test but I think I see +what is going on from the pattern. Strings starting with a number but then +subsequently not a number were still being parsed to numbers and compared +numerically. I've fixed that now. +"""]]