Documentation
¶
Index ¶
- func EnsureDereference(value interface{}) reflect.Type
- func Int64Ptr(values []interface{}, index int) (*int64, error)
- func IsMatchedError(err error) bool
- func Iterator(any interface{}) (func() interface{}, int, error)
- func MergeErrorIfNeeded(fn func() error, err *error)
- func NormalizeKey(key interface{}) interface{}
- func StructColumnMapper(src interface{}, tagName string, options ...option.Option) ([]Column, PlaceholderBinder, error)
- func UpdateUnresolved(field *Field, resolver Resolve) error
- type Builder
- type BuilderAdapter
- type Column
- type ColumnDecimalPrecision
- type ColumnDecimalScale
- type ColumnLength
- type ColumnMapper
- type ColumnNullable
- type Columns
- type Field
- type FieldStringifierFn
- type Fields
- type Matcher
- type ObjectStringifier
- type ObjectStringifierFn
- type Parallel
- type PlaceholderBinder
- type QueryResult
- type RecordlessBuilder
- type Resolve
- type Resolver
- type Session
- type SessionResolver
- type StringifierConfig
- type Tag
- type Transaction
- type ValueAccessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDereference ¶
EnsureDereference returns Type of value dereferenced e.g. if any is type of *Foo, it will return Foo
func IsMatchedError ¶
IsMatchedError returns whether err is matchError
func Iterator ¶
Iterator creates an iterator for any data structure, it returns next function, len, or error
func MergeErrorIfNeeded ¶
MergeErrorIfNeeded sets err as error from passed function used i.e. with deffer
func NormalizeKey ¶
func NormalizeKey(key interface{}) interface{}
NormalizeKey converts non nil numeric value to int or return nil
func StructColumnMapper ¶
func StructColumnMapper(src interface{}, tagName string, options ...option.Option) ([]Column, PlaceholderBinder, error)
StructColumnMapper returns genertic column mapper
func UpdateUnresolved ¶
Types ¶
type Builder ¶
Builder represents SQL builder
func NewBuilderAdapter ¶ added in v0.4.0
func NewBuilderAdapter(builder RecordlessBuilder) Builder
type BuilderAdapter ¶ added in v0.4.0
type BuilderAdapter struct {
// contains filtered or unexported fields
}
Builder represents SQL builder
type Column ¶
type Column interface {
Name() string
Length() (length int64, ok bool)
DecimalSize() (precision, scale int64, ok bool)
ScanType() reflect.Type
Nullable() (nullable, ok bool)
DatabaseTypeName() string
Tag() *Tag
}
Column represents a column
func NamesToColumns ¶
NamesToColumns converts []string to []sqlx.column
func StructColumns ¶
func StructColumns(recordType reflect.Type, tagName string, opts ...option.Option) ([]Column, error)
StructColumns returns column for the struct
func TypesToColumns ¶
func TypesToColumns(columns []*sql.ColumnType) []Column
TypesToColumns converts []*sql.ColumnType type to []sqlx.column
type ColumnDecimalPrecision ¶
type ColumnDecimalPrecision int64
ColumnDecimalPrecision represents column decimal precision
type ColumnDecimalScale ¶
type ColumnDecimalScale int64
ColumnDecimalScale represents column decimal scale
type ColumnMapper ¶
type ColumnMapper func(src interface{}, tagName string, options ...option.Option) ([]Column, PlaceholderBinder, error)
ColumnMapper maps src to columns and its placeholders
type Columns ¶
type Columns []Column
Columns represents columns
func (Columns) Autoincrement ¶
Autoincrement returns position of autoincrement column position or -1
func (Columns) IdentityColumnPos ¶
IdentityColumnPos returns identity column position in []Column
func (Columns) PrimaryKeys ¶
PrimaryKeys returns position of primary key position or -1
type Field ¶
type Field struct {
Tag
Column
*xunsafe.Field
EvalAddr func(pointer unsafe.Pointer) interface{}
Info *sink.Column
MatchesType bool
}
Field represents column mapped field
type FieldStringifierFn ¶
func Stringifier ¶
func Stringifier(field *xunsafe.Field, nullifyZeroValue bool, nullValue string) FieldStringifierFn
type Fields ¶
type Fields []Field
Fields represents slice of Field
func (Fields) ColumnNames ¶
ColumnNames returns slice of column names for given Fields
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher implements column to struct filed mapper
func NewMatcher ¶
NewMatcher creates a fields to column matcher
type ObjectStringifier ¶
type ObjectStringifier struct {
// contains filtered or unexported fields
}
func TypeStringifier ¶
func TypeStringifier(rType reflect.Type, nullValue string, omitTransient bool, options ...interface{}) *ObjectStringifier
TypeStringifier returns ObjectStringifier for a given Type. It will replace nil values with nullValue for properties with tag: "nullifyEmpty" and omit (if specified) transient properties By default, results are shared, no new arrays are returned unless Parallel(true) is provided as an option.
func (*ObjectStringifier) FieldNames ¶
func (s *ObjectStringifier) FieldNames() []string
func (*ObjectStringifier) Has ¶
func (s *ObjectStringifier) Has(fieldName string) bool
func (*ObjectStringifier) Stringifier ¶
func (s *ObjectStringifier) Stringifier(options ...interface{}) (ObjectStringifierFn, error)
type ObjectStringifierFn ¶
ObjectStringifierFn returns stringified object properties values and information if value was string before
type PlaceholderBinder ¶
type PlaceholderBinder func(src interface{}, params []interface{}, offset, limit int)
PlaceholderBinder copies source values to params starting with offset
type QueryResult ¶
QueryResult summarizes an executed SQL command. use instead of standard Result when you need omit bug: "0 affected rows"
func (*QueryResult) RowsAffected ¶
func (r *QueryResult) RowsAffected() (int64, error)
RowsAffected returns count of affected rows
type RecordlessBuilder ¶ added in v0.4.0
Builder represents SQL builder
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver represents unmatched column resolver
type Session ¶
type Session interface {
Exec(context context.Context, data interface{}, db *sql.DB, tableName string, options ...option.Option) (sql.Result, error)
}
Session represents load session e.g. MySQL "LOAD DATA LOCAL INFILE"
type SessionResolver ¶
SessionResolver returns new Session configured with given Dialect
type StringifierConfig ¶
type Tag ¶
type Tag struct {
Column string
Autoincrement bool
PrimaryKey bool
Sequence string
FieldIndex int
Transient bool
Ns string
Generator string
IsUnique bool
Db string
Table string
RefDb string
RefTable string
RefColumn string
Required bool
NullifyEmpty bool
ErrorMgs string
PresenceProvider bool
Bit bool
}
Tag represent field tag
type Transaction ¶
func TransactionFor ¶
func (*Transaction) Commit ¶
func (t *Transaction) Commit() error
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback() error
func (*Transaction) RollbackWithErr ¶
func (t *Transaction) RollbackWithErr(err error) error
type ValueAccessor ¶
type ValueAccessor = func(index int) interface{}
ValueAccessor represents function that returns value at given index.
func Values ¶
func Values(any interface{}) (ValueAccessor, int, error)
Values return function to access value at position