Documentation
¶
Index ¶
- Variables
- func BuildNamedParametersUpdateSetQuery(obj interface{}, fields []string) (string, error)
- func BuildNamedParametersUpdateSetQueryV2(obj interface{}, fields []string) (string, []string, error)
- func BuildParametrizedUpdateSetQuery(obj interface{}, fields []string) (string, error)
- func BuildUpdateSetQuery(obj interface{}, fields []string) (string, error)
- func GetAllFields(obj interface{}, skipFields []string, quoted bool, asNamedParameter bool) (fieldList string, err error)
- func GetChangedFields(original interface{}, new interface{}, skipFields []string) (fields []string, err error)
- func GetParameterValues(obj interface{}, fields []string, args ...interface{}) ([]interface{}, error)
- type DBType
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidFieldList = errors.New("invalid field list")
)
Database util errors
Functions ¶
func BuildNamedParametersUpdateSetQuery ¶
BuildNamedParametersUpdateSetQuery returns a string that can be used to build a set query, using named parameters (:param_name)
func BuildNamedParametersUpdateSetQueryV2 ¶
func BuildNamedParametersUpdateSetQueryV2(obj interface{}, fields []string) (string, []string, error)
BuildNamedParametersUpdateSetQueryV2 returns a string that can be used to build a set query, using named parameters (:param_name). This new version uses tag name, instead of struct's field name to compare.
func BuildParametrizedUpdateSetQuery ¶
BuildParametrizedUpdateSetQuery returns a string that can be used to build a set query, using parameters instead of values (parameter used is '?')
func BuildUpdateSetQuery ¶
BuildUpdateSetQuery returns a string that can be used to build a set query, with the values put as part of the string
func GetAllFields ¶
func GetAllFields(obj interface{}, skipFields []string, quoted bool, asNamedParameter bool) (fieldList string, err error)
GetAllFields returns all the db configured fields for the indicated struct.
Those fields indicated in 'skipFields' will not be included in the list; this is useful when dealing with auto incremental fields.
Flag 'quoted' makes all the fields to be wrapped as `field_name`; 'asNamedParameter' returns all fields as :field_name, useful for named queries. Flags are exclusive, use one or the other.
Note: those fields without the 'db' attribute or marked with a dash (`db:"-"`) are ignored.
func GetChangedFields ¶
func GetChangedFields(original interface{}, new interface{}, skipFields []string) (fields []string, err error)
GetChangedFields compare the fieles from source and destination and returns the list of fields that have been changed
func GetParameterValues ¶
func GetParameterValues(obj interface{}, fields []string, args ...interface{}) ([]interface{}, error)
GetParameterValues returns an array that may be used in a parametrized query