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 AppendOrderBy(q *Query, clause string)
- func AppendSelect(q *Query, columns ...string)
- func AppendWhere(q *Query, clause string, args ...interface{})
- func Bind(rows *sql.Rows, obj interface{}) error
- func BindMapping(typ reflect.Type, mapping map[string]uint64, cols []string) ([]uint64, error)
- func BuildUpsertQueryMySQL(dia Dialect, tableName string, update, whitelist []string) string
- func BuildUpsertQueryPostgres(dia Dialect, tableName string, updateOnConflict bool, ...) string
- func GetExecutor(q *Query) boil.Executor
- func MakeStructMapping(typ reflect.Type) map[string]uint64
- func NonZeroDefaultSet(defaults []string, obj interface{}) []string
- func PtrsFromMapping(val reflect.Value, mapping []uint64) []interface{}
- func SetCount(q *Query)
- func SetDelete(q *Query)
- func SetDialect(q *Query, dialect *Dialect)
- func SetExecutor(q *Query, exec boil.Executor)
- func SetFor(q *Query, clause string)
- func SetFrom(q *Query, from ...string)
- func SetLastInAsOr(q *Query)
- func SetLastWhereAsOr(q *Query)
- 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 []uint64) []interface{}
- type Dialect
- 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: `boil:"name,bind"`
- If "name" is omitted the sql column names that come back are TitleCased and matched against the field name.
- If the "name" part of the struct tag is specified, the given name will be used instead of the struct field name for binding.
- If the "name" of the struct tag is "-", this field will not be bound to.
- If the ",bind" option is specified on a struct field and that field is a struct itself, it will be recursed into to look for fields for binding.
Example Query:
type JoinStruct struct { // User1 can have it's struct fields bound to since it specifies // ,bind in the struct tag, it will look specifically for // fields that are prefixed with "user." returning from the query. // For example "user.id" column name will bind to User1.ID User1 *models.User `boil:"user,bind"` // User2 will follow the same rules as noted above except it will use // "friend." as the prefix it's looking for. User2 *models.User `boil:"friend,bind"` // RandomData will not be recursed into to look for fields to // bind and will not be bound to because of the - for the name. RandomData myStruct `boil:"-"` // Date will not be recursed into to look for fields to bind because // it does not specify ,bind in the struct tag. But it can be bound to // as it does not specify a - for the name. Date time.Time } models.Users(qm.InnerJoin("users as friend on users.friend_id = friend.id")).Bind(&joinStruct)
For custom objects that want to use eager loading, please see the loadRelationships function.
func BindMapping ¶
BindMapping creates a mapping that helps look up the pointer for the column given.
func BuildUpsertQueryMySQL ¶
BuildUpsertQueryMySQL builds a SQL statement string using the upsertData provided.
func BuildUpsertQueryPostgres ¶
func BuildUpsertQueryPostgres(dia Dialect, tableName string, updateOnConflict bool, ret, update, conflict, whitelist []string) string
BuildUpsertQueryPostgres builds a SQL statement string using the upsertData provided.
func MakeStructMapping ¶
MakeStructMapping creates a map of the struct to be able to quickly look up its pointers and values by name.
func NonZeroDefaultSet ¶
NonZeroDefaultSet returns the fields included in the defaults slice that are non zero values
func PtrsFromMapping ¶
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 SetLastInAsOr ¶
func SetLastInAsOr(q *Query)
SetLastInAsOr sets the or separator for the tail "IN" in the slice
func SetLastWhereAsOr ¶
func SetLastWhereAsOr(q *Query)
SetLastWhereAsOr sets the or separator for the tail "WHERE" in the slice
func ValuesFromMapping ¶
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 }
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 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 boil.Bind()
func (*Query) BindP ¶
func (q *Query) BindP(obj interface{})
BindP executes the query and inserts the result into the passed in object pointer. It panics on error. See boil.Bind() documentation.
func (*Query) ExecP ¶
ExecP executes a query that does not need a row returned It will panic on error