dialect

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 9 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 // RAW? ScanType
	Nullable bool
	Length   int64 // for varchar and maybe other types
	Scale    int   // Precision int ...
	// Overrides for sql types
	SQLType string // override
}

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, error)

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

func DefFromSQLTypes

func DefFromSQLTypes(typs []*sql.ColumnType) (Table, error)

func FromIterRows

func FromIterRows(it etl.Iter) (Table, error)

func (Table) Get

func (d Table) Get(colName string) (Col, bool)

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