Documentation ¶
Overview ¶
Package dber is an interfaceization of database/sql.DB. It even implements a wrapper for *sql.DB: SqlDBer.
Index ¶
- Constants
- Variables
- type DBer
- type Execer
- type Mock
- type Preparer
- type Queryer
- type ResultMock
- type Rowser
- type Scanner
- type SqlDBer
- func (db SqlDBer) Begin() (Txer, error)
- func (db SqlDBer) BeginTx(ctx context.Context, opt *sql.TxOptions) (Txer, error)
- func (db SqlDBer) Query(qry string, args ...interface{}) (Rowser, error)
- func (db SqlDBer) QueryContext(ctx context.Context, qry string, args ...interface{}) (Rowser, error)
- func (db SqlDBer) QueryRow(qry string, args ...interface{}) Scanner
- func (db SqlDBer) QueryRowContext(ctx context.Context, qry string, args ...interface{}) Scanner
- type SqlRowser
- type SqlScanner
- type SqlTxer
- func (tx SqlTxer) PrepareContext(ctx context.Context, qry string) (*sql.Stmt, error)
- func (tx SqlTxer) Query(qry string, args ...interface{}) (Rowser, error)
- func (tx SqlTxer) QueryContext(ctx context.Context, qry string, args ...interface{}) (Rowser, error)
- func (tx SqlTxer) QueryRow(qry string, args ...interface{}) Scanner
- func (tx SqlTxer) QueryRowContext(ctx context.Context, qry string, args ...interface{}) Scanner
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Exec(qry string, params ...interface{}) (sql.Result, error)
- func (tx *Tx) ExecContext(ctx context.Context, qry string, params ...interface{}) (sql.Result, error)
- func (p *Tx) ExpectQuery(qry string) Mock
- func (tx *Tx) PrepAndExe(qry string, params ...interface{}) (uint64, error)
- func (p *Tx) PrepareContext(_ context.Context, _ string) (*sql.Stmt, error)
- func (tx *Tx) Query(qry string, params ...interface{}) (Rowser, error)
- func (tx *Tx) QueryContext(ctx context.Context, qry string, params ...interface{}) (Rowser, error)
- func (tx *Tx) QueryRow(qry string, params ...interface{}) Scanner
- func (tx *Tx) QueryRowContext(ctx context.Context, qry string, params ...interface{}) Scanner
- func (tx *Tx) Rollback() error
- type TxState
- type Txer
Constants ¶
View Source
const ( TxUndecided = TxState(iota) TxRolledBack TxCommited )
View Source
const ExpectAny = "{{ExpectAny}}"
Variables ¶
View Source
var ( Debug = func(string, ...interface{}) {} ErrQueryMismatch = errors.New("query mismatch") ErrArgsMismatch = errors.New("args mismatch") ErrTxAlreadyRolledBack = errors.New("transaction already rolled back") ErrTxAlreadyCommited = errors.New("transaction already commited") ErrNotImplemented = errors.New("not implemented") )
Functions ¶
This section is empty.
Types ¶
type ResultMock ¶
type ResultMock struct {
ID, Affected int64
}
func (ResultMock) LastInsertId ¶
func (res ResultMock) LastInsertId() (int64, error)
func (ResultMock) RowsAffected ¶
func (res ResultMock) RowsAffected() (int64, error)
type SqlDBer ¶
SqlDBer is a wrapper for *sql.DB to implement DBer
func (SqlDBer) QueryContext ¶
type SqlScanner ¶
SqlScanner is a wrapper for *sql.Row to implement Scanner.
type SqlTxer ¶
SqlTxer is a wrapper for *sql.Tx to implement Txer
func (SqlTxer) PrepareContext ¶
func (SqlTxer) QueryContext ¶
type Tx ¶
type Tx struct { Expects []*expectQuery // contains filtered or unexported fields }
func (*Tx) ExecContext ¶
func (*Tx) ExpectQuery ¶
ExpectQuery adds the query to the list of expected queries. Iff the query starts and ends with "/", it is treated as a regexp, otherwise as plain text.
func (*Tx) PrepareContext ¶
func (*Tx) QueryContext ¶
func (*Tx) QueryRowContext ¶
Click to show internal directories.
Click to hide internal directories.