transaction

package
v2.21.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Code generated by MockGen. DO NOT EDIT. Source: implementation.go

Generated by this command:

mockgen -source=implementation.go -package transaction -destination implementation.mock.gen.go

Package transaction is a generated GoMock package.

Code generated by MockGen. DO NOT EDIT. Source: namedstatement.go

Generated by this command:

mockgen -source=namedstatement.go -package transaction -destination namedstatement.mock.gen.go

Package transaction is a generated GoMock package.

Code generated by MockGen. DO NOT EDIT. Source: transaction.go

Generated by this command:

mockgen -source=transaction.go -package transaction -destination transaction.mock.gen.go

Package transaction is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Begin

type Begin interface {
	// Begin transaction on the underlying transactable datastructure and
	// return it
	Begin() (Implementation, error)
}

Begin has methods for starting transactions

type Implementation

type Implementation interface {
	// NamedQuery within a transaction.
	// Any named placeholder parameters are replaced with fields from arg.
	NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
	// NamedExec a named query within a transaction.
	// Any named placeholder parameters are replaced with fields from arg.
	NamedExec(query string, arg interface{}) (sql.Result, error)
	// QueryRowx within a transaction.
	// Any placeholder parameters are replaced with supplied args.
	QueryRowx(query string, args ...interface{}) *sqlx.Row
	// PrepareNamed returns a sqlx.NamedStatement that can be used
	// to execute the prepared statement using named parameters
	PrepareNamed(query string) (*sqlx.NamedStmt, error)
	// Preparex returns a sqlx.Stmt that can be used to avoid
	// the overhead of preparing the same statement when executing
	// many times
	Preparex(query string) (*sqlx.Stmt, error)
	// Select within a transaction.
	// Any placeholder parameters are replaced with supplied args.
	Select(dest interface{}, query string, args ...interface{}) error
	// Exec a query within a transaction.
	// Any named placeholder parameters are replaced with fields from arg.
	Exec(query string, args ...any) (sql.Result, error)
	// Commit this transaction
	Commit() error
	// Rollback this transaction
	Rollback() error
}

type MockImplementation

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

MockImplementation is a mock of Implementation interface.

func NewMockImplementation

func NewMockImplementation(ctrl *gomock.Controller) *MockImplementation

NewMockImplementation creates a new mock instance.

func (*MockImplementation) Commit

func (m *MockImplementation) Commit() error

Commit mocks base method.

func (*MockImplementation) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockImplementation) Exec

func (m *MockImplementation) Exec(query string, args ...any) (sql.Result, error)

Exec mocks base method.

func (*MockImplementation) NamedExec

func (m *MockImplementation) NamedExec(query string, arg any) (sql.Result, error)

NamedExec mocks base method.

func (*MockImplementation) NamedQuery

func (m *MockImplementation) NamedQuery(query string, arg any) (*sqlx.Rows, error)

NamedQuery mocks base method.

func (*MockImplementation) PrepareNamed added in v2.18.5

func (m *MockImplementation) PrepareNamed(query string) (*sqlx.NamedStmt, error)

PrepareNamed mocks base method.

func (*MockImplementation) Preparex added in v2.18.5

func (m *MockImplementation) Preparex(query string) (*sqlx.Stmt, error)

Preparex mocks base method.

func (*MockImplementation) QueryRowx

func (m *MockImplementation) QueryRowx(query string, args ...any) *sqlx.Row

QueryRowx mocks base method.

func (*MockImplementation) Rollback

func (m *MockImplementation) Rollback() error

Rollback mocks base method.

func (*MockImplementation) Select

func (m *MockImplementation) Select(dest any, query string, args ...any) error

Select mocks base method.

type MockImplementationMockRecorder

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

MockImplementationMockRecorder is the mock recorder for MockImplementation.

func (*MockImplementationMockRecorder) Commit

Commit indicates an expected call of Commit.

func (*MockImplementationMockRecorder) Exec

func (mr *MockImplementationMockRecorder) Exec(query any, args ...any) *gomock.Call

Exec indicates an expected call of Exec.

func (*MockImplementationMockRecorder) NamedExec

func (mr *MockImplementationMockRecorder) NamedExec(query, arg any) *gomock.Call

NamedExec indicates an expected call of NamedExec.

func (*MockImplementationMockRecorder) NamedQuery

func (mr *MockImplementationMockRecorder) NamedQuery(query, arg any) *gomock.Call

NamedQuery indicates an expected call of NamedQuery.

func (*MockImplementationMockRecorder) PrepareNamed added in v2.18.5

func (mr *MockImplementationMockRecorder) PrepareNamed(query any) *gomock.Call

PrepareNamed indicates an expected call of PrepareNamed.

func (*MockImplementationMockRecorder) Preparex added in v2.18.5

func (mr *MockImplementationMockRecorder) Preparex(query any) *gomock.Call

Preparex indicates an expected call of Preparex.

func (*MockImplementationMockRecorder) QueryRowx

