Documentation ¶
Index ¶
- func ColumnGoTypeDef(ct *sql.ColumnType) (reflect.Type, error)
- func WithBatchSize(n int) insertOptFunc
- func WithDDLSync(ddlSync DDLSync) insertOptFunc
- func WithNullables(nullables ...string) insertOptFunc
- func WithTypeOverride(fn func(t ColDef) string) insertOptFunc
- type ColDef
- type DB
- type DDLSync
- type Dialect
- type Iter
- type Q
- type Row
- type SQLExec
- type SQLQuery
- type TableDef
- func (d TableDef) Get(colName string) (ColDef, bool)
- func (d TableDef) IndexOf(k string) int
- func (d TableDef) Len() int
- func (d TableDef) MissingOn(d2 TableDef) TableDef
- func (d TableDef) NormalizeRows(rows []Row) []Row
- func (d TableDef) RowValues(rows []Row) []any
- func (d TableDef) StrJoin(sep string) string
- func (d TableDef) String() string
- func (d TableDef) WithColumns(col ...ColDef) TableDef
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColumnGoTypeDef ¶
func ColumnGoTypeDef(ct *sql.ColumnType) (reflect.Type, error)
func WithBatchSize ¶
func WithBatchSize(n int) insertOptFunc
WithBatchSize sets the number of rows to insert in a single batch. might still execute multiple inserts.
func WithDDLSync ¶
func WithDDLSync(ddlSync DDLSync) insertOptFunc
WithDDLSync sets the DDL sync mode.
func WithNullables ¶
func WithNullables(nullables ...string) insertOptFunc
WithNullables sets the columns that can be null.
func WithTypeOverride ¶
WithTypeOverride uses the sql type returned by the func for col if the func returns an empty string, the default type is used.
Types ¶
type ColDef ¶
type ColDef struct { Name string // Type reflect.Type // RAW? ScanType Type Type Nullable bool Length int64 // for varchar and maybe other types Scale int // Precision int ... // Overrides for sql types SQLType string // override }
ColDef represets a column in a table
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
type Dialect ¶
type Dialect interface { ColumnGoType(ct *sql.ColumnType) (reflect.Type, error) TableDef(ctx context.Context, db SQLQuery, schema, name string) (TableDef, error) CreateTable(ctx context.Context, db SQLExec, schema, name string, table TableDef) error AddColumns(ctx context.Context, db SQLExec, schema, name string, table TableDef) error Insert(ctx context.Context, db SQLExec, schema, name string, table TableDef, rows []Row) error }
type TableDef ¶
type TableDef struct {
Columns []ColDef
}
TableDef represents an sql table definition.
func DefFromRows ¶
DefFromRows scans a slice of rows and returns a TableDef with the columns.
func DefFromSQLTypes ¶
func DefFromSQLTypes(typs []*sql.ColumnType, solverOpt ...sqlTypeSolver) (TableDef, error)
func NewTableDef ¶
func (TableDef) NormalizeRows ¶
NormalizeRows returns a slice of rows based on definition d.
func (TableDef) RowValues ¶
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 (TableDef) WithColumns ¶
type Type ¶
type Type int
const ( TypeUnknown Type = iota TypeSmallInt // int8 TypeUnsignedSmallInt // uint8 TypeInteger // int32 TypeUnsignedInteger // uint32 TypeBigInt // int64 TypeUnsignedBigInt // uint64 TypeDecimal // apd.Decimal TypeReal // float32 TypeDouble // float64 TypeVarchar // string TypeTimestamp // time.Time TypeBoolean // bool )