refactor: database interaction and error handling (#10762)

This pull request introduces a significant refactoring of the database
interaction layer, focusing on improving explicitness, transactional
control, and error handling. The core change is the removal of the
stateful `QueryExecutor` from repository instances. Instead, it is now
passed as an argument to each method that interacts with the database.

This change makes transaction management more explicit and flexible, as
the same repository instance can be used with a database pool or a
specific transaction without needing to be re-instantiated.

### Key Changes

- **Explicit `QueryExecutor` Passing:**
- All repository methods (`Get`, `List`, `Create`, `Update`, `Delete`,
etc.) in `InstanceRepository`, `OrganizationRepository`,
`UserRepository`, and their sub-repositories now require a
`database.QueryExecutor` (e.g., a `*pgxpool.Pool` or `pgx.Tx`) as the
first argument.
- Repository constructors no longer accept a `QueryExecutor`. For
example, `repository.InstanceRepository(pool)` is now
`repository.InstanceRepository()`.

- **Enhanced Error Handling:**
- A new `database.MissingConditionError` is introduced to enforce
required query conditions, such as ensuring an `instance_id` is always
present in `UPDATE` and `DELETE` operations.
- The database error wrapper in the `postgres` package now correctly
identifies and wraps `pgx.ErrTooManyRows` and similar errors from the
`scany` library into a `database.MultipleRowsFoundError`.

- **Improved Database Conditions:**
- The `database.Condition` interface now includes a
`ContainsColumn(Column) bool` method. This allows for runtime checks to
ensure that critical filters (like `instance_id`) are included in a
query, preventing accidental cross-tenant data modification.
- A new `database.Exists()` condition has been added to support `EXISTS`
subqueries, enabling more complex filtering logic, such as finding an
organization that has a specific domain.

- **Repository and Interface Refactoring:**
- The method for loading related entities (e.g., domains for an
organization) has been changed from a boolean flag (`Domains(true)`) to
a more explicit, chainable method (`LoadDomains()`). This returns a new
repository instance configured to load the sub-resource, promoting
immutability.
- The custom `OrgIdentifierCondition` has been removed in favor of using
the standard `database.Condition` interface, simplifying the API.

- **Code Cleanup and Test Updates:**
  - Unnecessary struct embeddings and metadata have been removed.
- All integration and repository tests have been updated to reflect the
new method signatures, passing the database pool or transaction object
explicitly.
- New tests have been added to cover the new `ExistsDomain`
functionality and other enhancements.

These changes make the data access layer more robust, predictable, and
easier to work with, especially in the context of database transactions.
This commit is contained in:
Silvan
2025-09-24 12:12:31 +02:00
committed by GitHub
parent 09d09ab337
commit cccfc816f6
53 changed files with 3900 additions and 1430 deletions

View File

@@ -1,9 +1,9 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/zitadel/zitadel/backend/v3/storage/database (interfaces: Pool,Client,Row,Rows,Transaction)
// Source: github.com/zitadel/zitadel/backend/v3/storage/database (interfaces: Pool,Connection,Row,Rows,Transaction)
//
// Generated by this command:
//
// mockgen -typed -package dbmock -destination ./dbmock/database.mock.go github.com/zitadel/zitadel/backend/v3/storage/database Pool,Client,Row,Rows,Transaction
// mockgen -typed -package dbmock -destination ./dbmock/database.mock.go github.com/zitadel/zitadel/backend/v3/storage/database Pool,Connection,Row,Rows,Transaction
//
// Package dbmock is a generated GoMock package.
@@ -21,6 +21,7 @@ import (
type MockPool struct {
ctrl *gomock.Controller
recorder *MockPoolMockRecorder
isgomock struct{}
}
// MockPoolMockRecorder is the mock recorder for MockPool.
@@ -41,18 +42,18 @@ func (m *MockPool) EXPECT() *MockPoolMockRecorder {
}
// Acquire mocks base method.
func (m *MockPool) Acquire(arg0 context.Context) (database.Client, error) {
func (m *MockPool) Acquire(ctx context.Context) (database.Connection, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Acquire", arg0)
ret0, _ := ret[0].(database.Client)
ret := m.ctrl.Call(m, "Acquire", ctx)
ret0, _ := ret[0].(database.Connection)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Acquire indicates an expected call of Acquire.
func (mr *MockPoolMockRecorder) Acquire(arg0 any) *MockPoolAcquireCall {
func (mr *MockPoolMockRecorder) Acquire(ctx any) *MockPoolAcquireCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Acquire", reflect.TypeOf((*MockPool)(nil).Acquire), arg0)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Acquire", reflect.TypeOf((*MockPool)(nil).Acquire), ctx)
return &MockPoolAcquireCall{Call: call}
}
@@ -62,36 +63,36 @@ type MockPoolAcquireCall struct {
}
// Return rewrite *gomock.Call.Return
func (c *MockPoolAcquireCall) Return(arg0 database.Client, arg1 error) *MockPoolAcquireCall {
func (c *MockPoolAcquireCall) Return(arg0 database.Connection, arg1 error) *MockPoolAcquireCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPoolAcquireCall) Do(f func(context.Context) (database.Client, error)) *MockPoolAcquireCall {
func (c *MockPoolAcquireCall) Do(f func(context.Context) (database.Connection, error)) *MockPoolAcquireCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPoolAcquireCall) DoAndReturn(f func(context.Context) (database.Client, error)) *MockPoolAcquireCall {
func (c *MockPoolAcquireCall) DoAndReturn(f func(context.Context) (database.Connection, error)) *MockPoolAcquireCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Begin mocks base method.
func (m *MockPool) Begin(arg0 context.Context, arg1 *database.TransactionOptions) (database.Transaction, error) {
func (m *MockPool) Begin(ctx context.Context, opts *database.TransactionOptions) (database.Transaction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Begin", arg0, arg1)
ret := m.ctrl.Call(m, "Begin", ctx, opts)
ret0, _ := ret[0].(database.Transaction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Begin indicates an expected call of Begin.
func (mr *MockPoolMockRecorder) Begin(arg0, arg1 any) *MockPoolBeginCall {
func (mr *MockPoolMockRecorder) Begin(ctx, opts any) *MockPoolBeginCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Begin", reflect.TypeOf((*MockPool)(nil).Begin), arg0, arg1)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Begin", reflect.TypeOf((*MockPool)(nil).Begin), ctx, opts)
return &MockPoolBeginCall{Call: call}
}
@@ -119,17 +120,17 @@ func (c *MockPoolBeginCall) DoAndReturn(f func(context.Context, *database.Transa
}
// Close mocks base method.
func (m *MockPool) Close(arg0 context.Context) error {
func (m *MockPool) Close(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Close", arg0)
ret := m.ctrl.Call(m, "Close", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Close indicates an expected call of Close.
func (mr *MockPoolMockRecorder) Close(arg0 any) *MockPoolCloseCall {
func (mr *MockPoolMockRecorder) Close(ctx any) *MockPoolCloseCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockPool)(nil).Close), arg0)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockPool)(nil).Close), ctx)
return &MockPoolCloseCall{Call: call}
}
@@ -157,10 +158,10 @@ func (c *MockPoolCloseCall) DoAndReturn(f func(context.Context) error) *MockPool
}
// Exec mocks base method.
func (m *MockPool) Exec(arg0 context.Context, arg1 string, arg2 ...any) (int64, error) {
func (m *MockPool) Exec(ctx context.Context, stmt string, args ...any) (int64, error) {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Exec", varargs...)
@@ -170,9 +171,9 @@ func (m *MockPool) Exec(arg0 context.Context, arg1 string, arg2 ...any) (int64,
}
// Exec indicates an expected call of Exec.
func (mr *MockPoolMockRecorder) Exec(arg0, arg1 any, arg2 ...any) *MockPoolExecCall {
func (mr *MockPoolMockRecorder) Exec(ctx, stmt any, args ...any) *MockPoolExecCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockPool)(nil).Exec), varargs...)
return &MockPoolExecCall{Call: call}
}
@@ -201,17 +202,17 @@ func (c *MockPoolExecCall) DoAndReturn(f func(context.Context, string, ...any) (
}
// Migrate mocks base method.
func (m *MockPool) Migrate(arg0 context.Context) error {
func (m *MockPool) Migrate(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Migrate", arg0)
ret := m.ctrl.Call(m, "Migrate", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Migrate indicates an expected call of Migrate.
func (mr *MockPoolMockRecorder) Migrate(arg0 any) *MockPoolMigrateCall {
func (mr *MockPoolMockRecorder) Migrate(ctx any) *MockPoolMigrateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockPool)(nil).Migrate), arg0)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockPool)(nil).Migrate), ctx)
return &MockPoolMigrateCall{Call: call}
}
@@ -238,11 +239,49 @@ func (c *MockPoolMigrateCall) DoAndReturn(f func(context.Context) error) *MockPo
return c
}
// Query mocks base method.
func (m *MockPool) Query(arg0 context.Context, arg1 string, arg2 ...any) (database.Rows, error) {
// Ping mocks base method.
func (m *MockPool) Ping(ctx context.Context) error {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
ret := m.ctrl.Call(m, "Ping", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Ping indicates an expected call of Ping.
func (mr *MockPoolMockRecorder) Ping(ctx any) *MockPoolPingCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ping", reflect.TypeOf((*MockPool)(nil).Ping), ctx)
return &MockPoolPingCall{Call: call}
}
// MockPoolPingCall wrap *gomock.Call
type MockPoolPingCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockPoolPingCall) Return(arg0 error) *MockPoolPingCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockPoolPingCall) Do(f func(context.Context) error) *MockPoolPingCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockPoolPingCall) DoAndReturn(f func(context.Context) error) *MockPoolPingCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Query mocks base method.
func (m *MockPool) Query(ctx context.Context, stmt string, args ...any) (database.Rows, error) {
m.ctrl.T.Helper()
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Query", varargs...)
@@ -252,9 +291,9 @@ func (m *MockPool) Query(arg0 context.Context, arg1 string, arg2 ...any) (databa
}
// Query indicates an expected call of Query.
func (mr *MockPoolMockRecorder) Query(arg0, arg1 any, arg2 ...any) *MockPoolQueryCall {
func (mr *MockPoolMockRecorder) Query(ctx, stmt any, args ...any) *MockPoolQueryCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockPool)(nil).Query), varargs...)
return &MockPoolQueryCall{Call: call}
}
@@ -283,10 +322,10 @@ func (c *MockPoolQueryCall) DoAndReturn(f func(context.Context, string, ...any)
}
// QueryRow mocks base method.
func (m *MockPool) QueryRow(arg0 context.Context, arg1 string, arg2 ...any) database.Row {
func (m *MockPool) QueryRow(ctx context.Context, stmt string, args ...any) database.Row {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "QueryRow", varargs...)
@@ -295,9 +334,9 @@ func (m *MockPool) QueryRow(arg0 context.Context, arg1 string, arg2 ...any) data
}
// QueryRow indicates an expected call of QueryRow.
func (mr *MockPoolMockRecorder) QueryRow(arg0, arg1 any, arg2 ...any) *MockPoolQueryRowCall {
func (mr *MockPoolMockRecorder) QueryRow(ctx, stmt any, args ...any) *MockPoolQueryRowCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRow", reflect.TypeOf((*MockPool)(nil).QueryRow), varargs...)
return &MockPoolQueryRowCall{Call: call}
}
@@ -325,73 +364,74 @@ func (c *MockPoolQueryRowCall) DoAndReturn(f func(context.Context, string, ...an
return c
}
// MockClient is a mock of Client interface.
type MockClient struct {
// MockConnection is a mock of Connection interface.
type MockConnection struct {
ctrl *gomock.Controller
recorder *MockClientMockRecorder
recorder *MockConnectionMockRecorder
isgomock struct{}
}
// MockClientMockRecorder is the mock recorder for MockClient.
type MockClientMockRecorder struct {
mock *MockClient
// MockConnectionMockRecorder is the mock recorder for MockConnection.
type MockConnectionMockRecorder struct {
mock *MockConnection
}
// NewMockClient creates a new mock instance.
func NewMockClient(ctrl *gomock.Controller) *MockClient {
mock := &MockClient{ctrl: ctrl}
mock.recorder = &MockClientMockRecorder{mock}
// NewMockConnection creates a new mock instance.
func NewMockConnection(ctrl *gomock.Controller) *MockConnection {
mock := &MockConnection{ctrl: ctrl}
mock.recorder = &MockConnectionMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockClient) EXPECT() *MockClientMockRecorder {
func (m *MockConnection) EXPECT() *MockConnectionMockRecorder {
return m.recorder
}
// Begin mocks base method.
func (m *MockClient) Begin(arg0 context.Context, arg1 *database.TransactionOptions) (database.Transaction, error) {
func (m *MockConnection) Begin(ctx context.Context, opts *database.TransactionOptions) (database.Transaction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Begin", arg0, arg1)
ret := m.ctrl.Call(m, "Begin", ctx, opts)
ret0, _ := ret[0].(database.Transaction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Begin indicates an expected call of Begin.
func (mr *MockClientMockRecorder) Begin(arg0, arg1 any) *MockClientBeginCall {
func (mr *MockConnectionMockRecorder) Begin(ctx, opts any) *MockConnectionBeginCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Begin", reflect.TypeOf((*MockClient)(nil).Begin), arg0, arg1)
return &MockClientBeginCall{Call: call}
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Begin", reflect.TypeOf((*MockConnection)(nil).Begin), ctx, opts)
return &MockConnectionBeginCall{Call: call}
}
// MockClientBeginCall wrap *gomock.Call
type MockClientBeginCall struct {
// MockConnectionBeginCall wrap *gomock.Call
type MockConnectionBeginCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockClientBeginCall) Return(arg0 database.Transaction, arg1 error) *MockClientBeginCall {
func (c *MockConnectionBeginCall) Return(arg0 database.Transaction, arg1 error) *MockConnectionBeginCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockClientBeginCall) Do(f func(context.Context, *database.TransactionOptions) (database.Transaction, error)) *MockClientBeginCall {
func (c *MockConnectionBeginCall) Do(f func(context.Context, *database.TransactionOptions) (database.Transaction, error)) *MockConnectionBeginCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockClientBeginCall) DoAndReturn(f func(context.Context, *database.TransactionOptions) (database.Transaction, error)) *MockClientBeginCall {
func (c *MockConnectionBeginCall) DoAndReturn(f func(context.Context, *database.TransactionOptions) (database.Transaction, error)) *MockConnectionBeginCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Exec mocks base method.
func (m *MockClient) Exec(arg0 context.Context, arg1 string, arg2 ...any) (int64, error) {
func (m *MockConnection) Exec(ctx context.Context, stmt string, args ...any) (int64, error) {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Exec", varargs...)
@@ -401,79 +441,117 @@ func (m *MockClient) Exec(arg0 context.Context, arg1 string, arg2 ...any) (int64
}
// Exec indicates an expected call of Exec.
func (mr *MockClientMockRecorder) Exec(arg0, arg1 any, arg2 ...any) *MockClientExecCall {
func (mr *MockConnectionMockRecorder) Exec(ctx, stmt any, args ...any) *MockConnectionExecCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockClient)(nil).Exec), varargs...)
return &MockClientExecCall{Call: call}
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockConnection)(nil).Exec), varargs...)
return &MockConnectionExecCall{Call: call}
}
// MockClientExecCall wrap *gomock.Call
type MockClientExecCall struct {
// MockConnectionExecCall wrap *gomock.Call
type MockConnectionExecCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockClientExecCall) Return(arg0 int64, arg1 error) *MockClientExecCall {
func (c *MockConnectionExecCall) Return(arg0 int64, arg1 error) *MockConnectionExecCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockClientExecCall) Do(f func(context.Context, string, ...any) (int64, error)) *MockClientExecCall {
func (c *MockConnectionExecCall) Do(f func(context.Context, string, ...any) (int64, error)) *MockConnectionExecCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockClientExecCall) DoAndReturn(f func(context.Context, string, ...any) (int64, error)) *MockClientExecCall {
func (c *MockConnectionExecCall) DoAndReturn(f func(context.Context, string, ...any) (int64, error)) *MockConnectionExecCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Migrate mocks base method.
func (m *MockClient) Migrate(arg0 context.Context) error {
func (m *MockConnection) Migrate(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Migrate", arg0)
ret := m.ctrl.Call(m, "Migrate", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Migrate indicates an expected call of Migrate.
func (mr *MockClientMockRecorder) Migrate(arg0 any) *MockClientMigrateCall {
func (mr *MockConnectionMockRecorder) Migrate(ctx any) *MockConnectionMigrateCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockClient)(nil).Migrate), arg0)
return &MockClientMigrateCall{Call: call}
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Migrate", reflect.TypeOf((*MockConnection)(nil).Migrate), ctx)
return &MockConnectionMigrateCall{Call: call}
}
// MockClientMigrateCall wrap *gomock.Call
type MockClientMigrateCall struct {
// MockConnectionMigrateCall wrap *gomock.Call
type MockConnectionMigrateCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockClientMigrateCall) Return(arg0 error) *MockClientMigrateCall {
func (c *MockConnectionMigrateCall) Return(arg0 error) *MockConnectionMigrateCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockClientMigrateCall) Do(f func(context.Context) error) *MockClientMigrateCall {
func (c *MockConnectionMigrateCall) Do(f func(context.Context) error) *MockConnectionMigrateCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockClientMigrateCall) DoAndReturn(f func(context.Context) error) *MockClientMigrateCall {
func (c *MockConnectionMigrateCall) DoAndReturn(f func(context.Context) error) *MockConnectionMigrateCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Ping mocks base method.
func (m *MockConnection) Ping(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Ping", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Ping indicates an expected call of Ping.
func (mr *MockConnectionMockRecorder) Ping(ctx any) *MockConnectionPingCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ping", reflect.TypeOf((*MockConnection)(nil).Ping), ctx)
return &MockConnectionPingCall{Call: call}
}
// MockConnectionPingCall wrap *gomock.Call
type MockConnectionPingCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockConnectionPingCall) Return(arg0 error) *MockConnectionPingCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockConnectionPingCall) Do(f func(context.Context) error) *MockConnectionPingCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockConnectionPingCall) DoAndReturn(f func(context.Context) error) *MockConnectionPingCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Query mocks base method.
func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 ...any) (database.Rows, error) {
func (m *MockConnection) Query(ctx context.Context, stmt string, args ...any) (database.Rows, error) {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Query", varargs...)
@@ -483,41 +561,41 @@ func (m *MockClient) Query(arg0 context.Context, arg1 string, arg2 ...any) (data
}
// Query indicates an expected call of Query.
func (mr *MockClientMockRecorder) Query(arg0, arg1 any, arg2 ...any) *MockClientQueryCall {
func (mr *MockConnectionMockRecorder) Query(ctx, stmt any, args ...any) *MockConnectionQueryCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockClient)(nil).Query), varargs...)
return &MockClientQueryCall{Call: call}
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockConnection)(nil).Query), varargs...)
return &MockConnectionQueryCall{Call: call}
}
// MockClientQueryCall wrap *gomock.Call
type MockClientQueryCall struct {
// MockConnectionQueryCall wrap *gomock.Call
type MockConnectionQueryCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockClientQueryCall) Return(arg0 database.Rows, arg1 error) *MockClientQueryCall {
func (c *MockConnectionQueryCall) Return(arg0 database.Rows, arg1 error) *MockConnectionQueryCall {
c.Call = c.Call.Return(arg0, arg1)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockClientQueryCall) Do(f func(context.Context, string, ...any) (database.Rows, error)) *MockClientQueryCall {
func (c *MockConnectionQueryCall) Do(f func(context.Context, string, ...any) (database.Rows, error)) *MockConnectionQueryCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockClientQueryCall) DoAndReturn(f func(context.Context, string, ...any) (database.Rows, error)) *MockClientQueryCall {
func (c *MockConnectionQueryCall) DoAndReturn(f func(context.Context, string, ...any) (database.Rows, error)) *MockConnectionQueryCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// QueryRow mocks base method.
func (m *MockClient) QueryRow(arg0 context.Context, arg1 string, arg2 ...any) database.Row {
func (m *MockConnection) QueryRow(ctx context.Context, stmt string, args ...any) database.Row {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "QueryRow", varargs...)
@@ -526,70 +604,70 @@ func (m *MockClient) QueryRow(arg0 context.Context, arg1 string, arg2 ...any) da
}
// QueryRow indicates an expected call of QueryRow.
func (mr *MockClientMockRecorder) QueryRow(arg0, arg1 any, arg2 ...any) *MockClientQueryRowCall {
func (mr *MockConnectionMockRecorder) QueryRow(ctx, stmt any, args ...any) *MockConnectionQueryRowCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRow", reflect.TypeOf((*MockClient)(nil).QueryRow), varargs...)
return &MockClientQueryRowCall{Call: call}
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRow", reflect.TypeOf((*MockConnection)(nil).QueryRow), varargs...)
return &MockConnectionQueryRowCall{Call: call}
}
// MockClientQueryRowCall wrap *gomock.Call
type MockClientQueryRowCall struct {
// MockConnectionQueryRowCall wrap *gomock.Call
type MockConnectionQueryRowCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockClientQueryRowCall) Return(arg0 database.Row) *MockClientQueryRowCall {
func (c *MockConnectionQueryRowCall) Return(arg0 database.Row) *MockConnectionQueryRowCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockClientQueryRowCall) Do(f func(context.Context, string, ...any) database.Row) *MockClientQueryRowCall {
func (c *MockConnectionQueryRowCall) Do(f func(context.Context, string, ...any) database.Row) *MockConnectionQueryRowCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockClientQueryRowCall) DoAndReturn(f func(context.Context, string, ...any) database.Row) *MockClientQueryRowCall {
func (c *MockConnectionQueryRowCall) DoAndReturn(f func(context.Context, string, ...any) database.Row) *MockConnectionQueryRowCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// Release mocks base method.
func (m *MockClient) Release(arg0 context.Context) error {
func (m *MockConnection) Release(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Release", arg0)
ret := m.ctrl.Call(m, "Release", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Release indicates an expected call of Release.
func (mr *MockClientMockRecorder) Release(arg0 any) *MockClientReleaseCall {
func (mr *MockConnectionMockRecorder) Release(ctx any) *MockConnectionReleaseCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Release", reflect.TypeOf((*MockClient)(nil).Release), arg0)
return &MockClientReleaseCall{Call: call}
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Release", reflect.TypeOf((*MockConnection)(nil).Release), ctx)
return &MockConnectionReleaseCall{Call: call}
}
// MockClientReleaseCall wrap *gomock.Call
type MockClientReleaseCall struct {
// MockConnectionReleaseCall wrap *gomock.Call
type MockConnectionReleaseCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *MockClientReleaseCall) Return(arg0 error) *MockClientReleaseCall {
func (c *MockConnectionReleaseCall) Return(arg0 error) *MockConnectionReleaseCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *MockClientReleaseCall) Do(f func(context.Context) error) *MockClientReleaseCall {
func (c *MockConnectionReleaseCall) Do(f func(context.Context) error) *MockConnectionReleaseCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *MockClientReleaseCall) DoAndReturn(f func(context.Context) error) *MockClientReleaseCall {
func (c *MockConnectionReleaseCall) DoAndReturn(f func(context.Context) error) *MockConnectionReleaseCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
@@ -598,6 +676,7 @@ func (c *MockClientReleaseCall) DoAndReturn(f func(context.Context) error) *Mock
type MockRow struct {
ctrl *gomock.Controller
recorder *MockRowMockRecorder
isgomock struct{}
}
// MockRowMockRecorder is the mock recorder for MockRow.
@@ -618,10 +697,10 @@ func (m *MockRow) EXPECT() *MockRowMockRecorder {
}
// Scan mocks base method.
func (m *MockRow) Scan(arg0 ...any) error {
func (m *MockRow) Scan(dest ...any) error {
m.ctrl.T.Helper()
varargs := []any{}
for _, a := range arg0 {
for _, a := range dest {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Scan", varargs...)
@@ -630,9 +709,9 @@ func (m *MockRow) Scan(arg0 ...any) error {
}
// Scan indicates an expected call of Scan.
func (mr *MockRowMockRecorder) Scan(arg0 ...any) *MockRowScanCall {
func (mr *MockRowMockRecorder) Scan(dest ...any) *MockRowScanCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scan", reflect.TypeOf((*MockRow)(nil).Scan), arg0...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scan", reflect.TypeOf((*MockRow)(nil).Scan), dest...)
return &MockRowScanCall{Call: call}
}
@@ -663,6 +742,7 @@ func (c *MockRowScanCall) DoAndReturn(f func(...any) error) *MockRowScanCall {
type MockRows struct {
ctrl *gomock.Controller
recorder *MockRowsMockRecorder
isgomock struct{}
}
// MockRowsMockRecorder is the mock recorder for MockRows.
@@ -797,10 +877,10 @@ func (c *MockRowsNextCall) DoAndReturn(f func() bool) *MockRowsNextCall {
}
// Scan mocks base method.
func (m *MockRows) Scan(arg0 ...any) error {
func (m *MockRows) Scan(dest ...any) error {
m.ctrl.T.Helper()
varargs := []any{}
for _, a := range arg0 {
for _, a := range dest {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Scan", varargs...)
@@ -809,9 +889,9 @@ func (m *MockRows) Scan(arg0 ...any) error {
}
// Scan indicates an expected call of Scan.
func (mr *MockRowsMockRecorder) Scan(arg0 ...any) *MockRowsScanCall {
func (mr *MockRowsMockRecorder) Scan(dest ...any) *MockRowsScanCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scan", reflect.TypeOf((*MockRows)(nil).Scan), arg0...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scan", reflect.TypeOf((*MockRows)(nil).Scan), dest...)
return &MockRowsScanCall{Call: call}
}
@@ -842,6 +922,7 @@ func (c *MockRowsScanCall) DoAndReturn(f func(...any) error) *MockRowsScanCall {
type MockTransaction struct {
ctrl *gomock.Controller
recorder *MockTransactionMockRecorder
isgomock struct{}
}
// MockTransactionMockRecorder is the mock recorder for MockTransaction.
@@ -862,18 +943,18 @@ func (m *MockTransaction) EXPECT() *MockTransactionMockRecorder {
}
// Begin mocks base method.
func (m *MockTransaction) Begin(arg0 context.Context) (database.Transaction, error) {
func (m *MockTransaction) Begin(ctx context.Context) (database.Transaction, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Begin", arg0)
ret := m.ctrl.Call(m, "Begin", ctx)
ret0, _ := ret[0].(database.Transaction)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// Begin indicates an expected call of Begin.
func (mr *MockTransactionMockRecorder) Begin(arg0 any) *MockTransactionBeginCall {
func (mr *MockTransactionMockRecorder) Begin(ctx any) *MockTransactionBeginCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Begin", reflect.TypeOf((*MockTransaction)(nil).Begin), arg0)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Begin", reflect.TypeOf((*MockTransaction)(nil).Begin), ctx)
return &MockTransactionBeginCall{Call: call}
}
@@ -901,17 +982,17 @@ func (c *MockTransactionBeginCall) DoAndReturn(f func(context.Context) (database
}
// Commit mocks base method.
func (m *MockTransaction) Commit(arg0 context.Context) error {
func (m *MockTransaction) Commit(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Commit", arg0)
ret := m.ctrl.Call(m, "Commit", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Commit indicates an expected call of Commit.
func (mr *MockTransactionMockRecorder) Commit(arg0 any) *MockTransactionCommitCall {
func (mr *MockTransactionMockRecorder) Commit(ctx any) *MockTransactionCommitCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Commit", reflect.TypeOf((*MockTransaction)(nil).Commit), arg0)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Commit", reflect.TypeOf((*MockTransaction)(nil).Commit), ctx)
return &MockTransactionCommitCall{Call: call}
}
@@ -939,17 +1020,17 @@ func (c *MockTransactionCommitCall) DoAndReturn(f func(context.Context) error) *
}
// End mocks base method.
func (m *MockTransaction) End(arg0 context.Context, arg1 error) error {
func (m *MockTransaction) End(ctx context.Context, err error) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "End", arg0, arg1)
ret := m.ctrl.Call(m, "End", ctx, err)
ret0, _ := ret[0].(error)
return ret0
}
// End indicates an expected call of End.
func (mr *MockTransactionMockRecorder) End(arg0, arg1 any) *MockTransactionEndCall {
func (mr *MockTransactionMockRecorder) End(ctx, err any) *MockTransactionEndCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "End", reflect.TypeOf((*MockTransaction)(nil).End), arg0, arg1)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "End", reflect.TypeOf((*MockTransaction)(nil).End), ctx, err)
return &MockTransactionEndCall{Call: call}
}
@@ -977,10 +1058,10 @@ func (c *MockTransactionEndCall) DoAndReturn(f func(context.Context, error) erro
}
// Exec mocks base method.
func (m *MockTransaction) Exec(arg0 context.Context, arg1 string, arg2 ...any) (int64, error) {
func (m *MockTransaction) Exec(ctx context.Context, stmt string, args ...any) (int64, error) {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Exec", varargs...)
@@ -990,9 +1071,9 @@ func (m *MockTransaction) Exec(arg0 context.Context, arg1 string, arg2 ...any) (
}
// Exec indicates an expected call of Exec.
func (mr *MockTransactionMockRecorder) Exec(arg0, arg1 any, arg2 ...any) *MockTransactionExecCall {
func (mr *MockTransactionMockRecorder) Exec(ctx, stmt any, args ...any) *MockTransactionExecCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockTransaction)(nil).Exec), varargs...)
return &MockTransactionExecCall{Call: call}
}
@@ -1021,10 +1102,10 @@ func (c *MockTransactionExecCall) DoAndReturn(f func(context.Context, string, ..
}
// Query mocks base method.
func (m *MockTransaction) Query(arg0 context.Context, arg1 string, arg2 ...any) (database.Rows, error) {
func (m *MockTransaction) Query(ctx context.Context, stmt string, args ...any) (database.Rows, error) {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Query", varargs...)
@@ -1034,9 +1115,9 @@ func (m *MockTransaction) Query(arg0 context.Context, arg1 string, arg2 ...any)
}
// Query indicates an expected call of Query.
func (mr *MockTransactionMockRecorder) Query(arg0, arg1 any, arg2 ...any) *MockTransactionQueryCall {
func (mr *MockTransactionMockRecorder) Query(ctx, stmt any, args ...any) *MockTransactionQueryCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Query", reflect.TypeOf((*MockTransaction)(nil).Query), varargs...)
return &MockTransactionQueryCall{Call: call}
}
@@ -1065,10 +1146,10 @@ func (c *MockTransactionQueryCall) DoAndReturn(f func(context.Context, string, .
}
// QueryRow mocks base method.
func (m *MockTransaction) QueryRow(arg0 context.Context, arg1 string, arg2 ...any) database.Row {
func (m *MockTransaction) QueryRow(ctx context.Context, stmt string, args ...any) database.Row {
m.ctrl.T.Helper()
varargs := []any{arg0, arg1}
for _, a := range arg2 {
varargs := []any{ctx, stmt}
for _, a := range args {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "QueryRow", varargs...)
@@ -1077,9 +1158,9 @@ func (m *MockTransaction) QueryRow(arg0 context.Context, arg1 string, arg2 ...an
}
// QueryRow indicates an expected call of QueryRow.
func (mr *MockTransactionMockRecorder) QueryRow(arg0, arg1 any, arg2 ...any) *MockTransactionQueryRowCall {
func (mr *MockTransactionMockRecorder) QueryRow(ctx, stmt any, args ...any) *MockTransactionQueryRowCall {
mr.mock.ctrl.T.Helper()
varargs := append([]any{arg0, arg1}, arg2...)
varargs := append([]any{ctx, stmt}, args...)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "QueryRow", reflect.TypeOf((*MockTransaction)(nil).QueryRow), varargs...)
return &MockTransactionQueryRowCall{Call: call}
}
@@ -1108,17 +1189,17 @@ func (c *MockTransactionQueryRowCall) DoAndReturn(f func(context.Context, string
}
// Rollback mocks base method.
func (m *MockTransaction) Rollback(arg0 context.Context) error {
func (m *MockTransaction) Rollback(ctx context.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Rollback", arg0)
ret := m.ctrl.Call(m, "Rollback", ctx)
ret0, _ := ret[0].(error)
return ret0
}
// Rollback indicates an expected call of Rollback.
func (mr *MockTransactionMockRecorder) Rollback(arg0 any) *MockTransactionRollbackCall {
func (mr *MockTransactionMockRecorder) Rollback(ctx any) *MockTransactionRollbackCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Rollback", reflect.TypeOf((*MockTransaction)(nil).Rollback), arg0)
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Rollback", reflect.TypeOf((*MockTransaction)(nil).Rollback), ctx)
return &MockTransactionRollbackCall{Call: call}
}