func (mr *MockImplementationMockRecorder) QueryRowx(query any, args ...any) *gomock.Call

QueryRowx indicates an expected call of QueryRowx.

func (*MockImplementationMockRecorder) Rollback

func (mr *MockImplementationMockRecorder) Rollback() *gomock.Call

Rollback indicates an expected call of Rollback.

func (*MockImplementationMockRecorder) Select

func (mr *MockImplementationMockRecorder) Select(dest, query any, args ...any) *gomock.Call

Select indicates an expected call of Select.

type MockNamedStatement added in v2.18.5

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

MockNamedStatement is a mock of NamedStatement interface.

func NewMockNamedStatement added in v2.18.5

func NewMockNamedStatement(ctrl *gomock.Controller) *MockNamedStatement

NewMockNamedStatement creates a new mock instance.

func (*MockNamedStatement) Close added in v2.18.5

func (m *MockNamedStatement) Close() error

Close mocks base method.

func (*MockNamedStatement) EXPECT added in v2.18.5

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockNamedStatement) Exec added in v2.18.5

func (m *MockNamedStatement) Exec(arg any) (sql.Result, error)

Exec mocks base method.

func (*MockNamedStatement) Get added in v2.18.5

func (m *MockNamedStatement) Get(dest, arg any) error

Get mocks base method.

type MockNamedStatementMockRecorder added in v2.18.5

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

MockNamedStatementMockRecorder is the mock recorder for MockNamedStatement.

func (*MockNamedStatementMockRecorder) Close added in v2.18.5

Close indicates an expected call of Close.

func (*MockNamedStatementMockRecorder) Exec added in v2.18.5

Exec indicates an expected call of Exec.

func (*MockNamedStatementMockRecorder) Get added in v2.18.5

func (mr *MockNamedStatementMockRecorder) Get(dest, arg any) *gomock.Call

Get indicates an expected call of Get.

type MockTransaction

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

MockTransaction is a mock of Transaction interface.

func NewMockTransaction

func NewMockTransaction(ctrl *gomock.Controller) *MockTransaction

NewMockTransaction creates a new mock instance.

func (*MockTransaction) Commit

func (m *MockTransaction) Commit() errors.TracerError

Commit mocks base method.

func (*MockTransaction) Create

Create mocks base method.

func (*MockTransaction) Delete

Delete mocks base method.

func (*MockTransaction) DeleteWhere

DeleteWhere mocks base method.

func (*MockTransaction) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTransaction) Implementation

func (m *MockTransaction) Implementation() Implementation

Implementation mocks base method.

func (*MockTransaction) List

List mocks base method.

func (*MockTransaction) ListWhere

ListWhere mocks base method.

func (*MockTransaction) PrepareNamed added in v2.18.5

func (m *MockTransaction) PrepareNamed(query string) (NamedStatement, errors.TracerError)

PrepareNamed mocks base method.

func (*MockTransaction) Read

Read mocks base method.

func (*MockTransaction) ReadOneWhere

func (m *MockTransaction) ReadOneWhere(arg0 record.Record, arg1 *qb.ConditionExpression) errors.TracerError

ReadOneWhere mocks base method.

func (*MockTransaction) Rollback

func (m *MockTransaction) Rollback() errors.TracerError

Rollback mocks base method.

func (*MockTransaction) Select

func (m *MockTransaction) Select(arg0 any, arg1 *qb.SelectQuery, arg2 record.ListOptions) errors.TracerError

Select mocks base method.

func (*MockTransaction) Update

Update mocks base method.

func (*MockTransaction) UpdateWhere

func (m *MockTransaction) UpdateWhere(arg0 record.Record, arg1 *qb.ConditionExpression, arg2 ...qb.FieldValue) (int64, errors.TracerError)

UpdateWhere mocks base method.

func (*MockTransaction) Upsert

Upsert mocks base method.

type MockTransactionMockRecorder

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

MockTransactionMockRecorder is the mock recorder for MockTransaction.

func (*MockTransactionMockRecorder) Commit

func (mr *MockTransactionMockRecorder) Commit() *gomock.Call

Commit indicates an expected call of Commit.

func (*MockTransactionMockRecorder) Create

func (mr *MockTransactionMockRecorder) Create(arg0 any) *gomock.Call

Create indicates an expected call of Create.

func (*MockTransactionMockRecorder) Delete

func (mr *MockTransactionMockRecorder) Delete(arg0 any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockTransactionMockRecorder) DeleteWhere

func (mr *MockTransactionMockRecorder) DeleteWhere(arg0, arg1 any) *gomock.Call

DeleteWhere indicates an expected call of DeleteWhere.

func (*MockTransactionMockRecorder) Implementation

func (mr *MockTransactionMockRecorder) Implementation() *gomock.Call

Implementation indicates an expected call of Implementation.

func (*MockTransactionMockRecorder) List

func (mr *MockTransactionMockRecorder) List(arg0, arg1, arg2 any) *gomock.Call

