Skip to content

Commit

Permalink
cli: fix scientific formatting from JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
brennanjl committed Feb 18, 2025
1 parent 0d6a57e commit c932974
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmd/kwil-cli/cmds/call-action.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package cmds

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"strconv"

"github.com/kwilteam/kwil-db/app/shared/display"
"github.com/kwilteam/kwil-db/cmd/kwil-cli/client"
Expand Down Expand Up @@ -152,7 +154,20 @@ func getStringRows(v [][]any) [][]string {
for _, r := range v {
var row []string
for _, c := range r {
row = append(row, fmt.Sprintf("%v", c))
var col string
switch c2 := c.(type) {
case []byte:
col = base64.StdEncoding.EncodeToString(c2)
case float64:
col = strconv.FormatFloat(c2, 'f', -1, 64)
case bool:
col = strconv.FormatBool(c2)
case nil:
col = "null"
default:
col = fmt.Sprintf("%v", c)
}
row = append(row, col)
}
rows = append(rows, row)
}
Expand Down

0 comments on commit c932974

Please sign in to comment.