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, args ...interface{})
- func AppendSelect(q *Query, columns ...string)
- func AppendWhere(q *Query, clause string, args ...interface{})
- func AppendWhereLeftParen(q *Query)
- func AppendWhereRightParen(q *Query)
- func AppendWith(q *Query, clause string, args ...interface{})
- func Assign(dst, src interface{})
- func Bind(rows *sql.Rows, obj interface{}) error
- func BindMapping(typ reflect.Type, mapping map[string]uint64, cols []string) ([]uint64, error)
- func BuildQuery(q *Query) (string, []interface{})
- func Equal(a, b interface{}) bool
- func GetSelect(q *Query) []string
- func IsNil(val interface{}) bool
- func IsValuerNil(val driver.Valuer) bool
- func MakeStructMapping(typ reflect.Type) map[string]uint64
- func MustTime(val driver.Valuer) time.Time
- func NonZeroDefaultSet(defaults []string, obj interface{}) []string
- func PtrsFromMapping(val reflect.Value, mapping []uint64) []interface{}
- func SetArgs(q *Query, args ...interface{})
- func SetCount(q *Query)
- func SetDelete(q *Query)
- func SetDialect(q *Query, dialect *drivers.Dialect)
- 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 SetLoadMods(q *Query, rel string, appl Applicator)
- func SetOffset(q *Query, offset int)
- func SetSQL(q *Query, sql string, args ...interface{})
- func SetScanner(scanner sql.Scanner, val driver.Value)
- func SetSelect(q *Query, sel []string)
- func SetUpdate(q *Query, cols map[string]interface{})
- func ValuesFromMapping(val reflect.Value, mapping []uint64) []interface{}
- type Applicator
- type Query
- func (q *Query) Bind(ctx context.Context, exec boil.Executor, obj interface{}) error
- func (q *Query) BindG(ctx context.Context, obj interface{}) error
- func (q *Query) BindP(ctx context.Context, exec boil.Executor, obj interface{})
- func (q *Query) Exec(exec boil.Executor) (sql.Result, error)
- func (q *Query) ExecContext(ctx context.Context, exec boil.ContextExecutor) (sql.Result, error)
- func (q *Query) ExecP(exec boil.Executor) sql.Result
- func (q *Query) Query(exec boil.Executor) (*sql.Rows, error)
- func (q *Query) QueryContext(ctx context.Context, exec boil.ContextExecutor) (*sql.Rows, error)
- func (q *Query) QueryP(exec boil.Executor) *sql.Rows
- func (q *Query) QueryRow(exec boil.Executor) *sql.Row
- func (q *Query) QueryRowContext(ctx context.Context, exec boil.ContextExecutor) *sql.Row
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 AppendOrderBy ¶
AppendOrderBy on the query.
func AppendWhere ¶
AppendWhere on the query.
func AppendWhereLeftParen ¶
func AppendWhereLeftParen(q *Query)
AppendWhereLeftParen creates a right left in the where expression
func AppendWhereRightParen ¶
func AppendWhereRightParen(q *Query)
AppendWhereRightParen creates a right paren in the where expression
func AppendWith ¶
AppendWith on the query.
func Assign ¶
func Assign(dst, src interface{})
Assign assigns a value to another using reflection. Dst must be a pointer.
func Bind ¶
Bind inserts the rows into the passed in object pointer, because the caller owns the rows it is imperative to note that the caller MUST both close the rows and check for errors on the rows.
If you neglect closing the rows your application may have a memory leak if the rows are not implicitly closed by iteration alone. If you neglect checking the rows.Err silent failures may occur in your application.
Valid types to bind to are: *Struct, []*Struct, and []Struct. Keep in mind if you use []Struct that Bind will be doing copy-by-value as a method of keeping heap memory usage low which means if your Struct contains reference types/pointers you will see incorrect results, do not use []Struct with a Struct with reference types.
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 usage:
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 BuildQuery ¶
BuildQuery builds a query object into the query string and it's accompanying arguments. Using this method allows query building without immediate execution.
func Equal ¶
func Equal(a, b interface{}) bool
Equal is different to reflect.DeepEqual in that it's both less efficient less magical, and dosen't concern itself with a wide variety of types that could be present but it does use the driver.Valuer interface since many types that will go through database things will use these.
We're focused on basic types + []byte. Since we're really only interested in things that are typically used for primary keys in a database.
Choosing not to use the DefaultParameterConverter here because sqlboiler doesn't generate pointer columns.
func IsNil ¶
func IsNil(val interface{}) bool
IsNil is a more generic version of IsValuerNil, will check to make sure it's not a valuer first.
func IsValuerNil ¶
IsValuerNil returns true if the valuer's value is null.
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 SetArgs ¶
func SetArgs(q *Query, args ...interface{})
SetArgs is primarily for re-use of a query so that the query text does not need to be re-generated, useful if you're performing the same query with different arguments over and over.
func SetLastWhereAsOr ¶
func SetLastWhereAsOr(q *Query)
SetLastWhereAsOr sets the or separator for the tail "WHERE" in the slice
func SetLoadMods ¶
func SetLoadMods(q *Query, rel string, appl Applicator)
SetLoadMods on the query.
func SetScanner ¶
SetScanner attempts to set a scannable value on a scanner.
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 Applicator ¶
type Applicator interface {
Apply(*Query)
}
Applicator exists only to allow query mods into the query struct around eager loaded relationships.
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.
If Context is non-nil it will upgrade the Executor to a ContextExecutor and query with the passed context. If Context is non-nil, any eager loading that's done must also be using load* methods that support context as the first parameter.
Also see documentation for Bind()
func (*Query) BindG ¶
BindG executes the query and inserts the result into the passed in object pointer. It uses the global executor. Also see documentation for Bind() and Query.Bind()
func (*Query) BindP ¶
BindP executes the query and inserts the result into the passed in object pointer. It panics on error. Also see documentation for Bind() and Query.Bind()
func (*Query) ExecContext ¶
ExecContext executes a query that does not need a row returned
func (*Query) ExecP ¶
ExecP executes a query that does not need a row returned It will panic on error
func (*Query) QueryContext ¶
QueryContext executes the query for the All finisher and returns multiple rows
func (*Query) QueryP ¶
QueryP executes the query for the All finisher and returns multiple rows It will panic on error
func (*Query) QueryRowContext ¶
QueryRowContext executes the query for the One finisher and returns a row