Documentation
¶
Overview ¶
Package sqlutils is a generated GoMock package.
Index ¶
- Constants
- func IsUniqueViolation(err error) bool
- func IsUniqueViolationByField(err error, field string) bool
- func Sorting(field, direction string) string
- func WithTx[R any](ctx context.Context, db SQLDB, f func(q SQLTX) (R, error)) (R, error)
- type MockQuerier
- func (m *MockQuerier) EXPECT() *MockQuerierMockRecorder
- func (m *MockQuerier) Exec(query string, args ...any) (sql.Result, error)
- func (m *MockQuerier) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (m *MockQuerier) Prepare(query string) (*sql.Stmt, error)
- func (m *MockQuerier) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
- func (m *MockQuerier) Query(query string, args ...any) (*sql.Rows, error)
- func (m *MockQuerier) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (m *MockQuerier) QueryRow(query string, args ...any) *sql.Row
- func (m *MockQuerier) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
- type MockQuerierMockRecorder
- func (mr *MockQuerierMockRecorder) Exec(query any, args ...any) *gomock.Call
- func (mr *MockQuerierMockRecorder) ExecContext(ctx, query any, args ...any) *gomock.Call
- func (mr *MockQuerierMockRecorder) Prepare(query any) *gomock.Call
- func (mr *MockQuerierMockRecorder) PrepareContext(ctx, query any) *gomock.Call
- func (mr *MockQuerierMockRecorder) Query(query any, args ...any) *gomock.Call
- func (mr *MockQuerierMockRecorder) QueryContext(ctx, query any, args ...any) *gomock.Call
- func (mr *MockQuerierMockRecorder) QueryRow(query any, args ...any) *gomock.Call
- func (mr *MockQuerierMockRecorder) QueryRowContext(ctx, query any, args ...any) *gomock.Call
- type MockResult
- type MockResultMockRecorder
- type MockSQLDB
- func (m *MockSQLDB) BeginTx(ctx context.Context, opts *sql.TxOptions) (SQLTX, error)
- func (m *MockSQLDB) Close() error
- func (m *MockSQLDB) EXPECT() *MockSQLDBMockRecorder
- func (m *MockSQLDB) Exec(query string, args ...any) (sql.Result, error)
- func (m *MockSQLDB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (m *MockSQLDB) Ping() error
- func (m *MockSQLDB) Prepare(query string) (*sql.Stmt, error)
- func (m *MockSQLDB) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
- func (m *MockSQLDB) Query(query string, args ...any) (*sql.Rows, error)
- func (m *MockSQLDB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (m *MockSQLDB) QueryRow(query string, args ...any) *sql.Row
- func (m *MockSQLDB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
- type MockSQLDBMockRecorder
- func (mr *MockSQLDBMockRecorder) BeginTx(ctx, opts any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) Close() *gomock.Call
- func (mr *MockSQLDBMockRecorder) Exec(query any, args ...any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) ExecContext(ctx, query any, args ...any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) Ping() *gomock.Call
- func (mr *MockSQLDBMockRecorder) Prepare(query any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) PrepareContext(ctx, query any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) Query(query any, args ...any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) QueryContext(ctx, query any, args ...any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) QueryRow(query any, args ...any) *gomock.Call
- func (mr *MockSQLDBMockRecorder) QueryRowContext(ctx, query any, args ...any) *gomock.Call
- type MockSQLTX
- func (m *MockSQLTX) Commit() error
- func (m *MockSQLTX) EXPECT() *MockSQLTXMockRecorder
- func (m *MockSQLTX) Exec(query string, args ...any) (sql.Result, error)
- func (m *MockSQLTX) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (m *MockSQLTX) Prepare(query string) (*sql.Stmt, error)
- func (m *MockSQLTX) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
- func (m *MockSQLTX) Query(query string, args ...any) (*sql.Rows, error)
- func (m *MockSQLTX) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (m *MockSQLTX) QueryRow(query string, args ...any) *sql.Row
- func (m *MockSQLTX) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
- func (m *MockSQLTX) Rollback() error
- type MockSQLTXMockRecorder
- func (mr *MockSQLTXMockRecorder) Commit() *gomock.Call
- func (mr *MockSQLTXMockRecorder) Exec(query any, args ...any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) ExecContext(ctx, query any, args ...any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) Prepare(query any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) PrepareContext(ctx, query any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) Query(query any, args ...any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) QueryContext(ctx, query any, args ...any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) QueryRow(query any, args ...any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) QueryRowContext(ctx, query any, args ...any) *gomock.Call
- func (mr *MockSQLTXMockRecorder) Rollback() *gomock.Call
- type PaginationResult
- type Querier
- type SQLDB
- type SQLTX
- type Storage
Constants ¶
const ( DESC = "DESC" // Descending order. ASC = "ASC" // Ascending order. )
Variables ¶
This section is empty.
Functions ¶
func IsUniqueViolation ¶
IsUniqueViolation check if error is a unique constraint violation error
func IsUniqueViolationByField ¶
IsUniqueViolationByField check if error is a unique constraint violation error by field
Types ¶
type MockQuerier ¶
type MockQuerier struct {
// contains filtered or unexported fields
}
MockQuerier is a mock of Querier interface.
func NewMockQuerier ¶
func NewMockQuerier(ctrl *gomock.Controller) *MockQuerier
NewMockQuerier creates a new mock instance.
func (*MockQuerier) EXPECT ¶
func (m *MockQuerier) EXPECT() *MockQuerierMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockQuerier) ExecContext ¶
func (m *MockQuerier) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
ExecContext mocks base method.
func (*MockQuerier) Prepare ¶
func (m *MockQuerier) Prepare(query string) (*sql.Stmt, error)
Prepare mocks base method.
func (*MockQuerier) PrepareContext ¶
PrepareContext mocks base method.
func (*MockQuerier) QueryContext ¶
func (m *MockQuerier) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryContext mocks base method.
func (*MockQuerier) QueryRow ¶
func (m *MockQuerier) QueryRow(query string, args ...any) *sql.Row
QueryRow mocks base method.
func (*MockQuerier) QueryRowContext ¶
QueryRowContext mocks base method.
type MockQuerierMockRecorder ¶
type MockQuerierMockRecorder struct {
// contains filtered or unexported fields
}
MockQuerierMockRecorder is the mock recorder for MockQuerier.
func (*MockQuerierMockRecorder) Exec ¶
func (mr *MockQuerierMockRecorder) Exec(query any, args ...any) *gomock.Call
Exec indicates an expected call of Exec.
func (*MockQuerierMockRecorder) ExecContext ¶
func (mr *MockQuerierMockRecorder) ExecContext(ctx, query any, args ...any) *gomock.Call
ExecContext indicates an expected call of ExecContext.
func (*MockQuerierMockRecorder) Prepare ¶
func (mr *MockQuerierMockRecorder) Prepare(query any) *gomock.Call
Prepare indicates an expected call of Prepare.
func (*MockQuerierMockRecorder) PrepareContext ¶
func (mr *MockQuerierMockRecorder) PrepareContext(ctx, query any) *gomock.Call
PrepareContext indicates an expected call of PrepareContext.
func (*MockQuerierMockRecorder) Query ¶
func (mr *MockQuerierMockRecorder) Query(query any, args ...any) *gomock.Call
Query indicates an expected call of Query.
func (*MockQuerierMockRecorder) QueryContext ¶
func (mr *MockQuerierMockRecorder) QueryContext(ctx, query any, args ...any) *gomock.Call
QueryContext indicates an expected call of QueryContext.
func (*MockQuerierMockRecorder) QueryRow ¶
func (mr *MockQuerierMockRecorder) QueryRow(query any, args ...any) *gomock.Call
QueryRow indicates an expected call of QueryRow.
func (*MockQuerierMockRecorder) QueryRowContext ¶
func (mr *MockQuerierMockRecorder) QueryRowContext(ctx, query any, args ...any) *gomock.Call
QueryRowContext indicates an expected call of QueryRowContext.
type MockResult ¶
type MockResult struct {
// contains filtered or unexported fields
}
MockResult is a mock of Result interface.
func NewMockResult ¶
func NewMockResult(ctrl *gomock.Controller) *MockResult
NewMockResult creates a new mock instance.
func (*MockResult) EXPECT ¶
func (m *MockResult) EXPECT() *MockResultMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockResult) LastInsertId ¶
func (m *MockResult) LastInsertId() (int64, error)
LastInsertId mocks base method.
func (*MockResult) RowsAffected ¶
func (m *MockResult) RowsAffected() (int64, error)
RowsAffected mocks base method.
type MockResultMockRecorder ¶
type MockResultMockRecorder struct {
// contains filtered or unexported fields
}
MockResultMockRecorder is the mock recorder for MockResult.
func (*MockResultMockRecorder) LastInsertId ¶
func (mr *MockResultMockRecorder) LastInsertId() *gomock.Call
LastInsertId indicates an expected call of LastInsertId.
func (*MockResultMockRecorder) RowsAffected ¶
func (mr *MockResultMockRecorder) RowsAffected() *gomock.Call
RowsAffected indicates an expected call of RowsAffected.
type MockSQLDB ¶
type MockSQLDB struct {
// contains filtered or unexported fields
}
MockSQLDB is a mock of SQLDB interface.
func MockSQLDBHelper ¶
func MockSQLDBHelper(ctrl *gomock.Controller) *MockSQLDB
func NewMockSQLDB ¶
func NewMockSQLDB(ctrl *gomock.Controller) *MockSQLDB
NewMockSQLDB creates a new mock instance.
func (*MockSQLDB) EXPECT ¶
func (m *MockSQLDB) EXPECT() *MockSQLDBMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSQLDB) ExecContext ¶
ExecContext mocks base method.
func (*MockSQLDB) PrepareContext ¶
PrepareContext mocks base method.
func (*MockSQLDB) QueryContext ¶
QueryContext mocks base method.
type MockSQLDBMockRecorder ¶
type MockSQLDBMockRecorder struct {
// contains filtered or unexported fields
}
MockSQLDBMockRecorder is the mock recorder for MockSQLDB.
func (*MockSQLDBMockRecorder) BeginTx ¶
func (mr *MockSQLDBMockRecorder) BeginTx(ctx, opts any) *gomock.Call
BeginTx indicates an expected call of BeginTx.
func (*MockSQLDBMockRecorder) Close ¶
func (mr *MockSQLDBMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockSQLDBMockRecorder) Exec ¶
func (mr *MockSQLDBMockRecorder) Exec(query any, args ...any) *gomock.Call
Exec indicates an expected call of Exec.
func (*MockSQLDBMockRecorder) ExecContext ¶
func (mr *MockSQLDBMockRecorder) ExecContext(ctx, query any, args ...any) *gomock.Call
ExecContext indicates an expected call of ExecContext.
func (*MockSQLDBMockRecorder) Ping ¶
func (mr *MockSQLDBMockRecorder) Ping() *gomock.Call
Ping indicates an expected call of Ping.
func (*MockSQLDBMockRecorder) Prepare ¶
func (mr *MockSQLDBMockRecorder) Prepare(query any) *gomock.Call
Prepare indicates an expected call of Prepare.
func (*MockSQLDBMockRecorder) PrepareContext ¶
func (mr *MockSQLDBMockRecorder) PrepareContext(ctx, query any) *gomock.Call
PrepareContext indicates an expected call of PrepareContext.
func (*MockSQLDBMockRecorder) Query ¶
func (mr *MockSQLDBMockRecorder) Query(query any, args ...any) *gomock.Call
Query indicates an expected call of Query.
func (*MockSQLDBMockRecorder) QueryContext ¶
func (mr *MockSQLDBMockRecorder) QueryContext(ctx, query any, args ...any) *gomock.Call
QueryContext indicates an expected call of QueryContext.
func (*MockSQLDBMockRecorder) QueryRow ¶
func (mr *MockSQLDBMockRecorder) QueryRow(query any, args ...any) *gomock.Call
QueryRow indicates an expected call of QueryRow.
func (*MockSQLDBMockRecorder) QueryRowContext ¶
func (mr *MockSQLDBMockRecorder) QueryRowContext(ctx, query any, args ...any) *gomock.Call
QueryRowContext indicates an expected call of QueryRowContext.
type MockSQLTX ¶
type MockSQLTX struct {
// contains filtered or unexported fields
}
MockSQLTX is a mock of SQLTX interface.
func NewMockSQLTX ¶
func NewMockSQLTX(ctrl *gomock.Controller) *MockSQLTX
NewMockSQLTX creates a new mock instance.
func (*MockSQLTX) EXPECT ¶
func (m *MockSQLTX) EXPECT() *MockSQLTXMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSQLTX) ExecContext ¶
ExecContext mocks base method.
func (*MockSQLTX) PrepareContext ¶
PrepareContext mocks base method.
func (*MockSQLTX) QueryContext ¶
QueryContext mocks base method.
func (*MockSQLTX) QueryRowContext ¶
QueryRowContext mocks base method.
type MockSQLTXMockRecorder ¶
type MockSQLTXMockRecorder struct {
// contains filtered or unexported fields
}
MockSQLTXMockRecorder is the mock recorder for MockSQLTX.
func (*MockSQLTXMockRecorder) Commit ¶
func (mr *MockSQLTXMockRecorder) Commit() *gomock.Call
Commit indicates an expected call of Commit.
func (*MockSQLTXMockRecorder) Exec ¶
func (mr *MockSQLTXMockRecorder) Exec(query any, args ...any) *gomock.Call
Exec indicates an expected call of Exec.
func (*MockSQLTXMockRecorder) ExecContext ¶
func (mr *MockSQLTXMockRecorder) ExecContext(ctx, query any, args ...any) *gomock.Call
ExecContext indicates an expected call of ExecContext.
func (*MockSQLTXMockRecorder) Prepare ¶
func (mr *MockSQLTXMockRecorder) Prepare(query any) *gomock.Call
Prepare indicates an expected call of Prepare.
func (*MockSQLTXMockRecorder) PrepareContext ¶
func (mr *MockSQLTXMockRecorder) PrepareContext(ctx, query any) *gomock.Call
PrepareContext indicates an expected call of PrepareContext.
func (*MockSQLTXMockRecorder) Query ¶
func (mr *MockSQLTXMockRecorder) Query(query any, args ...any) *gomock.Call
Query indicates an expected call of Query.
func (*MockSQLTXMockRecorder) QueryContext ¶
func (mr *MockSQLTXMockRecorder) QueryContext(ctx, query any, args ...any) *gomock.Call
QueryContext indicates an expected call of QueryContext.
func (*MockSQLTXMockRecorder) QueryRow ¶
func (mr *MockSQLTXMockRecorder) QueryRow(query any, args ...any) *gomock.Call
QueryRow indicates an expected call of QueryRow.
func (*MockSQLTXMockRecorder) QueryRowContext ¶
func (mr *MockSQLTXMockRecorder) QueryRowContext(ctx, query any, args ...any) *gomock.Call
QueryRowContext indicates an expected call of QueryRowContext.
func (*MockSQLTXMockRecorder) Rollback ¶
func (mr *MockSQLTXMockRecorder) Rollback() *gomock.Call
Rollback indicates an expected call of Rollback.
type PaginationResult ¶
PaginationResult represents pagination parameters with limit and offset values.
func Pagination ¶
func Pagination(page, perPage string) PaginationResult
Pagination calculates and returns the pagination limit and offset based on the page and perPage parameters.
type Querier ¶
type Querier interface { Exec(query string, args ...any) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) Query(query string, args ...any) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) QueryRow(query string, args ...any) *sql.Row QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row }
Querier defines an interface for executing SQL queries and statements. It abstracts the basic database operations to support flexibility for various implementations.
type SQLDB ¶
type SQLDB interface { Querier BeginTx(ctx context.Context, opts *sql.TxOptions) (SQLTX, error) Close() error Ping() error }
SQLDB represents an SQL database client, extending the Querier interface with methods for transaction management and connection lifecycle.
type SQLTX ¶
SQLTX represents an SQL transaction, extending the Querier interface with methods to manage transaction lifecycle.