@@ -37,10 +37,12 @@ func (e *csvExporter) Export(rows pgx.Rows, csvPath string, options ExportOption
3737 defer writer .Flush ()
3838
3939 // Write headers
40+
41+ fields := rows .FieldDescriptions ()
42+
4043 if ! options .NoHeader {
41- fieldDescriptions := rows .FieldDescriptions ()
42- headers := make ([]string , len (fieldDescriptions ))
43- for i , fd := range fieldDescriptions {
44+ headers := make ([]string , len (fields ))
45+ for i , fd := range fields {
4446 headers [i ] = string (fd .Name )
4547 }
4648
@@ -50,9 +52,6 @@ func (e *csvExporter) Export(rows pgx.Rows, csvPath string, options ExportOption
5052 logger .Debug ("CSV headers written: %s" , strings .Join (headers , string (options .Delimiter )))
5153 }
5254
53- //datetime layout(Golang format) and timezone
54- layout , loc := userTimeZoneFormat (options .TimeFormat , options .TimeZone )
55-
5655 // Write data rows
5756 logger .Debug ("Starting to write CSV rows..." )
5857
@@ -76,7 +75,7 @@ func (e *csvExporter) Export(rows pgx.Rows, csvPath string, options ExportOption
7675 //format values to strings
7776 record := make ([]string , len (values ))
7877 for i , v := range values {
79- record [i ] = formatCSVValue (v , layout , loc )
78+ record [i ] = formatCSVValue (v , fields [ i ]. DataTypeOID , options . TimeFormat , options . TimeZone )
8079 }
8180
8281 rowCount ++
0 commit comments