dialect

package
v0.0.4-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColumnGoType

func ColumnGoType(ct *sql.ColumnType) (reflect.Type, error)

func EqualFold

func EqualFold(s string) func(row Row) *drow.Field

equalFold returns a func used in drow.Row.At to fetch a insesitive case field

Types

type Col

type Col struct {
	Name string
	Type reflect.Type
	// Overrides for sql types
	SQLType string
	SQLDef  string
	Scale   int
}

Col represets a column in a table

func (Col) Eq

func (c Col) Eq(c2 Col) bool

Eq compares two columns by name and type.

func (Col) Zero

func (c Col) Zero() any

Zero returns the zero value for the column type.

type Row

type Row = drow.Row

type Table

type Table struct {
	Columns []Col
}

Table represents an sql table definition.

func DefFromRows

func DefFromRows(rows []Row) Table

DefFromRows scans a slice of rows and returns a TableDef with the columns.

func (Table) Get

func (d Table) Get(colName string) Col

Get returns the column with the given name or an empty col if non existent.

func (Table) IndexOf

func (d Table) IndexOf(k string) int

func (Table) Len

func (d Table) Len() int

Len returns the number of columns in the table.

func (Table) MissingOn

func (d Table) MissingOn(d2 Table) Table

MissingOn returns a TableDef with missing columns from d2

func (Table) NormalizeRows

func (d Table) NormalizeRows(rows []Row) []Row

NormalizeRows returns a slice of rows based on definition d.

func (Table) RowValues

func (d Table) RowValues(rows []Row) []any

RowValues returns a slice of values from the given rows. |row1|row2|row3| => |row1[0]|row1[1]|row2[0]|row2[1]|row3[0]|row3[1]|

func (Table) StrJoin

func (d Table) StrJoin(sep string) string

StrJoin returns a string with all column names joined by sep.

func (Table) String

func (d Table) String() string

func (Table) WithColumns

func (d Table) WithColumns(col ...Col) Table

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL