Documentation ¶
Index ¶
- Variables
- func IsContainErrorDuplicateViolateUniqueConstraint(err error) bool
- func IsContainErrorNoRowsInResultSet(err error) bool
- func IsContainErrorTsquerySyntax(err error) bool
- func IsErrorDuplicateViolateUniqueConstraint(err error) bool
- func IsErrorNoRowsInResultSet(err error) bool
- func IsErrorTsquerySyntax(err error) bool
- func NamedExecContext(ctx context.Context, tx dbtypes.Named, query string, arg interface{}) (result sql.Result, err error)
- func NamedExecStrictContext(ctx context.Context, tx dbtypes.Named, query string, arg interface{}) (result sql.Result, err error)
- func NamedGetContext(ctx context.Context, tx dbtypes.Named, dest interface{}, query string, ...) (err error)
- func NamedSelectContext(ctx context.Context, tx dbtypes.Named, dest interface{}, query string, ...) (err error)
- func NamedSelectInContext(ctx context.Context, tx dbtypes.Transactionx, dest interface{}, query string, ...) (err error)
- func NamedSelectInStrictContext(ctx context.Context, tx dbtypes.Transactionx, dest interface{}, query string, ...) (err error)
- func NamedSelectStrictContext(ctx context.Context, tx dbtypes.Named, dest interface{}, query string, ...) (err error)
- func ParseTsQuery(ctx context.Context, tx *sqlx.DB, query string) (result string, err error)
- func SQLScanEnumString(obj interface{}, value interface{}, stringMapEnum map[string]interface{}) (err error)
- func SQLScanJSON(obj interface{}, value interface{}) (err error)
- func SQLScanStrictJSON(obj interface{}, value interface{}) (err error)
- func SQLScanString(obj interface{}, value interface{}) (err error)
- func SQLScanStringSlice(obj interface{}, value interface{}) (err error)
- func SQLValueJSON(obj interface{}) (value driver.Value, err error)
- func SQLValueStringSlice(obj interface{}) (value driver.Value, err error)
- type SQLJsonMap
- type SQLNullTime
- type SQLStringSlice
- type SQLStringSliceJSON
- type SQLUUID
Constants ¶
This section is empty.
Variables ¶
var ( ErrorNoRowsInResultSet = errutil.NewFactory("no rows in result set") ErrorDuplicateViolateUniqueConstraint = errutil.NewFactory("duplicate key value violates unique constraint") ErrorTsquerySyntax = errutil.NewFactory("syntax error in tsquery") )
errors
var ( ErrorPrepareNamed = errutil.NewFactory("prepare SQL named query failed") ErrorNoRowAffected = errutil.NewFactory("no row affected") )
errors
var ( ErrorUnsupportedScanType1 = errutil.NewFactory("unsupported scan type: %T") ErrorInvalidObjType1 = errutil.NewFactory("invalid obj type: %T") ErrorNoValueFound1 = errutil.NewFactory("no value found for key %v") )
errors
Functions ¶
func IsContainErrorDuplicateViolateUniqueConstraint ¶
IsContainErrorDuplicateViolateUniqueConstraint check err contain sql error "duplicate key value violates unique constraint"
func IsContainErrorNoRowsInResultSet ¶
IsContainErrorNoRowsInResultSet check err contain sql error "no rows in result set"
func IsContainErrorTsquerySyntax ¶
IsContainErrorTsquerySyntax check error contain sql error "syntax error in tsquery"
func IsErrorDuplicateViolateUniqueConstraint ¶
IsErrorDuplicateViolateUniqueConstraint check err is sql error "duplicate key value violates unique constraint"
func IsErrorNoRowsInResultSet ¶
IsErrorNoRowsInResultSet check err is sql error "no rows in result set" or "no row affected"
func IsErrorTsquerySyntax ¶
IsErrorTsquerySyntax check error is sql error "syntax error in tsquery"
func NamedExecContext ¶
func NamedExecContext( ctx context.Context, tx dbtypes.Named, query string, arg interface{}, ) (result sql.Result, err error)
NamedExecContext prepare named SQL statement and call Exec function with context
func NamedExecStrictContext ¶
func NamedExecStrictContext( ctx context.Context, tx dbtypes.Named, query string, arg interface{}, ) (result sql.Result, err error)
NamedExecStrictContext like NamedExecContext, but result rows affected should greater than zero
func NamedGetContext ¶
func NamedGetContext( ctx context.Context, tx dbtypes.Named, dest interface{}, query string, arg interface{}, ) (err error)
NamedGetContext prepare named SQL statement and call Get function with context, return error if get nothing
func NamedSelectContext ¶
func NamedSelectContext( ctx context.Context, tx dbtypes.Named, dest interface{}, query string, arg interface{}, ) (err error)
NamedSelectContext prepare named SQL statement and call Select function with context
func NamedSelectInContext ¶
func NamedSelectInContext( ctx context.Context, tx dbtypes.Transactionx, dest interface{}, query string, arg interface{}, ) (err error)
NamedSelectInContext prepare named/in SQL statement and call Select function with context
func NamedSelectInStrictContext ¶
func NamedSelectInStrictContext( ctx context.Context, tx dbtypes.Transactionx, dest interface{}, query string, arg interface{}, ) (err error)
NamedSelectInStrictContext prepare named/in SQL statement and call Select function with context, return error if select nothing
func NamedSelectStrictContext ¶
func NamedSelectStrictContext( ctx context.Context, tx dbtypes.Named, dest interface{}, query string, arg interface{}, ) (err error)
NamedSelectStrictContext prepare named SQL statement and call Select function with context, return error if select nothing
func ParseTsQuery ¶
ParseTsQuery remove invalid tsquery syntax, tx should not be transaction because error will cause transaction stop
func SQLScanEnumString ¶
func SQLScanEnumString(obj interface{}, value interface{}, stringMapEnum map[string]interface{}) (err error)
SQLScanEnumString set obj to value's enum in stringMapEnum representation
func SQLScanJSON ¶
func SQLScanJSON(obj interface{}, value interface{}) (err error)
SQLScanJSON set obj to value's JSON representation
func SQLScanStrictJSON ¶
func SQLScanStrictJSON(obj interface{}, value interface{}) (err error)
SQLScanStrictJSON set obj to value's JSON representation, all field should exist in obj
func SQLScanString ¶
func SQLScanString(obj interface{}, value interface{}) (err error)
SQLScanString set obj to value's string representation
func SQLScanStringSlice ¶
func SQLScanStringSlice(obj interface{}, value interface{}) (err error)
SQLScanStringSlice set obj to value's stringslice representation
func SQLValueJSON ¶
SQLValueJSON return obj's JSON representation which implements driver.Value
func SQLValueStringSlice ¶
SQLValueStringSlice return s postgresql representation which implements driver.Value
Types ¶
type SQLJsonMap ¶
type SQLJsonMap map[string]interface{}
SQLJsonMap general map type for SQL
func (*SQLJsonMap) Scan ¶
func (t *SQLJsonMap) Scan(value interface{}) (err error)
Scan decode SQL value
type SQLNullTime ¶
SQLNullTime represents a time.Time that may be null. Inherit pq.NullTime and rewrite JSON marshaler
func (SQLNullTime) MarshalJSON ¶
func (t SQLNullTime) MarshalJSON() ([]byte, error)
MarshalJSON implement JSON marshaler
func (*SQLNullTime) UnmarshalJSON ¶
func (t *SQLNullTime) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON implement JSON unmarshaler
type SQLStringSlice ¶
type SQLStringSlice []string
SQLStringSlice is a type of []string and implement SQL driver
func NewSQLStringSlice ¶
func NewSQLStringSlice(s *[]string) *SQLStringSlice
NewSQLStringSlice create from *[]string
func (*SQLStringSlice) Scan ¶
func (t *SQLStringSlice) Scan(value interface{}) (err error)
Scan decode SQL value
func (*SQLStringSlice) ToStringSlice ¶
func (t *SQLStringSlice) ToStringSlice() *[]string
ToStringSlice return nil if SQLStringSlice is nil
type SQLStringSliceJSON ¶
type SQLStringSliceJSON []string
SQLStringSliceJSON is a type of []string and implement SQL driver
func (*SQLStringSliceJSON) Scan ¶
func (t *SQLStringSliceJSON) Scan(value interface{}) (err error)
Scan decode SQL value