Documentation
¶
Overview ¶
Package result formats query values for display and export.
Formatting lives apart from the UI so the grid, CSV export and JSON export all agree on what a value looks like — and so the rules can be tested without a terminal.
Index ¶
- Constants
- func EscapeTags(s string) string
- func Format(v any) string
- func Truncate(s string, limit int) string
- type Buffer
- func (b *Buffer) Append(rows [][]any) int
- func (b *Buffer) AtCapacity() bool
- func (b *Buffer) Cell(row, col int) string
- func (b *Buffer) ColumnCount() int
- func (b *Buffer) ColumnName(col int) string
- func (b *Buffer) Columns() []string
- func (b *Buffer) Raw(row, col int) any
- func (b *Buffer) Reset()
- func (b *Buffer) Row(row int) []any
- func (b *Buffer) RowCount() int
- func (b *Buffer) SetColumns(columns []string, types []*sql.ColumnType)
Constants ¶
const CellLimit = 200
CellLimit caps how many runes a grid cell shows. Long values stay in the buffer intact; only the rendering is shortened.
const NullText = "NULL"
NullText is how a SQL NULL is shown. It has to be visually distinct from an empty string: treating the two alike misleads people into thinking a row failed an IS NULL test for no reason.
const TimeLayout = "2006-01-02 15:04:05"
TimeLayout is the timestamp rendering, chosen to match MySQL's own.
Variables ¶
This section is empty.
Functions ¶
func EscapeTags ¶
EscapeTags neutralises tview's colour-tag syntax.
tview reads "[" as the start of a tag, so a cell containing "[red]" would recolour the grid instead of showing its own text. tview's documented escape is to write "[" as "[[".
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer holds the rows of one result set.
It is written by the streaming goroutine and read by the UI goroutine, so every accessor takes the lock. Reads outside the current bounds return zero values rather than panicking: tview asks for cells while rendering, and a result that was just cleared would otherwise crash the application.
func (*Buffer) AtCapacity ¶
AtCapacity reports whether the buffer has stopped accepting rows.
func (*Buffer) ColumnCount ¶
ColumnCount is the number of columns in the result.
func (*Buffer) ColumnName ¶
ColumnName returns the name of a column, or "" if it is out of range.
func (*Buffer) RowCount ¶
RowCount is the number of rows received so far. While a stream is running it grows, which is what lets the grid scroll through partial results.
func (*Buffer) SetColumns ¶
func (b *Buffer) SetColumns(columns []string, types []*sql.ColumnType)
SetColumns replaces the result header and drops any existing rows.