List indicates an expected call of List.

func (*MockTransactionMockRecorder) ListWhere

func (mr *MockTransactionMockRecorder) ListWhere(arg0, arg1, arg2, arg3 any) *gomock.Call

ListWhere indicates an expected call of ListWhere.

func (*MockTransactionMockRecorder) PrepareNamed added in v2.18.5

func (mr *MockTransactionMockRecorder) PrepareNamed(query any) *gomock.Call

PrepareNamed indicates an expected call of PrepareNamed.

func (*MockTransactionMockRecorder) Read

func (mr *MockTransactionMockRecorder) Read(arg0, arg1 any) *gomock.Call

Read indicates an expected call of Read.

func (*MockTransactionMockRecorder) ReadOneWhere

func (mr *MockTransactionMockRecorder) ReadOneWhere(arg0, arg1 any) *gomock.Call

ReadOneWhere indicates an expected call of ReadOneWhere.

func (*MockTransactionMockRecorder) Rollback

func (mr *MockTransactionMockRecorder) Rollback() *gomock.Call

Rollback indicates an expected call of Rollback.

func (*MockTransactionMockRecorder) Select

func (mr *MockTransactionMockRecorder) Select(arg0, arg1, arg2 any) *gomock.Call

Select indicates an expected call of Select.

func (*MockTransactionMockRecorder) Update

func (mr *MockTransactionMockRecorder) Update(arg0 any) *gomock.Call

Update indicates an expected call of Update.

func (*MockTransactionMockRecorder) UpdateWhere

func (mr *MockTransactionMockRecorder) UpdateWhere(arg0, arg1 any, arg2 ...any) *gomock.Call

UpdateWhere indicates an expected call of UpdateWhere.

func (*MockTransactionMockRecorder) Upsert

func (mr *MockTransactionMockRecorder) Upsert(arg0 any) *gomock.Call

Upsert indicates an expected call of Upsert.

type NamedStatement added in v2.18.5

type NamedStatement interface {
	// Close closes the named statement.
	Close() error
	// Exec executes a named statement using the struct passed.
	// Any named placeholder parameters are replaced with fields from arg.
	Exec(arg interface{}) (sql.Result, error)
	// Get using this NamedStmt
	// Any named placeholder parameters are replaced with fields from arg.
	Get(dest interface{}, arg interface{}) error
}

NamedStatement is a prepared statement that executes named queries. Prepare it how you would execute a NamedQuery, but pass in a struct or map when executing. Not all method represented, see: sqlx@1.3.5/named.go

type Transaction

type Transaction interface {
	utility.CommitRollback
	// Create initializes a Record and inserts it into the Database
	Create(record.Record) errors.TracerError
	// Upsert a new entry into the database for the Record
	Upsert(record.Record) errors.TracerError
	// Read populates a Record from the database
	Read(record.Record, record.PrimaryKeyValue) errors.TracerError
	// ReadOneWhere populates a Record from a custom where clause
	ReadOneWhere(record.Record, *qb.ConditionExpression) errors.TracerError
	// List populates obj with a list of Records from the database
	// TODO: [COR-586] we can expand the Record interface to return an collection
	// 		 of its type so we don't have to pass this clumsily
	List(record.Record, any, record.ListOptions) errors.TracerError
	// ListWhere populates target with a list of Records from the database
	// TODO: [COR-586] we can expand the Record interface to return a collection
	// 		 of its type so we don't have to pass this clumsily
	ListWhere(record.Record, any, *qb.ConditionExpression, record.ListOptions) errors.TracerError
	// Select executes a given select query and populates the target
	// TODO: [COR-586] we can expand the Record interface to return a collection
	// 		 of its type so we don't have to pass this clumsily
	Select(any, *qb.SelectQuery, record.ListOptions) errors.TracerError
	// Update replaces an entry in the database for the Record
	Update(record.Record) errors.TracerError
	// UpdateWhere updates fields for the Record based on a supplied where clause in a transaction
	UpdateWhere(record.Record, *qb.ConditionExpression, ...qb.FieldValue) (int64, errors.TracerError)
	// Delete removes a row from the database
	Delete(record.Record) errors.TracerError
	// DeleteWhere removes row(s) from the database based on a supplied where clause
	DeleteWhere(record.Record, *qb.ConditionExpression) errors.TracerError
	// PrepareNamed returns a NamedStatement that can be used
	// to execute the prepared statement using named parameters
	PrepareNamed(query string) (NamedStatement, errors.TracerError)
	// Implementation that is backing this transaction
	Implementation() Implementation
}

Transaction is an in-progress database transaction.

A transaction must end with a call to Commit or Rollback.

After a call to Commit or Rollback, all operations on the transaction fail with ErrTxDone.

func New

func New(db Begin, logger log.Logger, slow time.Duration,
	loggedQueries map[string]time.Duration) (Transaction, error)

New transaction that will log query executions that are slower than the passed duration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL