mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Display timestamp fields with format RFC3339Nano
This commit is contained in:
parent
599205ae15
commit
c6e82bca77
1 changed files with 13 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ package cli
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
featurebase "github.com/featurebasedb/featurebase/v3"
|
||||
"github.com/jedib0t/go-pretty/table"
|
||||
|
|
@ -87,11 +88,20 @@ func writeTable(r *featurebase.WireQueryResponse, format *writeOptions, qOut io.
|
|||
t.AppendHeader(schemaToRow(r.Schema))
|
||||
}
|
||||
for _, row := range r.Data {
|
||||
// If the value is nil, replace it with a null string; go-pretty doesn't
|
||||
// expect nil pointers in the data values.
|
||||
// Loop through all the colums of each row and modify any based on
|
||||
// type.
|
||||
//
|
||||
// If the value is nil, replace it with a null string; go-pretty
|
||||
// doesn't expect nil pointers in the data values.
|
||||
//
|
||||
// If the value is a time.Time, we want to print it using
|
||||
// RFC3339Nano to be consistent with everything else.
|
||||
for i := range row {
|
||||
if row[i] == nil {
|
||||
switch v := row[i].(type) {
|
||||
case nil:
|
||||
row[i] = nullValue
|
||||
case time.Time:
|
||||
row[i] = v.Format(time.RFC3339Nano)
|
||||
}
|
||||
}
|
||||
t.AppendRow(table.Row(row))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue