package squirrel

Import Path
	github.com/Masterminds/squirrel (on go.dev)

Dependency Relation
	imports 12 packages, and imported by one package

Involved Source 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 Package squirrel provides a fluent SQL generator. See https://github.com/Masterminds/squirrel for examples. squirrel_ctx.go statement.go stmtcacher.go stmtcacher_ctx.go update.go update_ctx.go where.go
Package-Level Type Names (total 62, in which 39 are exported)
/* sort exporteds by: | */
And conjunction Sqlizers ( T) ToSql() (string, []interface{}, error) T : Sqlizer
BaseRunner groups the Execer and Queryer interfaces. ( T) Exec(query string, args ...interface{}) (sql.Result, error) ( T) Query(query string, args ...interface{}) (*sql.Rows, error) DBProxy (interface) DBProxyBeginner (interface) DBProxyContext (interface) Runner (interface) RunnerContext (interface) StdSql (interface) StdSqlCtx (interface) *StmtCache *database/sql.DB *database/sql.Tx T : Execer T : Queryer func DeleteBuilder.RunWith(runner BaseRunner) DeleteBuilder func InsertBuilder.RunWith(runner BaseRunner) InsertBuilder func SelectBuilder.RunWith(runner BaseRunner) SelectBuilder func StatementBuilderType.RunWith(runner BaseRunner) StatementBuilderType func UpdateBuilder.RunWith(runner BaseRunner) UpdateBuilder
CaseBuilder builds SQL CASE construct which could be used as parts of queries. What sets optional "ELSE ..." part for CASE construct ToSql builds the query into a SQL string and bound args. When adds "WHEN ... THEN ..." part to CASE construct T : Sqlizer func Case(what ...interface{}) CaseBuilder func CaseBuilder.Else(expr interface{}) CaseBuilder func CaseBuilder.When(when interface{}, then interface{}) CaseBuilder
DBProxy groups the Execer, Queryer, QueryRower, and Preparer interfaces. ( T) Exec(query string, args ...interface{}) (sql.Result, error) ( T) Prepare(query string) (*sql.Stmt, error) ( T) Query(query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRow(query string, args ...interface{}) RowScanner DBProxyBeginner (interface) DBProxyContext (interface) *StmtCache T : BaseRunner T : Execer T : Preparer T : Queryer T : QueryRower T : Runner
( T) Begin() (*sql.Tx, error) ( T) Exec(query string, args ...interface{}) (sql.Result, error) ( T) Prepare(query string) (*sql.Stmt, error) ( T) Query(query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRow(query string, args ...interface{}) RowScanner T : BaseRunner T : DBProxy T : Execer T : Preparer T : Queryer T : QueryRower T : Runner func NewStmtCacheProxy(db *sql.DB) DBProxyBeginner
DBProxyContext groups the Execer, Queryer, QueryRower and PreparerContext interfaces. ( T) Exec(query string, args ...interface{}) (sql.Result, error) ( T) Prepare(query string) (*sql.Stmt, error) ( T) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) ( T) Query(query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRow(query string, args ...interface{}) RowScanner *StmtCache T : BaseRunner T : DBProxy T : Execer T : Preparer T : PreparerContext T : Queryer T : QueryRower T : Runner func NewStmtCacher(prep PreparerContext) DBProxyContext
DeleteBuilder builds SQL DELETE statements. Exec builds and Execs the query with the Runner set by RunWith. ExecContext builds and ExecContexts the query with the Runner set by RunWith. From sets the table to be deleted from. Limit sets a LIMIT clause on the query. Offset sets a OFFSET clause on the query. OrderBy adds ORDER BY expressions to the query. PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query. Prefix adds an expression to the beginning of the query PrefixExpr adds an expression to the very beginning of the query ( T) Query() (*sql.Rows, error) QueryContext builds and QueryContexts the query with the Runner set by RunWith. QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith. RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec. ScanContext is a shortcut for QueryRowContext().Scan. Suffix adds an expression to the end of the query SuffixExpr adds an expression to the end of the query ToSql builds the query into a SQL string and bound args. Where adds WHERE expressions to the query. See SelectBuilder.Where for more information. T : Sqlizer func Delete(from string) DeleteBuilder func DeleteBuilder.From(from string) DeleteBuilder func DeleteBuilder.Limit(limit uint64) DeleteBuilder func DeleteBuilder.Offset(offset uint64) DeleteBuilder func DeleteBuilder.OrderBy(orderBys ...string) DeleteBuilder func DeleteBuilder.PlaceholderFormat(f PlaceholderFormat) DeleteBuilder func DeleteBuilder.Prefix(sql string, args ...interface{}) DeleteBuilder func DeleteBuilder.PrefixExpr(expr Sqlizer) DeleteBuilder func DeleteBuilder.RunWith(runner BaseRunner) DeleteBuilder func DeleteBuilder.Suffix(sql string, args ...interface{}) DeleteBuilder func DeleteBuilder.SuffixExpr(expr Sqlizer) DeleteBuilder func DeleteBuilder.Where(pred interface{}, args ...interface{}) DeleteBuilder func StatementBuilderType.Delete(from string) DeleteBuilder
Eq is syntactic sugar for use with Where/Having/Set methods. ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
Execer is the interface that wraps the Exec method. Exec executes the given query as implemented by database/sql.Exec. ( T) Exec(query string, args ...interface{}) (sql.Result, error) BaseRunner (interface) DBProxy (interface) DBProxyBeginner (interface) DBProxyContext (interface) Runner (interface) RunnerContext (interface) StdSql (interface) StdSqlCtx (interface) *StmtCache *database/sql.DB *database/sql.Tx func ExecWith(db Execer, s Sqlizer) (res sql.Result, err error)
ExecerContext is the interface that wraps the ExecContext method. Exec executes the given query as implemented by database/sql.ExecContext. ( T) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) RunnerContext (interface) StdSqlCtx (interface) *StmtCache *database/sql.Conn *database/sql.DB *database/sql.Tx func ExecContextWith(ctx context.Context, db ExecerContext, s Sqlizer) (res sql.Result, err error)
Gt is syntactic sugar for use with Where/Having/Set methods. Ex: .Where(Gt{"id": 1}) == "id > 1" ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
GtOrEq is syntactic sugar for use with Where/Having/Set methods. Ex: .Where(GtOrEq{"id": 1}) == "id >= 1" ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
ILike is syntactic sugar for use with ILIKE conditions. Ex: .Where(ILike{"name": "sq%"}) ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
InsertBuilder builds SQL INSERT statements. Columns adds insert columns to the query. Exec builds and Execs the query with the Runner set by RunWith. ExecContext builds and ExecContexts the query with the Runner set by RunWith. Into sets the INTO clause of the query. Options adds keyword options before the INTO clause of the query. PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query. Prefix adds an expression to the beginning of the query PrefixExpr adds an expression to the very beginning of the query Query builds and Querys the query with the Runner set by RunWith. QueryContext builds and QueryContexts the query with the Runner set by RunWith. QueryRow builds and QueryRows the query with the Runner set by RunWith. QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith. RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec. Scan is a shortcut for QueryRow().Scan. ScanContext is a shortcut for QueryRowContext().Scan. Select set Select clause for insert query If Values and Select are used, then Select has higher priority 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 Suffix adds an expression to the end of the query SuffixExpr adds an expression to the end of the query ToSql builds the query into a SQL string and bound args. Values adds a single row's values to the query. T : RowScanner T : Sqlizer T : github.com/jackc/pgx/v4.Row func Insert(into string) InsertBuilder func Replace(into string) InsertBuilder func InsertBuilder.Columns(columns ...string) InsertBuilder func InsertBuilder.Into(from string) InsertBuilder func InsertBuilder.Options(options ...string) InsertBuilder func InsertBuilder.PlaceholderFormat(f PlaceholderFormat) InsertBuilder func InsertBuilder.Prefix(sql string, args ...interface{}) InsertBuilder func InsertBuilder.PrefixExpr(expr Sqlizer) InsertBuilder func InsertBuilder.RunWith(runner BaseRunner) InsertBuilder func InsertBuilder.Select(sb SelectBuilder) InsertBuilder func InsertBuilder.SetMap(clauses map[string]interface{}) InsertBuilder func InsertBuilder.Suffix(sql string, args ...interface{}) InsertBuilder func InsertBuilder.SuffixExpr(expr Sqlizer) InsertBuilder func InsertBuilder.Values(values ...interface{}) InsertBuilder func StatementBuilderType.Insert(into string) InsertBuilder func StatementBuilderType.Replace(into string) InsertBuilder
Like is syntactic sugar for use with LIKE conditions. Ex: .Where(Like{"name": "%irrel"}) ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
Lt is syntactic sugar for use with Where/Having/Set methods. Ex: .Where(Lt{"id": 1}) ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
LtOrEq is syntactic sugar for use with Where/Having/Set methods. Ex: .Where(LtOrEq{"id": 1}) == "id <= 1" ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
NotEq is syntactic sugar for use with Where/Having/Set methods. Ex: .Where(NotEq{"id": 1}) == "id <> 1" ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
NotILike is syntactic sugar for use with ILIKE conditions. Ex: .Where(NotILike{"name": "sq%"}) ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
NotLike is syntactic sugar for use with LIKE conditions. Ex: .Where(NotLike{"name": "%irrel"}) ( T) ToSql() (sql string, args []interface{}, err error) T : Sqlizer
Or conjunction Sqlizers ( T) ToSql() (string, []interface{}, error) T : Sqlizer
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. ( T) ReplacePlaceholders(sql string) (string, error) func DeleteBuilder.PlaceholderFormat(f PlaceholderFormat) DeleteBuilder func InsertBuilder.PlaceholderFormat(f PlaceholderFormat) InsertBuilder func SelectBuilder.PlaceholderFormat(f PlaceholderFormat) SelectBuilder func StatementBuilderType.PlaceholderFormat(f PlaceholderFormat) StatementBuilderType func UpdateBuilder.PlaceholderFormat(f PlaceholderFormat) UpdateBuilder
Prepareer is the interface that wraps the Prepare method. Prepare executes the given query as implemented by database/sql.Prepare. ( T) Prepare(query string) (*sql.Stmt, error) DBProxy (interface) DBProxyBeginner (interface) DBProxyContext (interface) PreparerContext (interface) *StmtCache *database/sql.DB *database/sql.Tx
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. ( T) Prepare(query string) (*sql.Stmt, error) ( T) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) DBProxyContext (interface) *StmtCache *database/sql.DB *database/sql.Tx T : Preparer func NewStmtCache(prep PreparerContext) *StmtCache func NewStmtCacher(prep PreparerContext) DBProxyContext
Queryer is the interface that wraps the Query method. Query executes the given query as implemented by database/sql.Query. ( T) Query(query string, args ...interface{}) (*sql.Rows, error) BaseRunner (interface) DBProxy (interface) DBProxyBeginner (interface) DBProxyContext (interface) Runner (interface) RunnerContext (interface) StdSql (interface) StdSqlCtx (interface) *StmtCache *database/sql.DB *database/sql.Tx func QueryWith(db Queryer, s Sqlizer) (rows *sql.Rows, err error)
QueryerContext is the interface that wraps the QueryContext method. QueryContext executes the given query as implemented by database/sql.QueryContext. ( T) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) RunnerContext (interface) StdSqlCtx (interface) *StmtCache *database/sql.Conn *database/sql.DB *database/sql.Tx func QueryContextWith(ctx context.Context, db QueryerContext, s Sqlizer) (rows *sql.Rows, err error)
QueryRower is the interface that wraps the QueryRow method. QueryRow executes the given query as implemented by database/sql.QueryRow. ( T) QueryRow(query string, args ...interface{}) RowScanner DBProxy (interface) DBProxyBeginner (interface) DBProxyContext (interface) Runner (interface) RunnerContext (interface) *StmtCache func QueryRowWith(db QueryRower, s Sqlizer) RowScanner
QueryRowerContext is the interface that wraps the QueryRowContext method. QueryRowContext executes the given query as implemented by database/sql.QueryRowContext. ( T) QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner RunnerContext (interface) *StmtCache func QueryRowContextWith(ctx context.Context, db QueryRowerContext, s Sqlizer) RowScanner
Row wraps database/sql.Row to let squirrel return new errors on Scan. RowScanner RowScanner Scan returns Row.err or calls RowScanner.Scan. *T : RowScanner *T : github.com/jackc/pgx/v4.Row
RowScanner is the interface that wraps the Scan method. Scan behaves like database/sql.Row.Scan. ( T) Scan(...interface{}) error InsertBuilder *Row SelectBuilder UpdateBuilder github.com/jackc/pgx/v4.Row (interface) github.com/jackc/pgx/v4.Rows (interface) *database/sql.Row *database/sql.Rows T : github.com/jackc/pgx/v4.Row func QueryRowContextWith(ctx context.Context, db QueryRowerContext, s Sqlizer) RowScanner func QueryRowWith(db QueryRower, s Sqlizer) RowScanner func DBProxy.QueryRow(query string, args ...interface{}) RowScanner func DBProxyBeginner.QueryRow(query string, args ...interface{}) RowScanner func DBProxyContext.QueryRow(query string, args ...interface{}) RowScanner func DeleteBuilder.QueryRowContext(ctx context.Context) RowScanner func InsertBuilder.QueryRow() RowScanner func InsertBuilder.QueryRowContext(ctx context.Context) RowScanner func QueryRower.QueryRow(query string, args ...interface{}) RowScanner func QueryRowerContext.QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner func Runner.QueryRow(query string, args ...interface{}) RowScanner func RunnerContext.QueryRow(query string, args ...interface{}) RowScanner func RunnerContext.QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner func SelectBuilder.QueryRow() RowScanner func SelectBuilder.QueryRowContext(ctx context.Context) RowScanner func (*StmtCache).QueryRow(query string, args ...interface{}) RowScanner func (*StmtCache).QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner func UpdateBuilder.QueryRow() RowScanner func UpdateBuilder.QueryRowContext(ctx context.Context) RowScanner
Runner groups the Execer, Queryer, and QueryRower interfaces. ( T) Exec(query string, args ...interface{}) (sql.Result, error) ( T) Query(query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRow(query string, args ...interface{}) RowScanner DBProxy (interface) DBProxyBeginner (interface) DBProxyContext (interface) RunnerContext (interface) *StmtCache T : BaseRunner T : Execer T : Queryer T : QueryRower func WrapStdSql(stdSql StdSql) Runner
RunnerContext groups the Runner interface, along with the Contect versions of each of its methods ( T) Exec(query string, args ...interface{}) (sql.Result, error) ( T) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) ( T) Query(query string, args ...interface{}) (*sql.Rows, error) ( T) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) ( T) QueryRow(query string, args ...interface{}) RowScanner ( T) QueryRowContext(ctx context.Context, query string, args ...interface{}) RowScanner *StmtCache T : BaseRunner T : Execer T : ExecerContext T : Queryer T : QueryerContext T : QueryRower T : QueryRowerContext T : Runner func WrapStdSqlCtx(stdSqlCtx StdSqlCtx) RunnerContext
SelectBuilder builds SQL SELECT statements. 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) Columns adds result columns to the query. Distinct adds a DISTINCT clause to the query. Exec builds and Execs the query with the Runner set by RunWith. ExecContext builds and ExecContexts the query with the Runner set by RunWith. From sets the FROM clause of the query. FromSelect sets a subquery into the FROM clause of the query. GroupBy adds GROUP BY expressions to the query. Having adds an expression to the HAVING clause of the query. See Where. Join adds a JOIN clause to the query. JoinClause adds a join clause to the query. LeftJoin adds a LEFT JOIN clause to the query. Limit sets a LIMIT clause on the query. ( T) MustSql() (string, []interface{}) Offset sets a OFFSET clause on the query. Options adds select option to the query OrderBy adds ORDER BY expressions to the query. OrderByClause adds ORDER BY clause to the query. PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query. Prefix adds an expression to the beginning of the query PrefixExpr adds an expression to the very beginning of the query Query builds and Querys the query with the Runner set by RunWith. QueryContext builds and QueryContexts the query with the Runner set by RunWith. QueryRow builds and QueryRows the query with the Runner set by RunWith. QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith. Limit ALL allows to access all records with limit RemoveOffset removes OFFSET clause. RightJoin adds a RIGHT JOIN clause to the query. RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec. For most cases runner will be a database connection. Internally we use this to mock out the database connection for testing. Scan is a shortcut for QueryRow().Scan. ScanContext is a shortcut for QueryRowContext().Scan. Suffix adds an expression to the end of the query SuffixExpr adds an expression to the end of the query ToSql builds the query into a SQL string and bound args. 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. T : RowScanner T : Sqlizer T : github.com/jackc/pgx/v4.Row func Select(columns ...string) SelectBuilder func SelectBuilder.Column(column interface{}, args ...interface{}) SelectBuilder func SelectBuilder.Columns(columns ...string) SelectBuilder func SelectBuilder.Distinct() SelectBuilder func SelectBuilder.From(from string) SelectBuilder func SelectBuilder.FromSelect(from SelectBuilder, alias string) SelectBuilder func SelectBuilder.GroupBy(groupBys ...string) SelectBuilder func SelectBuilder.Having(pred interface{}, rest ...interface{}) SelectBuilder func SelectBuilder.Join(join string, rest ...interface{}) SelectBuilder func SelectBuilder.JoinClause(pred interface{}, args ...interface{}) SelectBuilder func SelectBuilder.LeftJoin(join string, rest ...interface{}) SelectBuilder func SelectBuilder.Limit(limit uint64) SelectBuilder func SelectBuilder.Offset(offset uint64) SelectBuilder func SelectBuilder.Options(options ...string) SelectBuilder func SelectBuilder.OrderBy(orderBys ...string) SelectBuilder func SelectBuilder.OrderByClause(pred interface{}, args ...interface{}) SelectBuilder func SelectBuilder.PlaceholderFormat(f PlaceholderFormat) SelectBuilder func SelectBuilder.Prefix(sql string, args ...interface{}) SelectBuilder func SelectBuilder.PrefixExpr(expr Sqlizer) SelectBuilder func SelectBuilder.RemoveLimit() SelectBuilder func SelectBuilder.RemoveOffset() SelectBuilder func SelectBuilder.RightJoin(join string, rest ...interface{}) SelectBuilder func SelectBuilder.RunWith(runner BaseRunner) SelectBuilder func SelectBuilder.Suffix(sql string, args ...interface{}) SelectBuilder func SelectBuilder.SuffixExpr(expr Sqlizer) SelectBuilder func SelectBuilder.Where(pred interface{}, args ...interface{}) SelectBuilder func StatementBuilderType.Select(columns ...string) SelectBuilder func InsertBuilder.Select(sb SelectBuilder) InsertBuilder func SelectBuilder.FromSelect(from SelectBuilder, alias string) SelectBuilder
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. ( T) ToSql() (string, []interface{}, error) And CaseBuilder DeleteBuilder Eq Gt GtOrEq ILike InsertBuilder Like Lt LtOrEq NotEq NotILike NotLike Or SelectBuilder UpdateBuilder func Expr(sql string, args ...interface{}) Sqlizer func Alias(expr Sqlizer, alias string) aliasExpr func DebugSqlizer(s Sqlizer) string func ExecContextWith(ctx context.Context, db ExecerContext, s Sqlizer) (res sql.Result, err error) func ExecWith(db Execer, s Sqlizer) (res sql.Result, err error) func QueryContextWith(ctx context.Context, db QueryerContext, s Sqlizer) (rows *sql.Rows, err error) func QueryRowContextWith(ctx context.Context, db QueryRowerContext, s Sqlizer) RowScanner func QueryRowWith(db QueryRower, s Sqlizer) RowScanner func QueryWith(db Queryer, s Sqlizer) (rows *sql.Rows, err error) func DeleteBuilder.PrefixExpr(expr Sqlizer) DeleteBuilder func DeleteBuilder.SuffixExpr(expr Sqlizer) DeleteBuilder func InsertBuilder.PrefixExpr(expr Sqlizer) InsertBuilder func InsertBuilder.SuffixExpr(expr Sqlizer) InsertBuilder func SelectBuilder.PrefixExpr(expr Sqlizer) SelectBuilder func SelectBuilder.SuffixExpr(expr Sqlizer) SelectBuilder func UpdateBuilder.PrefixExpr(expr Sqlizer) UpdateBuilder func UpdateBuilder.SuffixExpr(expr Sqlizer) UpdateBuilder
StatementBuilderType is the type of StatementBuilder. Delete returns a DeleteBuilder for this StatementBuilderType. Insert returns a InsertBuilder for this StatementBuilderType. PlaceholderFormat sets the PlaceholderFormat field for any child builders. Replace returns a InsertBuilder for this StatementBuilderType with the statement keyword set to "REPLACE". RunWith sets the RunWith field for any child builders. Select returns a SelectBuilder for this StatementBuilderType. Update returns a UpdateBuilder for this StatementBuilderType. Where adds WHERE expressions to the query. See SelectBuilder.Where for more information. func StatementBuilderType.PlaceholderFormat(f PlaceholderFormat) StatementBuilderType func StatementBuilderType.RunWith(runner BaseRunner) StatementBuilderType func StatementBuilderType.Where(pred interface{}, args ...interface{}) StatementBuilderType var StatementBuilder
StdSql encompasses the standard methods of the *sql.DB type, and other types that wrap these methods. ( T) Exec(string, ...interface{}) (sql.Result, error) ( T) Query(string, ...interface{}) (*sql.Rows, error) ( T) QueryRow(string, ...interface{}) *sql.Row StdSqlCtx (interface) *database/sql.DB *database/sql.Tx T : BaseRunner T : Execer T : Queryer func WrapStdSql(stdSql StdSql) Runner
StdSqlCtx encompasses the standard methods of the *sql.DB type, along with the Context versions of those methods, and other types that wrap these methods. ( T) Exec(string, ...interface{}) (sql.Result, error) ( T) ExecContext(context.Context, string, ...interface{}) (sql.Result, error) ( T) Query(string, ...interface{}) (*sql.Rows, error) ( T) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) ( T) QueryRow(string, ...interface{}) *sql.Row ( T) QueryRowContext(context.Context, string, ...interface{}) *sql.Row *database/sql.DB *database/sql.Tx T : BaseRunner T : Execer T : ExecerContext T : Queryer T : QueryerContext T : StdSql func WrapStdSqlCtx(stdSqlCtx StdSqlCtx) RunnerContext
StmtCache wraps and delegates down to a Preparer type It also automatically prepares all statements sent to the underlying Preparer calls for Exec, Query and QueryRow and caches the returns *sql.Stmt using the provided query as the key. So that it can be automatically re-used. Clear removes and closes all the currently cached prepared statements Exec delegates down to the underlying Preparer using a prepared statement ExecContext delegates down to the underlying PreparerContext using a prepared statement Prepare delegates down to the underlying Preparer and caches the result using the provided query as a key PrepareContext delegates down to the underlying PreparerContext and caches the result using the provided query as a key Query delegates down to the underlying Preparer using a prepared statement QueryContext delegates down to the underlying PreparerContext using a prepared statement QueryRow delegates down to the underlying Preparer using a prepared statement QueryRowContext delegates down to the underlying PreparerContext using a prepared statement *T : BaseRunner *T : DBProxy *T : DBProxyContext *T : Execer *T : ExecerContext *T : Preparer *T : PreparerContext *T : Queryer *T : QueryerContext *T : QueryRower *T : QueryRowerContext *T : Runner *T : RunnerContext func NewStmtCache(prep PreparerContext) *StmtCache
UpdateBuilder builds SQL UPDATE statements. Exec builds and Execs the query with the Runner set by RunWith. ExecContext builds and ExecContexts the query with the Runner set by RunWith. Limit sets a LIMIT clause on the query. Offset sets a OFFSET clause on the query. OrderBy adds ORDER BY expressions to the query. PlaceholderFormat sets PlaceholderFormat (e.g. Question or Dollar) for the query. Prefix adds an expression to the beginning of the query PrefixExpr adds an expression to the very beginning of the query ( T) Query() (*sql.Rows, error) QueryContext builds and QueryContexts the query with the Runner set by RunWith. ( T) QueryRow() RowScanner QueryRowContext builds and QueryRowContexts the query with the Runner set by RunWith. RunWith sets a Runner (like database/sql.DB) to be used with e.g. Exec. ( T) Scan(dest ...interface{}) error ScanContext is a shortcut for QueryRowContext().Scan. Set adds SET clauses to the query. SetMap is a convenience method which calls .Set for each key/value pair in clauses. Suffix adds an expression to the end of the query SuffixExpr adds an expression to the end of the query Table sets the table to be updated. ToSql builds the query into a SQL string and bound args. Where adds WHERE expressions to the query. See SelectBuilder.Where for more information. T : RowScanner T : Sqlizer T : github.com/jackc/pgx/v4.Row func Update(table string) UpdateBuilder func StatementBuilderType.Update(table string) UpdateBuilder func UpdateBuilder.Limit(limit uint64) UpdateBuilder func UpdateBuilder.Offset(offset uint64) UpdateBuilder func UpdateBuilder.OrderBy(orderBys ...string) UpdateBuilder func UpdateBuilder.PlaceholderFormat(f PlaceholderFormat) UpdateBuilder func UpdateBuilder.Prefix(sql string, args ...interface{}) UpdateBuilder func UpdateBuilder.PrefixExpr(expr Sqlizer) UpdateBuilder func UpdateBuilder.RunWith(runner BaseRunner) UpdateBuilder func UpdateBuilder.Set(column string, value interface{}) UpdateBuilder func UpdateBuilder.SetMap(clauses map[string]interface{}) UpdateBuilder func UpdateBuilder.Suffix(sql string, args ...interface{}) UpdateBuilder func UpdateBuilder.SuffixExpr(expr Sqlizer) UpdateBuilder func UpdateBuilder.Table(table string) UpdateBuilder func UpdateBuilder.Where(pred interface{}, args ...interface{}) UpdateBuilder
Package-Level Functions (total 35, in which 22 are exported)
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"))
Case returns a new CaseBuilder "what" represents case value
ConcatExpr builds an expression by concatenating strings and other expressions. Ex: name_expr := Expr("CONCAT(?, ' ', ?)", firstName, lastName) ConcatExpr("COALESCE(full_name,", name_expr, ")")
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.
Delete returns a new DeleteBuilder with the given table name. See DeleteBuilder.Table.
ExecContextWith ExecContexts the SQL returned by s with db.
ExecWith Execs the SQL returned by s with db.
Expr builds an expression from a SQL fragment and arguments. Ex: Expr("FROM_UNIXTIME(?)", t)
Insert returns a new InsertBuilder with the given table name. See InsertBuilder.Into.
NewStmtCache returns a *StmtCache wrapping a PreparerContext that caches Prepared Stmts. Stmts are cached based on the string value of their queries.
NewStmtCacher is deprecated Use NewStmtCache instead
Placeholders returns a string with count ? placeholders joined with commas.
QueryContextWith QueryContexts the SQL returned by s with db.
QueryRowContextWith QueryRowContexts the SQL returned by s with db.
QueryRowWith QueryRows the SQL returned by s with db.
QueryWith Querys the SQL returned by s with db.
Replace returns a new InsertBuilder with the statement keyword set to "REPLACE" and with the given table name. See InsertBuilder.Into.
Select returns a new SelectBuilder, optionally setting some result columns. See SelectBuilder.Columns.
Update returns a new UpdateBuilder with the given table name. See UpdateBuilder.Table.
WrapStdSql wraps a type implementing the standard SQL interface with methods that squirrel expects.
WrapStdSqlCtx wraps a type implementing the standard SQL interface plus the context versions of the methods with methods that squirrel expects.
Package-Level Variables (total 8, all are exported)
AtP is a PlaceholderFormat instance that replaces placeholders with "@p"-prefixed positional placeholders (e.g. @p1, @p2, @p3).
Colon is a PlaceholderFormat instance that replaces placeholders with colon-prefixed positional placeholders (e.g. :1, :2, :3).
Dollar is a PlaceholderFormat instance that replaces placeholders with dollar-prefixed positional placeholders (e.g. $1, $2, $3).
NoContextSupport is returned if a db doesn't support Context.
Question is a PlaceholderFormat instance that leaves placeholders as question marks.
RunnerNotQueryRunner is returned by QueryRow if the RunWith value doesn't implement QueryRower.
RunnerNotSet is returned by methods that need a Runner if it isn't set.
StatementBuilder is a parent builder for other builders, e.g. SelectBuilder.
Package-Level Constants (total 2, neither is exported)