Documentation ¶
Index ¶
- Constants
- func AppendFrom(q *Query, from ...string)
- func AppendGroupBy(q *Query, clause string)
- func AppendHaving(q *Query, clause string, args ...interface{})
- func AppendIn(q *Query, clause string, args ...interface{})
- func AppendInnerJoin(q *Query, clause string, args ...interface{})
- func AppendLoad(q *Query, relationships ...string)
- func AppendOrderBy(q *Query, clause string)
- func AppendSelect(q *Query, fields ...string)
- func AppendWhere(q *Query, clause string, args ...interface{})
- func Bind(rows *sql.Rows, obj interface{}) error
- func BuildUpsertQueryMSSQL(dia Dialect, modelName string, primary, update, insert []string, ...) string
- func BuildUpsertQueryMySQL(dia Dialect, modelName string, update, whitelist []string) string
- func BuildUpsertQueryPostgres(dia Dialect, modelName string, updateOnConflict bool, ...) string
- func GetSelect(q *Query) []string
- func MakeStructMapping(typ reflect.Type) map[string]MappedField
- func PtrsFromMapping(val reflect.Value, mapping []MappedField) []interface{}
- func SetCount(q *Query)
- func SetDelete(q *Query)
- func SetDialect(q *Query, dialect *Dialect)
- func SetFor(q *Query, clause string)
- func SetFrom(q *Query, from ...string)
- func SetLimit(q *Query, limit int)
- func SetLoad(q *Query, relationships ...string)
- func SetOffset(q *Query, offset int)
- func SetSQL(q *Query, sql string, args ...interface{})
- func SetSelect(q *Query, sel []string)
- func SetUpdate(q *Query, cols map[string]interface{})
- func ValuesFromMapping(val reflect.Value, mapping []MappedField) []interface{}
- type Dialect
- type MappedField
- type Query
Constants ¶
const ( JoinInner joinKind = iota JoinOuterLeft JoinOuterRight JoinNatural )
Join type constants
Variables ¶
This section is empty.
Functions ¶
func AppendHaving ¶
AppendHaving on the query.
func AppendInnerJoin ¶
AppendInnerJoin on the query.
func AppendWhere ¶
AppendWhere on the query.
func Bind ¶
Bind executes the query and inserts the result into the passed in object pointer
Bind rules:
- Struct tags control bind, in the form of: `bunny:"name,bind,null:valid_column_name"`
- If the `bunny` struct tag is not present, the field will be completely ignored.
- The "name" part specifies the SQL column name that will be bound to this field.
- If the ",bind" option is specified on a field of struct type, Bind will recurse into it to look for fields for binding. "name" is appended as a prefix to the SQL column names of the inner fields.
- If the ",null:valid_column_name" option is specified in addition to ",bind", the SQL boolean column "valid_column_name" is used to tell whether the nested struct is valid (not null) or not (null).
func BuildUpsertQueryMSSQL ¶
func BuildUpsertQueryMSSQL(dia Dialect, modelName string, primary, update, insert []string, output []string) string
BuildUpsertQueryMSSQL builds a SQL statement string using the upsertData provided.
func BuildUpsertQueryMySQL ¶
BuildUpsertQueryMySQL builds a SQL statement string using the upsertData provided.
func BuildUpsertQueryPostgres ¶
func BuildUpsertQueryPostgres(dia Dialect, modelName string, updateOnConflict bool, ret, update, conflict, whitelist []string) string
BuildUpsertQueryPostgres builds a SQL statement string using the upsertData provided.
func MakeStructMapping ¶
func MakeStructMapping(typ reflect.Type) map[string]MappedField
MakeStructMapping creates a map of the struct to be able to quickly look up its pointers and values by name.
func PtrsFromMapping ¶
func PtrsFromMapping(val reflect.Value, mapping []MappedField) []interface{}
PtrsFromMapping expects to be passed an addressable struct and a mapping of where to find things. It pulls the pointers out referred to by the mapping.
func ValuesFromMapping ¶
func ValuesFromMapping(val reflect.Value, mapping []MappedField) []interface{}
ValuesFromMapping expects to be passed an addressable struct and a mapping of where to find things. It pulls the pointers out referred to by the mapping.
Types ¶
type Dialect ¶
type Dialect struct { // The left quote character for SQL identifiers LQ byte // The right quote character for SQL identifiers RQ byte // Bool flag indicating whether indexed // placeholders ($1) are used, or ? placeholders. IndexPlaceholders bool // Bool flag indicating whether "TOP" or "LIMIT" clause // must be used for rows limitation UseTopClause bool }
Dialect holds values that direct the query builder how to build compatible queries for each database. Each database driver needs to implement functions that provide these values.
type MappedField ¶
type MappedField struct { Path uint64 ParentValid *MappedField }
func BindMapping ¶
func BindMapping(typ reflect.Type, mapping map[string]MappedField, cols []string) ([]MappedField, error)
BindMapping creates a mapping that helps look up the pointer for the field given.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query holds the state for the built up query
func (*Query) Bind ¶
Bind executes the query and inserts the result into the passed in object pointer
See documentation for bunny.Bind()