Documentation ¶
Index ¶
- Constants
- func DetectColumnCaseFormat(recordType reflect.Type) text.CaseFormat
- func EnsureDereference(value interface{}) reflect.Type
- func ExtractColumnNames(recordType reflect.Type) []string
- func Int64Ptr(values []interface{}, index int) (*int64, error)
- func Int64ValuePtr(value interface{}) (*int64, error)
- func IsIdentityColumn(col Column) bool
- func IsMatchedError(err error) bool
- func IsStruct(t reflect.Type) bool
- func Iterator(any interface{}) (func() interface{}, int, error)
- func NormalizeColumnType(scanType reflect.Type, name string) reflect.Type
- func NormalizeKey(key interface{}) interface{}
- func ParseType(columnType string) (reflect.Type, bool)
- func RunWithError(fn func() error, err *error)
- func StructColumnMapper(src interface{}, options ...option.Option) ([]Column, PlaceholderBinder, error)
- func UpdateUnresolved(field *Field, resolver Resolve) error
- type Builder
- type BuilderAdapter
- type Column
- type ColumnMapper
- type ColumnOption
- type ColumnWithFields
- type Columns
- type Field
- type FieldStringifierFn
- type Fielder
- type Fields
- type JSONEncodedValue
- 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 StringifierFloat32Config
- type StringifierFloat64Config
- type Tag
- type Transaction
- type ValueAccessor
Constants ¶
const ( EncodingJSON = "JSON" TagSqlx = "sqlx" )
Variables ¶
This section is empty.
Functions ¶
func DetectColumnCaseFormat ¶ added in v0.9.1
func DetectColumnCaseFormat(recordType reflect.Type) text.CaseFormat
func EnsureDereference ¶
EnsureDereference returns Type of value dereferenced e.g. if any is type of *Foo, it will return Foo
func ExtractColumnNames ¶ added in v0.9.1
ExtractColumnNames extract sqlx tag colum names
func Int64ValuePtr ¶ added in v0.7.0
func IsIdentityColumn ¶ added in v0.7.0
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 NormalizeColumnType ¶ added in v0.5.2
func NormalizeKey ¶
func NormalizeKey(key interface{}) interface{}
NormalizeKey converts non nil numeric value to int or return nil
func RunWithError ¶ added in v0.8.0
RunWithError sets err as error from passed function used i.e. with deffer
func StructColumnMapper ¶
func StructColumnMapper(src interface{}, 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 NewColumn ¶
func NewColumn(name, databaseTypeName string, rType reflect.Type, opts ...ColumnOption) Column
NewColumn creates a column
func StructColumns ¶
StructColumns returns column for the struct
func TypesToColumns ¶
func TypesToColumns(columns []*sql.ColumnType) []Column
TypesToColumns converts []*sql.ColumnType type to []sqlx.column
type ColumnMapper ¶
type ColumnMapper func(src interface{}, options ...option.Option) ([]Column, PlaceholderBinder, error)
ColumnMapper maps src to columns and its placeholders
type ColumnOption ¶ added in v0.9.1
type ColumnOption func(o *column)
func WithColumnDecimalPrecision ¶ added in v0.9.1
func WithColumnDecimalPrecision(l int64) ColumnOption
WithColumnDecimalPrecision returns column decimal precision set option
func WithColumnDecimalScale ¶ added in v0.9.1
func WithColumnDecimalScale(l int64) ColumnOption
WithColumnDecimalScale returns column decimal scale set option
func WithColumnLength ¶ added in v0.9.1
func WithColumnLength(l int64) ColumnOption
WithColumnLength returns column length set option
func WithColumnNullable ¶ added in v0.9.1
func WithColumnNullable(l bool) ColumnOption
WithColumnNullable returns column nullable set option
func WithCustomOption ¶ added in v0.9.1
func WithCustomOption(opts ...interface{}) ColumnOption
WithCustomOption returns column tag option
type ColumnWithFields ¶ added in v0.7.0
func NewColumnWithFields ¶ added in v0.7.0
func NewColumnWithFields(name string, databaseTypeName string, rType reflect.Type, fields []*xunsafe.Field, opts ...ColumnOption) ColumnWithFields
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, options ...interface{}) FieldStringifierFn
type Fields ¶
type Fields []Field
Fields represents slice of Field
func (Fields) ColumnNames ¶
ExtractColumnNames returns slice of column names for given Fields
type JSONEncodedValue ¶ added in v0.7.0
type JSONEncodedValue struct {
Val interface{}
}
func (*JSONEncodedValue) Scan ¶ added in v0.7.0
func (j *JSONEncodedValue) Scan(v interface{}) error
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 StringifierConfig struct { Fields []string CaseFormat format.Case StringifierFloat32Config StringifierFloat32Config StringifierFloat64Config StringifierFloat64Config }
StringifierConfig represents stringifier config
type StringifierFloat32Config ¶ added in v0.5.4
type StringifierFloat32Config struct {
Precision string
}
StringifierFloat32Config represents stringifier float32 config
type StringifierFloat64Config ¶ added in v0.5.4
type StringifierFloat64Config struct {
Precision string
}
StringifierFloat64Config represents stringifier float64 config
type Tag ¶
type Tag struct { Column string Autoincrement bool PrimaryKey bool Sequence string 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 Encoding string CaseFormat text.CaseFormat DataType string Raw string }
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