mogi: github.com/guregu/mogi Index | Files | Directories

package mogi

import "github.com/guregu/mogi"

Index

Package Files

cond.go conn.go delete.go driver.go execstub.go input.go insert.go magic.go mogi.go rows.go select.go stmt.go stub.go tx.go unify.go update.go where.go

Variables

var (
    // ErrUnstubbed is returned as the result for unstubbed queries.
    ErrUnstubbed = errors.New("mogi: query not stubbed")
    // ErrUnresolved is returned as the result of a stub that was matched,
    // but whose data could not be resolved. For example, exceeded LIMITs.
    ErrUnresolved = errors.New("mogi: query matched but no stub data")
)

func Dump Uses

func Dump()

Dump prints all the current stubs, in order of priority. Helpful for debugging.

func ParseTime Uses

func ParseTime(layout string)

ParseTime will configure mogi to convert dates of the given layout (e.g. time.RFC3339) to time.Time when using StubCSV. Give it an empty string to turn off time parsing.

func Reset Uses

func Reset()

Reset removes all the stubs that have been set

func Verbose Uses

func Verbose(v bool)

Verbose turns on unstubbed logging when v is true

type ExecStub Uses

type ExecStub struct {
    // contains filtered or unexported fields
}

ExecStub is a SQL exec stub (for INSERT, UPDATE, DELETE)

func Delete Uses

func Delete() *ExecStub

Delete starts a new stub for DELETE statements.

func Insert Uses

func Insert(cols ...string) *ExecStub

Insert starts a new stub for INSERT statements. You can filter out which columns to use this stub for. If you don't pass any columns, it will stub all INSERT queries.

func Update Uses

func Update(cols ...string) *ExecStub

Update starts a new stub for UPDATE statements. You can filter out which columns (from the SET statement) this stub is for. If you don't pass any columns, it will stub all UPDATE queries.

func (*ExecStub) Args Uses

func (s *ExecStub) Args(args ...driver.Value) *ExecStub

Args further filters this stub, matching based on the args passed to the query

func (*ExecStub) Dump Uses

func (s *ExecStub) Dump() *ExecStub

Dump outputs debug information, without performing any matching.

func (*ExecStub) From Uses

func (s *ExecStub) From(table string) *ExecStub

From further filters this stub, matching based on the FROM table specified.

func (*ExecStub) Into Uses

func (s *ExecStub) Into(table string) *ExecStub

Into further filters this stub, matching based on the INTO table specified.

func (*ExecStub) Notify Uses

func (s *ExecStub) Notify(ch chan<- struct{}) *ExecStub

Notify will have this stub send to the given channel when matched. You should put this as the last part of your stub chain.

func (*ExecStub) Priority Uses

func (s *ExecStub) Priority(p int) *ExecStub

Priority adds the given priority to this stub, without performing any matching.

func (*ExecStub) Stub Uses

func (s *ExecStub) Stub(res driver.Result)

Stub takes a driver.Result and registers this stub with the driver

func (*ExecStub) StubError Uses

func (s *ExecStub) StubError(err error)

StubError takes an error and registers this stub with the driver

func (*ExecStub) StubResult Uses

func (s *ExecStub) StubResult(lastInsertID, rowsAffected int64)

StubResult is an easy way to stub a driver.Result. Given a value of -1, the result will return an error for that particular part.

func (*ExecStub) StubRowsAffected Uses

func (s *ExecStub) StubRowsAffected(rowsAffected int64)

StubRowsAffected is an easy way to stub a driver.Result when you only need to specify the rows affected.

func (*ExecStub) Table Uses

func (s *ExecStub) Table(table string) *ExecStub

Table further filters this stub, matching the target table in INSERT, UPDATE, or DELETE.

func (*ExecStub) Value Uses

func (s *ExecStub) Value(col string, v interface{}) *ExecStub

Value further filters this stub, matching based on values supplied to the query For INSERTs, it matches the first row of values, so it is a shortcut for ValueAt(0, ...) For UPDATEs, it matches on the SET clause.

func (*ExecStub) ValueAt Uses

func (s *ExecStub) ValueAt(row int, col string, v interface{}) *ExecStub

ValueAt further filters this stub, matching based on values supplied to the query

func (*ExecStub) Where Uses

func (s *ExecStub) Where(col string, v ...interface{}) *ExecStub

Where further filters this stub by values of input in the WHERE clause. You can pass multiple values for IN clause matching.

func (*ExecStub) WhereOp Uses

func (s *ExecStub) WhereOp(col string, operator string, v ...interface{}) *ExecStub

WhereOp further filters this stub by values of input and the operator used in the WHERE clause.

type Stub Uses

type Stub struct {
    // contains filtered or unexported fields
}

Stub is a SQL query stub (for SELECT)

func Select Uses

func Select(cols ...string) *Stub

Select starts a new stub for SELECT statements. You can filter out which columns to use this stub for. If you don't pass any columns, it will stub all SELECT queries.

func (*Stub) Args Uses

func (s *Stub) Args(args ...driver.Value) *Stub

Args further filters this stub, matching based on the args passed to the query

func (*Stub) Dump Uses

func (s *Stub) Dump() *Stub

Dump outputs debug information, without performing any matching.

func (*Stub) From Uses

func (s *Stub) From(tables ...string) *Stub

From further filters this stub by table names in the FROM and JOIN clauses (in order). You need to give it the un-aliased table names.

func (*Stub) Notify Uses

func (s *Stub) Notify(ch chan<- struct{}) *Stub

Notify will have this stub send to the given channel when matched. You should put this as the last part of your stub chain.

func (*Stub) Priority Uses

func (s *Stub) Priority(p int) *Stub

Priority adds the given priority to this stub, without performing any matching.

func (*Stub) Stub Uses

func (s *Stub) Stub(rows [][]driver.Value)

Stub takes row data and registers this stub with the driver

func (*Stub) StubCSV Uses

func (s *Stub) StubCSV(data string)

StubCSV takes CSV data and registers this stub with the driver

func (*Stub) StubError Uses

func (s *Stub) StubError(err error)

StubError registers this stub to return the given error

func (*Stub) Subquery Uses

func (s *Stub) Subquery() subquery

func (*Stub) Where Uses

func (s *Stub) Where(col string, v ...interface{}) *Stub

Where further filters this stub by values of input in the WHERE clause. You can pass multiple values for IN clause matching.

func (*Stub) WhereOp Uses

func (s *Stub) WhereOp(col string, operator string, v ...interface{}) *Stub

WhereOp further filters this stub by values of input and the operator used in the WHERE clause.

Directories

PathSynopsis
internal/proto/queryPackage query is a generated protocol buffer package.
internal/sqlparser
internal/sqltypesPackage sqltypes implements interfaces and types that represent SQL values.

Package mogi imports 16 packages (graph). Updated 2018-10-10. Refresh now. Tools for package owners.