Documentation
¶
Index ¶
- Constants
- func DetectColumnCaseFormat(recordType reflect.Type) text.CaseFormat
- func DetectColumns(ctx context.Context, db *sql.DB, query string, args ...interface{}) ([]*sink.Column, error)
- 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 CSVEncodedValue
- type Column
- type ColumnMapper
- type ColumnOption
- type ColumnWithFields
- type Columns
- type Field
- type FieldStringifierFn
- type Fielder
- type Fields
- type JSONEncodedValue
- type LoadExecutor
- type LoadExecutorResolver
- type Matcher
- type MergeExecutor
- type MergeExecutorResolver
- type ObjectStringifier
- type ObjectStringifierFn
- type Parallel
- type PlaceholderBinder
- type QueryResult
- type RecordlessBuilder
- type Resolve
- type Resolver
- type StringifierConfig
- type StringifierFloat32Config
- type StringifierFloat64Config
- type Tag
- type Transaction
- type ValueAccessor
Constants ¶
const ( EncodingJSON = "JSON" EncodingCSV = "CSV" TagSqlx = "sqlx" )
Variables ¶
This section is empty.
Functions ¶
func DetectColumnCaseFormat ¶ added in v0.9.1
func DetectColumnCaseFormat(recordType reflect.Type) text.CaseFormat
func DetectColumns ¶ added in v0.17.0
func DetectColumns(ctx context.Context, db *sql.DB, query string, args ...interface{}) ([]*sink.Column, error)
DetectColumns detects columns for the supplied SQL.
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 CSVEncodedValue ¶ added in v0.26.0
type CSVEncodedValue struct {
Val any
// contains filtered or unexported fields
}
CSVEncodedValue bridges one CSV SQL value and a typed Go scalar slice.
func (*CSVEncodedValue) MarshalJSON ¶ added in v0.26.0
func (c *CSVEncodedValue) MarshalJSON() ([]byte, error)
Cache serialization retains the original source, never decoded slice data.
func (*CSVEncodedValue) Scan ¶ added in v0.26.0
func (c *CSVEncodedValue) Scan(raw any) error
func (*CSVEncodedValue) UnmarshalJSON ¶ added in v0.26.0
func (c *CSVEncodedValue) UnmarshalJSON(data []byte) error
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
// contains filtered or unexported fields
}
Field represents column mapped field
func (Field) FieldIndex ¶ added in v0.26.0
FieldIndex returns the mapped Go field's complete holder index. The returned slice is detached; unresolved SQL columns have no model field path.
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 LoadExecutor ¶ added in v0.14.0
type LoadExecutor interface {
Exec(context context.Context, data interface{}, db *sql.DB, tableName string, options ...loption.Option) (sql.Result, error)
}
LoadExecutor represents load executor interface
type LoadExecutorResolver ¶ added in v0.14.0
type LoadExecutorResolver = func(dialect *info.Dialect) LoadExecutor
LoadExecutorResolver returns new LoadExecutor configured with given Dialect
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 MergeExecutor ¶ added in v0.14.0
type MergeExecutor interface {
Exec(context context.Context, data interface{}, db *sql.DB, tableName string, options ...moption.Option) (info.MergeResult, error)
}
MergeExecutor represents merge executor interface
type MergeExecutorResolver ¶ added in v0.14.0
type MergeExecutorResolver = func(dialect *info.Dialect, config info.MergeConfig) (MergeExecutor, error)
MergeExecutorResolver returns a MergeExecutor configured with given Dialect and MergeConfig
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 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
UniqueDep string
Db string // authored SQL qualifier; SQL identifier quotes are retained
Table string // authored SQL table identifier; quotes are retained
RefDb string // authored SQL reference qualifier; not a connector lookup name
RefTable string // authored SQL reference table identifier; quotes are retained
RefColumn string
Required bool
OmitEmpty bool
NullifyEmpty bool
ErrorMgs string
PresenceProvider bool
Bit bool
Encoding string
CaseFormat text.CaseFormat
DataType string
Raw string
}
Tag represent field tag
func (*Tag) HasDefaultGenerator ¶ added in v0.26.0
HasDefaultGenerator reports whether this field activates native database default generation. Identity allocation is a separate producer.
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
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package schema owns non-destructive table provisioning through SQLX metadata.
|
Package schema owns non-destructive table provisioning through SQLX metadata. |