csv: interpolated field names in values are now case insensitive

Field names are supposed to be case insensitive, but a field assignment like

fields  ...,Transaction_Date,...
date %Transaction_Date

was failing, because of the capitalised letters. Fixed now.
This commit is contained in:
Simon Michael 2018-07-22 18:42:00 +01:00
parent 7266064557
commit fe73f2a6b5

View File

@ -800,10 +800,10 @@ getEffectiveAssignment rules record f = lastMay $ assignmentsFor f
renderTemplate :: CsvRules -> CsvRecord -> FieldTemplate -> String
renderTemplate rules record t = regexReplaceBy "%[A-z0-9]+" replace t
where
replace ('%':pat) = maybe pat (\i -> atDef "" record (i-1)) mi
replace ('%':pat) = maybe pat (\i -> atDef "" record (i-1)) mindex
where
mi | all isDigit pat = readMay pat
| otherwise = lookup pat $ rcsvfieldindexes rules
mindex | all isDigit pat = readMay pat
| otherwise = lookup (map toLower pat) $ rcsvfieldindexes rules
replace pat = pat
-- Parse the date string using the specified date-format, or if unspecified try these default formats: