fix(csv): less quoting in semicolon separated lists

This commit is contained in:
Gregor Kleen 2021-08-18 19:00:53 +02:00
parent fe8e4bbd4f
commit 42f1eabb2c
2 changed files with 4 additions and 2 deletions

View File

@ -140,7 +140,9 @@ instance ToField a => ToField (CsvSemicolonList a) where
fs = map toField xs
encOpts = defaultEncodeOptions
{ encDelimiter = fromIntegral $ ord ';'
, encQuoting = bool QuoteMinimal QuoteAll $ all null fs
, encQuoting = case fs of
[fStr] | null fStr -> QuoteAll
_other -> QuoteMinimal
, encUseCrLf = True
}

View File

@ -32,7 +32,7 @@ spec = modifyMaxSuccess (* 10) . parallel $ do
test ["foo", "bar"] "foo;bar"
test [] ""
test [""] "\"\""
test ["", ""] "\"\";\"\""
test ["", ""] ";"
test ["foo", ""] "foo;"
test ["", "foo"] ";foo"
test ["", "", "foo", ""] ";;foo;"