sqlutil

package
v1.0.0-...-4f7f1ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2016 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorUnsupportedScanType1 = errutil.NewFactory("unsupported scan type: %v")
	ErrorInvalidObjType1      = errutil.NewFactory("invalid obj type: %T")
	ErrorNoValueFound1        = errutil.NewFactory("no value found for key %v")
)
View Source
var (
	ErrorPrepareNamed = errutil.NewFactory("prepare SQL named query failed")
)

errors

Functions

func IsContainErrorDuplicateViolateUniqueConstraint

func IsContainErrorDuplicateViolateUniqueConstraint(err error) bool

func IsContainErrorNoRowsInResultSet

func IsContainErrorNoRowsInResultSet(err error) bool

func IsContainErrorTsquerySyntax

func IsContainErrorTsquerySyntax(err error) bool

func IsErrorDuplicateViolateUniqueConstraint

func IsErrorDuplicateViolateUniqueConstraint(err error) bool

func IsErrorNoRowsInResultSet

func IsErrorNoRowsInResultSet(err error) bool

func IsErrorTsquerySyntax

func IsErrorTsquerySyntax(err error) bool

func NamedGet

func NamedGet(
	tx dbtypes.Named,
	dest interface{},
	query string,
	arg interface{},
) (err error)

NamedGet prepare named SQL statement and call Get function

func NamedSelect

func NamedSelect(
	tx dbtypes.Named,
	dest interface{},
	query string,
	arg interface{},
) (err error)

NamedSelect prepare named SQL statement and call Select function

func SQLScanEnumString

func SQLScanEnumString(obj interface{}, value interface{}, stringMapEnum map[string]interface{}) (err error)

Set obj to value's enum in stringMapEnum representation

func SQLScanJson

func SQLScanJson(obj interface{}, value interface{}) (err error)

Set obj to value's JSON representation

func SQLScanString

func SQLScanString(obj interface{}, value interface{}) (err error)

Set obj to value's string representation

func SQLScanStringSlice

func SQLScanStringSlice(obj interface{}, value interface{}) (err error)

Set obj to value's stringslice representation

func SQLValueJson

func SQLValueJson(obj interface{}) (value driver.Value, err error)

Return obj's JSON representation which implements driver.Value

func SQLValueStringSlice

func SQLValueStringSlice(obj interface{}) (value driver.Value, err error)

Return s postgresql representation which implements driver.Value

func ToTsQuery

func ToTsQuery(db *sqlx.DB, query string) (tsquery string, err error)

Types

type JsonText

type JsonText json.RawMessage

JsonText is a json.RawMessage, which is a []byte underneath. Value() validates the json format in the source, and returns an error if the json is not valid. Scan does no validation. JsonText additionally implements `Unmarshal`, which unmarshals the json within to an interface{}

func (*JsonText) MarshalJSON

func (j *JsonText) MarshalJSON() ([]byte, error)

MarshalJSON returns the *j as the JSON encoding of j.

func (*JsonText) Scan

func (j *JsonText) Scan(src interface{}) error

Scan stores the src in *j. No validation is done.

func (*JsonText) Unmarshal

func (j *JsonText) Unmarshal(v interface{}) error

Unmarshal unmarshal's the json in j to v, as in json.Unmarshal.

func (*JsonText) UnmarshalJSON

func (j *JsonText) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *j to a copy of data

func (*JsonText) Value

func (j *JsonText) Value() (value driver.Value, err error)

Value returns j as a value. This does a validating unmarshal into another RawMessage. If j is invalid json, it returns an error.

type SQLJsonMap

type SQLJsonMap map[string]interface{}

func (*SQLJsonMap) Scan

func (t *SQLJsonMap) Scan(value interface{}) (err error)

func (*SQLJsonMap) Value

func (t *SQLJsonMap) Value() (value driver.Value, err error)

type SQLStringSlice

type SQLStringSlice []string

func NewSQLStringSlice

func NewSQLStringSlice(s *[]string) *SQLStringSlice

func (*SQLStringSlice) Scan

func (t *SQLStringSlice) Scan(value interface{}) (err error)

func (*SQLStringSlice) ToStringSlice

func (t *SQLStringSlice) ToStringSlice() *[]string

func (*SQLStringSlice) Value

func (t *SQLStringSlice) Value() (value driver.Value, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL