squirrel.v1: gopkg.in/Masterminds/squirrel.v1 Index | Files

package squirrel

import "gopkg.in/Masterminds/squirrel.v1"

Package squirrel provides a fluent SQL generator.

See https://github.com/Masterminds/squirrel for examples.

Index

Package Files

case.go delete.go delete_ctx.go expr.go insert.go insert_ctx.go part.go placeholder.go row.go select.go select_ctx.go squirrel.go squirrel_ctx.go statement.go stmtcacher.go stmtcacher_ctx.go update.go update_ctx.go where.go

Variables

var (
    // Question is a PlaceholderFormat instance that leaves placeholders as
    // question marks.
    Question = questionFormat{}

    // Dollar is a PlaceholderFormat instance that replaces placeholders with
    // dollar-prefixed positional placeholders (e.g. $1, $2, $3).
    Dollar = dollarFormat{}

    // Colon is a PlaceholderFormat instance that replaces placeholders with
    // colon-prefixed positional placeholders (e.g. :1, :2, :3).
    Colon = colonFormat{}
)
var NoContextSupport = errors.New("DB does not support Context")

NoContextSupport is returned if a db doesn't support Context.

var RunnerNotQueryRunner = fmt.Errorf("cannot QueryRow; Runner is not a QueryRower")

RunnerNotQueryRunner is returned by QueryRow if the RunWith value doesn't implement QueryRower.

var RunnerNotSet = fmt.Errorf("cannot run; no Runner set (RunWith)")

RunnerNotSet is returned by methods that need a Runner if it isn't set.

var StatementBuilder = StatementBuilderType(builder.EmptyBuilder).PlaceholderFormat(Question)

StatementBuilder is a parent builder for other builders, e.g. SelectBuilder.

func Alias Uses

func Alias(expr Sqlizer, alias string) aliasExpr

Alias allows to define alias for column in SelectBuilder. Useful when column is defined as complex expression like IF or CASE Ex:

.Column(Alias(caseStmt, "case_column"))

func DebugSqlizer Uses

func DebugSqlizer(s Sqlizer) string

DebugSqlizer calls ToSql on s and shows the approximate SQL to be executed

If ToSql returns an error, the result of this method will look like: "[ToSql error: %s]" or "[DebugSqlizer error: %s]"

IMPORTANT: As its name suggests, this function should only be used for debugging. While the string result *might* be valid SQL, this function does not try very hard to ensure it. Additionally, executing the output of this function with any untrusted user input is certainly insecure.

func ExecContextWith Uses

func ExecContextWith(ctx context.Context, db ExecerContext, s Sqlizer) (res sql.Result, err error)

ExecContextWith ExecContexts the SQL returned by s with db.

func ExecWith Uses

func ExecWith(db Execer, s Sqlizer) (res sql.Result, err error)

ExecWith Execs the SQL returned by s with db.

func Expr Uses

func Expr(sql string, args ...interface{}) expr

Expr builds value expressions for InsertBuilder and UpdateBuilder.

Ex:

.Values(Expr("FROM_UNIXTIME(?)", t))

func Placeholders Uses

func Placeholders(count int) string

Placeholders returns a string with count ? placeholders joined with commas.

func QueryContextWith Uses

func QueryContextWith(ctx context.Context, db QueryerContext, s Sqlizer) (rows *sql.Rows, err error)

QueryContextWith QueryContexts the SQL returned by s with db.

func QueryWith Uses

func QueryWith(db Queryer, s Sqlizer) (rows *sql.Rows, err error)

QueryWith Querys the SQL returned by s with db.

type And Uses

type And conj

And conjunction Sqlizers

func (And) ToSql Uses

func (a And) ToSql() (string, []interface{}, error)

type BaseRunner Uses

type BaseRunner interface {
    Execer
    Queryer
}

BaseRunner groups the Execer and Queryer interfaces.

type CaseBuilder Uses

type CaseBuilder builder.Builder

CaseBuilder builds SQL CASE construct which could be used as parts of queries.

func Case Uses

func Case(what ...interface{}) CaseBuilder

Case returns a new CaseBuilder "what" represents case value

func (CaseBuilder) Else Uses

func (b CaseBuilder) Else(expr interface{}) CaseBuilder

What sets optional "ELSE ..." part for CASE construct

func (CaseBuilder) ToSql Uses

func (b CaseBuilder) ToSql() (string, []interface{}, error)

ToSql builds the query into a SQL string and bound args.

func (CaseBuilder) When Uses

func (b CaseBuilder) When(when interface{}, then interface{}) CaseBuilder

When adds "WHEN ... THEN ..." part to CASE construct

type DBProxy Uses

type DBProxy interface {
    Execer
    Queryer
    QueryRower
    Preparer
}

DBProxy groups the Execer, Queryer, QueryRower, and Preparer interfaces.

type DBProxyBeginner Uses

type DBProxyBeginner interface {
    DBProxy
    Begin() (*sql.Tx, error)
}

func NewStmtCacheProxy Uses

func NewStmtCacheProxy(db *sql.DB) DBProxyBeginner

type DBProxyContext Uses

type DBProxyContext interface {
    Execer
    Queryer
    QueryRower
    PreparerContext
}

DBProxyContext groups the Execer, Queryer, QueryRower and PreparerContext interfaces.

func NewStmtCacher Uses

func NewStmtCacher(prep PreparerContext) DBProxyContext

NewStmtCacher returns a DBProxy wrapping prep that caches Prepared Stmts.

Stmts are cached based on the string value of their queries.

type DeleteBuilder Uses

type DeleteBuilder builder.Builder

DeleteBuilder builds SQL DELETE statements.

func Delete Uses

func Delete(from string) DeleteBuilder

Delete returns a new DeleteBuilder with the given table name.

See DeleteBuilder.Table.

func (DeleteBuilder) Exec Uses

func (b DeleteBuilder) Exec() (sql.Result, error)

Exec builds and Execs the query with the Runner set by RunWith.

func (DeleteBuilder) ExecContext Uses

func (b DeleteBuilder) ExecContext(ctx context.Context) (sql.Result, error)

ExecContext builds and ExecContexts the query with the Runner set by RunWith.

func (DeleteBuilder) From Uses

func (b DeleteBuilder) From(from string) DeleteBuilder

From sets the table to be deleted from.

func (DeleteBuilder) Limit Uses

func (b DeleteBuilder) Limit(limit uint64) DeleteBuilder

Limit sets a LIMIT clause on the query.

func (DeleteBuilder) Offset Uses

func (b DeleteBuilder) Offset(offset uint64) DeleteBuilder

Offset sets a OFFSET clause on the query.

func (DeleteBuilder) OrderBy Uses

func (b DeleteBuilder) OrderBy(orderBys ...string) DeleteBuilder

OrderBy adds ORDER BY expressions to the query.

func (DeleteBuilder) PlaceholderFormat Uses

func (b DeleteBuilder) PlaceholderFormat(f PlaceholderFormat) DeleteBuilder

PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query.

func (DeleteBuilder) Prefix Uses

func (b DeleteBuilder) Prefix(sql string, args ...interface{}) DeleteBuilder

Prefix adds an expression to the beginning of the query

func (DeleteBuilder) Query Uses

func (b DeleteBuilder) Query() (*sql.Rows, error)

func (DeleteBuilder) RunWith Uses

func (b DeleteBuilder) RunWith(runner BaseRunner) DeleteBuilder

RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.

func (DeleteBuilder) Suffix Uses

func (b DeleteBuilder) Suffix(sql string, args ...interface{}) DeleteBuilder

Suffix adds an expression to the end of the query

func (DeleteBuilder) ToSql Uses

func (b DeleteBuilder) ToSql() (string, []interface{}, error)

ToSql builds the query into a SQL string and bound args.

func (DeleteBuilder) Where Uses

func (b DeleteBuilder) Where(pred interface{}, args ...interface{}) DeleteBuilder

Where adds WHERE expressions to the query.

See SelectBuilder.Where for more information.

type Eq Uses

type Eq map[string]interface{}

Eq is syntactic sugar for use with Where/Having/Set methods. Ex:

.Where(Eq{"id": 1})

func (Eq) ToSql Uses

func (eq Eq) ToSql() (sql string, args []interface{}, err error)

type Execer Uses

type Execer interface {
    Exec(query string, args ...interface{}) (sql.Result, error)
}

Execer is the interface that wraps the Exec method.

Exec executes the given query as implemented by database/sql.Exec.

type ExecerContext Uses

type ExecerContext interface {
    ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

ExecerContext is the interface that wraps the ExecContext method.

Exec executes the given query as implemented by database/sql.ExecContext.

type Gt Uses

type Gt Lt

Gt is syntactic sugar for use with Where/Having/Set methods. Ex:

.Where(Gt{"id": 1}) == "id > 1"

func (Gt) ToSql Uses

func (gt Gt) ToSql() (sql string, args []interface{}, err error)

type GtOrEq Uses

type GtOrEq Lt

GtOrEq is syntactic sugar for use with Where/Having/Set methods. Ex:

.Where(GtOrEq{"id": 1}) == "id >= 1"

func (GtOrEq) ToSql Uses

func (gtOrEq GtOrEq) ToSql() (sql string, args []interface{}, err error)

type InsertBuilder Uses

type InsertBuilder builder.Builder

InsertBuilder builds SQL INSERT statements.

func Insert Uses

func Insert(into string) InsertBuilder

Insert returns a new InsertBuilder with the given table name.

See InsertBuilder.Into.

func (InsertBuilder) Columns Uses

func (b InsertBuilder) Columns(columns ...string) InsertBuilder

Columns adds insert columns to the query.

func (InsertBuilder) Exec Uses

func (b InsertBuilder) Exec() (sql.Result, error)

Exec builds and Execs the query with the Runner set by RunWith.

func (InsertBuilder) ExecContext Uses

func (b InsertBuilder) ExecContext(ctx context.Context) (sql.Result, error)

ExecContext builds and ExecContexts the query with the Runner set by RunWith.

func (InsertBuilder) Into Uses

func (b InsertBuilder) Into(from string) InsertBuilder

Into sets the INTO clause of the query.

func (InsertBuilder) Options Uses

func (b InsertBuilder) Options(options ...string) InsertBuilder

Options adds keyword options before the INTO clause of the query.

func (InsertBuilder) PlaceholderFormat Uses

func (b InsertBuilder) PlaceholderFormat(f PlaceholderFormat) InsertBuilder

PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query.

func (InsertBuilder) Prefix Uses

func (b InsertBuilder) Prefix(sql string, args ...interface{}) InsertBuilder

Prefix adds an expression to the beginning of the query

func (InsertBuilder) Query Uses

func (b InsertBuilder) Query() (*sql.Rows, error)

Query builds and Querys the query with the Runner set by RunWith.

func (InsertBuilder) QueryContext Uses

func (b InsertBuilder) QueryContext(ctx context.Context) (*sql.Rows, error)

QueryContext builds and QueryContexts the query with the Runner set by RunWith.

func (InsertBuilder) QueryRow Uses

func (b InsertBuilder) QueryRow() RowScanner

QueryRow builds and QueryRows the query with the Runner set by RunWith.

func (InsertBuilder) QueryRowContext Uses

func (b InsertBuilder) QueryRowContext(ctx context.Context) RowScanner

QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith.

func (InsertBuilder) RunWith Uses

func (b InsertBuilder) RunWith(runner BaseRunner) InsertBuilder

RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.

func (InsertBuilder) Scan Uses

func (b InsertBuilder) Scan(dest ...interface{}) error

Scan is a shortcut for QueryRow().Scan.

func (InsertBuilder) ScanContext Uses

func (b InsertBuilder) ScanContext(ctx context.Context, dest ...interface{}) error

ScanContext is a shortcut for QueryRowContext().Scan.

func (InsertBuilder) Select Uses

func (b InsertBuilder) Select(sb SelectBuilder) InsertBuilder

Select set Select clause for insert query If Values and Select are used, then Select has higher priority

func (InsertBuilder) SetMap Uses

func (b InsertBuilder) SetMap(clauses map[string]interface{}) InsertBuilder

SetMap set columns and values for insert builder from a map of column name and value note that it will reset all previous columns and values was set if any

func (InsertBuilder) Suffix Uses

func (b InsertBuilder) Suffix(sql string, args ...interface{}) InsertBuilder

Suffix adds an expression to the end of the query

func (InsertBuilder) ToSql Uses

func (b InsertBuilder) ToSql() (string, []interface{}, error)

ToSql builds the query into a SQL string and bound args.

func (InsertBuilder) Values Uses

func (b InsertBuilder) Values(values ...interface{}) InsertBuilder

Values adds a single row's values to the query.

type Like Uses

type Like map[string]interface{}

Like is syntactic sugar for use with LIKE conditions. Ex:

.Where(Like{"name": "%irrel"})

func (Like) ToSql Uses

func (lk Like) ToSql() (sql string, args []interface{}, err error)

type Lt Uses

type Lt map[string]interface{}

Lt is syntactic sugar for use with Where/Having/Set methods. Ex:

.Where(Lt{"id": 1})

func (Lt) ToSql Uses

func (lt Lt) ToSql() (sql string, args []interface{}, err error)

type LtOrEq Uses

type LtOrEq Lt

LtOrEq is syntactic sugar for use with Where/Having/Set methods. Ex:

.Where(LtOrEq{"id": 1}) == "id <= 1"

func (LtOrEq) ToSql Uses

func (ltOrEq LtOrEq) ToSql() (sql string, args []interface{}, err error)

type NotEq Uses

type NotEq Eq

NotEq is syntactic sugar for use with Where/Having/Set methods. Ex:

.Where(NotEq{"id": 1}) == "id <> 1"

func (NotEq) ToSql Uses

func (neq NotEq) ToSql() (sql string, args []interface{}, err error)

type NotLike Uses

type NotLike Like

NotLike is syntactic sugar for use with LIKE conditions. Ex:

.Where(NotLike{"name": "%irrel"})

func (NotLike) ToSql Uses

func (nlk NotLike) ToSql() (sql string, args []interface{}, err error)

type Or Uses

type Or conj

Or conjunction Sqlizers

func (Or) ToSql Uses

func (o Or) ToSql() (string, []interface{}, error)

type PlaceholderFormat Uses

type PlaceholderFormat interface {
    ReplacePlaceholders(sql string) (string, error)
}

PlaceholderFormat is the interface that wraps the ReplacePlaceholders method.

ReplacePlaceholders takes a SQL statement and replaces each question mark placeholder with a (possibly different) SQL placeholder.

type Preparer Uses

type Preparer interface {
    Prepare(query string) (*sql.Stmt, error)
}

Prepareer is the interface that wraps the Prepare method.

Prepare executes the given query as implemented by database/sql.Prepare.

type PreparerContext Uses

type PreparerContext interface {
    Preparer
    PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

PrepareerContext is the interface that wraps the Prepare and PrepareContext methods.

Prepare executes the given query as implemented by database/sql.Prepare. PrepareContext executes the given query as implemented by database/sql.PrepareContext.

type QueryRower Uses

type QueryRower interface {
    QueryRow(query string, args ...interface{}) RowScanner
}

QueryRower is the interface that wraps the QueryRow method.

QueryRow executes the given query as implemented by database/sql.QueryRow.

type QueryRowerContext Uses

type QueryRowerContext interface {
    QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner
}

QueryRowerContext is the interface that wraps the QueryRowContext method.

QueryRowContext executes the given query as implemented by database/sql.QueryRowContext.

type Queryer Uses

type Queryer interface {
    Query(query string, args ...interface{}) (*sql.Rows, error)
}

Queryer is the interface that wraps the Query method.

Query executes the given query as implemented by database/sql.Query.

type QueryerContext Uses

type QueryerContext interface {
    QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

QueryerContext is the interface that wraps the QueryContext method.

QueryContext executes the given query as implemented by database/sql.QueryContext.

type Row Uses

type Row struct {
    RowScanner
    // contains filtered or unexported fields
}

Row wraps database/sql.Row to let squirrel return new errors on Scan.

func (*Row) Scan Uses

func (r *Row) Scan(dest ...interface{}) error

Scan returns Row.err or calls RowScanner.Scan.

type RowScanner Uses

type RowScanner interface {
    Scan(...interface{}) error
}

RowScanner is the interface that wraps the Scan method.

Scan behaves like database/sql.Row.Scan.

func QueryRowContextWith Uses

func QueryRowContextWith(ctx context.Context, db QueryRowerContext, s Sqlizer) RowScanner

QueryRowContextWith QueryRowContexts the SQL returned by s with db.

func QueryRowWith Uses

func QueryRowWith(db QueryRower, s Sqlizer) RowScanner

QueryRowWith QueryRows the SQL returned by s with db.

type Runner Uses

type Runner interface {
    Execer
    Queryer
    QueryRower
}

Runner groups the Execer, Queryer, and QueryRower interfaces.

type SelectBuilder Uses

type SelectBuilder builder.Builder

SelectBuilder builds SQL SELECT statements.

func Select Uses

func Select(columns ...string) SelectBuilder

Select returns a new SelectBuilder, optionally setting some result columns.

See SelectBuilder.Columns.

func (SelectBuilder) Column Uses

func (b SelectBuilder) Column(column interface{}, args ...interface{}) SelectBuilder

Column adds a result column to the query. Unlike Columns, Column accepts args which will be bound to placeholders in the columns string, for example:

Column("IF(col IN ("+squirrel.Placeholders(3)+"), 1, 0) as col", 1, 2, 3)

func (SelectBuilder) Columns Uses

func (b SelectBuilder) Columns(columns ...string) SelectBuilder

Columns adds result columns to the query.

func (SelectBuilder) Distinct Uses

func (b SelectBuilder) Distinct() SelectBuilder

Distinct adds a DISTINCT clause to the query.

func (SelectBuilder) Exec Uses

func (b SelectBuilder) Exec() (sql.Result, error)

Exec builds and Execs the query with the Runner set by RunWith.

func (SelectBuilder) ExecContext Uses

func (b SelectBuilder) ExecContext(ctx context.Context) (sql.Result, error)

ExecContext builds and ExecContexts the query with the Runner set by RunWith.

func (SelectBuilder) From Uses

func (b SelectBuilder) From(from string) SelectBuilder

From sets the FROM clause of the query.

func (SelectBuilder) FromSelect Uses

func (b SelectBuilder) FromSelect(from SelectBuilder, alias string) SelectBuilder

FromSelect sets a subquery into the FROM clause of the query.

func (SelectBuilder) GroupBy Uses

func (b SelectBuilder) GroupBy(groupBys ...string) SelectBuilder

GroupBy adds GROUP BY expressions to the query.

func (SelectBuilder) Having Uses

func (b SelectBuilder) Having(pred interface{}, rest ...interface{}) SelectBuilder

Having adds an expression to the HAVING clause of the query.

See Where.

func (SelectBuilder) Join Uses

func (b SelectBuilder) Join(join string, rest ...interface{}) SelectBuilder

Join adds a JOIN clause to the query.

func (SelectBuilder) JoinClause Uses

func (b SelectBuilder) JoinClause(pred interface{}, args ...interface{}) SelectBuilder

JoinClause adds a join clause to the query.

func (SelectBuilder) LeftJoin Uses

func (b SelectBuilder) LeftJoin(join string, rest ...interface{}) SelectBuilder

LeftJoin adds a LEFT JOIN clause to the query.

func (SelectBuilder) Limit Uses

func (b SelectBuilder) Limit(limit uint64) SelectBuilder

Limit sets a LIMIT clause on the query.

func (SelectBuilder) MustSql Uses

func (b SelectBuilder) MustSql() (string, []interface{})

func (SelectBuilder) Offset Uses

func (b SelectBuilder) Offset(offset uint64) SelectBuilder

Offset sets a OFFSET clause on the query.

func (SelectBuilder) Options Uses

func (b SelectBuilder) Options(options ...string) SelectBuilder

Options adds select option to the query

func (SelectBuilder) OrderBy Uses

func (b SelectBuilder) OrderBy(orderBys ...string) SelectBuilder

OrderBy adds ORDER BY expressions to the query.

func (SelectBuilder) PlaceholderFormat Uses

func (b SelectBuilder) PlaceholderFormat(f PlaceholderFormat) SelectBuilder

PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query.

func (SelectBuilder) Prefix Uses

func (b SelectBuilder) Prefix(sql string, args ...interface{}) SelectBuilder

Prefix adds an expression to the beginning of the query

func (SelectBuilder) Query Uses

func (b SelectBuilder) Query() (*sql.Rows, error)

Query builds and Querys the query with the Runner set by RunWith.

func (SelectBuilder) QueryContext Uses

func (b SelectBuilder) QueryContext(ctx context.Context) (*sql.Rows, error)

QueryContext builds and QueryContexts the query with the Runner set by RunWith.

func (SelectBuilder) QueryRow Uses

func (b SelectBuilder) QueryRow() RowScanner

QueryRow builds and QueryRows the query with the Runner set by RunWith.

func (SelectBuilder) QueryRowContext Uses

func (b SelectBuilder) QueryRowContext(ctx context.Context) RowScanner

QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith.

func (SelectBuilder) RemoveLimit Uses

func (b SelectBuilder) RemoveLimit() SelectBuilder

Limit ALL allows to access all records with limit

func (SelectBuilder) RightJoin Uses

func (b SelectBuilder) RightJoin(join string, rest ...interface{}) SelectBuilder

RightJoin adds a RIGHT JOIN clause to the query.

func (SelectBuilder) RunWith Uses

func (b SelectBuilder) RunWith(runner BaseRunner) SelectBuilder

RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.

func (SelectBuilder) Scan Uses

func (b SelectBuilder) Scan(dest ...interface{}) error

Scan is a shortcut for QueryRow().Scan.

func (SelectBuilder) ScanContext Uses

func (b SelectBuilder) ScanContext(ctx context.Context, dest ...interface{}) error

ScanContext is a shortcut for QueryRowContext().Scan.

func (SelectBuilder) Suffix Uses

func (b SelectBuilder) Suffix(sql string, args ...interface{}) SelectBuilder

Suffix adds an expression to the end of the query

func (SelectBuilder) ToSql Uses

func (b SelectBuilder) ToSql() (string, []interface{}, error)

ToSql builds the query into a SQL string and bound args.

func (SelectBuilder) Where Uses

func (b SelectBuilder) Where(pred interface{}, args ...interface{}) SelectBuilder

Where adds an expression to the WHERE clause of the query.

Expressions are ANDed together in the generated SQL.

Where accepts several types for its pred argument:

nil OR "" - ignored.

string - SQL expression. If the expression has SQL placeholders then a set of arguments must be passed as well, one for each placeholder.

map[string]interface{} OR Eq - map of SQL expressions to values. Each key is transformed into an expression like "<key> = ?", with the corresponding value bound to the placeholder. If the value is nil, the expression will be "<key> IS NULL". If the value is an array or slice, the expression will be "<key> IN (?,?,...)", with one placeholder for each item in the value. These expressions are ANDed together.

Where will panic if pred isn't any of the above types.

type Sqlizer Uses

type Sqlizer interface {
    ToSql() (string, []interface{}, error)
}

Sqlizer is the interface that wraps the ToSql method.

ToSql returns a SQL representation of the Sqlizer, along with a slice of args as passed to e.g. database/sql.Exec. It can also return an error.

type StatementBuilderType Uses

type StatementBuilderType builder.Builder

StatementBuilderType is the type of StatementBuilder.

func (StatementBuilderType) Delete Uses

func (b StatementBuilderType) Delete(from string) DeleteBuilder

Delete returns a DeleteBuilder for this StatementBuilderType.

func (StatementBuilderType) Insert Uses

func (b StatementBuilderType) Insert(into string) InsertBuilder

Insert returns a InsertBuilder for this StatementBuilderType.

func (StatementBuilderType) PlaceholderFormat Uses

func (b StatementBuilderType) PlaceholderFormat(f PlaceholderFormat) StatementBuilderType

PlaceholderFormat sets the PlaceholderFormat field for any child builders.

func (StatementBuilderType) RunWith Uses

func (b StatementBuilderType) RunWith(runner BaseRunner) StatementBuilderType

RunWith sets the RunWith field for any child builders.

func (StatementBuilderType) Select Uses

func (b StatementBuilderType) Select(columns ...string) SelectBuilder

Select returns a SelectBuilder for this StatementBuilderType.

func (StatementBuilderType) Update Uses

func (b StatementBuilderType) Update(table string) UpdateBuilder

Update returns a UpdateBuilder for this StatementBuilderType.

type UpdateBuilder Uses

type UpdateBuilder builder.Builder

UpdateBuilder builds SQL UPDATE statements.

func Update Uses

func Update(table string) UpdateBuilder

Update returns a new UpdateBuilder with the given table name.

See UpdateBuilder.Table.

func (UpdateBuilder) Exec Uses

func (b UpdateBuilder) Exec() (sql.Result, error)

Exec builds and Execs the query with the Runner set by RunWith.

func (UpdateBuilder) ExecContext Uses

func (b UpdateBuilder) ExecContext(ctx context.Context) (sql.Result, error)

ExecContext builds and ExecContexts the query with the Runner set by RunWith.

func (UpdateBuilder) Limit Uses

func (b UpdateBuilder) Limit(limit uint64) UpdateBuilder

Limit sets a LIMIT clause on the query.

func (UpdateBuilder) Offset Uses

func (b UpdateBuilder) Offset(offset uint64) UpdateBuilder

Offset sets a OFFSET clause on the query.

func (UpdateBuilder) OrderBy Uses

func (b UpdateBuilder) OrderBy(orderBys ...string) UpdateBuilder

OrderBy adds ORDER BY expressions to the query.

func (UpdateBuilder) PlaceholderFormat Uses

func (b UpdateBuilder) PlaceholderFormat(f PlaceholderFormat) UpdateBuilder

PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query.

func (UpdateBuilder) Prefix Uses

func (b UpdateBuilder) Prefix(sql string, args ...interface{}) UpdateBuilder

Prefix adds an expression to the beginning of the query

func (UpdateBuilder) Query Uses

func (b UpdateBuilder) Query() (*sql.Rows, error)

func (UpdateBuilder) QueryContext Uses

func (b UpdateBuilder) QueryContext(ctx context.Context) (*sql.Rows, error)

QueryContext builds and QueryContexts the query with the Runner set by RunWith.

func (UpdateBuilder) QueryRow Uses

func (b UpdateBuilder) QueryRow() RowScanner

func (UpdateBuilder) QueryRowContext Uses

func (b UpdateBuilder) QueryRowContext(ctx context.Context) RowScanner

QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith.

func (UpdateBuilder) RunWith Uses

func (b UpdateBuilder) RunWith(runner BaseRunner) UpdateBuilder

RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec.

func (UpdateBuilder) Scan Uses

func (b UpdateBuilder) Scan(dest ...interface{}) error

func (UpdateBuilder) ScanContext Uses

func (b UpdateBuilder) ScanContext(ctx context.Context, dest ...interface{}) error

ScanContext is a shortcut for QueryRowContext().Scan.

func (UpdateBuilder) Set Uses

func (b UpdateBuilder) Set(column string, value interface{}) UpdateBuilder

Set adds SET clauses to the query.

func (UpdateBuilder) SetMap Uses

func (b UpdateBuilder) SetMap(clauses map[string]interface{}) UpdateBuilder

SetMap is a convenience method which calls .Set for each key/value pair in clauses.

func (UpdateBuilder) Suffix Uses

func (b UpdateBuilder) Suffix(sql string, args ...interface{}) UpdateBuilder

Suffix adds an expression to the end of the query

func (UpdateBuilder) Table Uses

func (b UpdateBuilder) Table(table string) UpdateBuilder

Table sets the table to be updated.

func (UpdateBuilder) ToSql Uses

func (b UpdateBuilder) ToSql() (string, []interface{}, error)

ToSql builds the query into a SQL string and bound args.

func (UpdateBuilder) Where Uses

func (b UpdateBuilder) Where(pred interface{}, args ...interface{}) UpdateBuilder

Where adds WHERE expressions to the query.

See SelectBuilder.Where for more information.

Package squirrel imports 12 packages (graph) and is imported by 12 packages. Updated 2019-01-14. Refresh now. Tools for package owners.