mirror of
https://github.com/minio/minio.git
synced 2025-11-28 21:18:10 -05:00
sql: Add support of escape quote in CSV (#9231)
This commit modifies csv parser, a fork of golang csv parser to support a custom quote escape character. The quote escape character is used to escape the quote character when a csv field contains a quote character as part of data.
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
"github.com/klauspost/compress/zstd"
|
||||
"github.com/minio/minio/pkg/s3select/json"
|
||||
"github.com/minio/minio/pkg/s3select/sql"
|
||||
"github.com/minio/simdjson-go"
|
||||
)
|
||||
|
||||
@@ -131,11 +132,17 @@ func TestNDJSON(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
var gotB, wantB bytes.Buffer
|
||||
err = rec.WriteCSV(&gotB, ',', '"', false)
|
||||
opts := sql.WriteCSVOpts{
|
||||
FieldDelimiter: ',',
|
||||
Quote: '"',
|
||||
QuoteEscape: '"',
|
||||
AlwaysQuote: false,
|
||||
}
|
||||
err = rec.WriteCSV(&gotB, opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
err = want.WriteCSV(&wantB, ',', '"', false)
|
||||
err = want.WriteCSV(&wantB, opts)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user