This commit is contained in:
adlerhurst
2025-07-25 20:05:15 +02:00
parent 513818f55d
commit 889420f2d8
14 changed files with 14 additions and 9 deletions

View File

@@ -33,6 +33,7 @@ func (c *pgxConn) Begin(ctx context.Context, opts *database.TransactionOptions)
// Query implements sql.Client. // Query implements sql.Client.
// Subtle: this method shadows the method (*Conn).Query of pgxConn.Conn. // Subtle: this method shadows the method (*Conn).Query of pgxConn.Conn.
func (c *pgxConn) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) { func (c *pgxConn) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) {
//nolint:sqlclosecheck // Rows.Close is called by the caller
rows, err := c.Conn.Query(ctx, sql, args...) rows, err := c.Conn.Query(ctx, sql, args...)
if err != nil { if err != nil {
return nil, wrapError(err) return nil, wrapError(err)

View File

@@ -33,6 +33,7 @@ func (c *pgxPool) Acquire(ctx context.Context) (database.Client, error) {
// Query implements [database.Pool]. // Query implements [database.Pool].
// Subtle: this method shadows the method (Pool).Query of pgxPool.Pool. // Subtle: this method shadows the method (Pool).Query of pgxPool.Pool.
func (c *pgxPool) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) { func (c *pgxPool) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) {
//nolint:sqlclosecheck // Rows.Close is called by the caller
rows, err := c.Pool.Query(ctx, sql, args...) rows, err := c.Pool.Query(ctx, sql, args...)
if err != nil { if err != nil {
return nil, wrapError(err) return nil, wrapError(err)

View File

@@ -40,6 +40,7 @@ func (tx *pgxTx) End(ctx context.Context, err error) error {
// Query implements [database.Transaction]. // Query implements [database.Transaction].
// Subtle: this method shadows the method (Tx).Query of pgxTx.Tx. // Subtle: this method shadows the method (Tx).Query of pgxTx.Tx.
func (tx *pgxTx) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) { func (tx *pgxTx) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) {
//nolint:sqlclosecheck // Rows.Close is called by the caller
rows, err := tx.Tx.Query(ctx, sql, args...) rows, err := tx.Tx.Query(ctx, sql, args...)
if err != nil { if err != nil {
return nil, wrapError(err) return nil, wrapError(err)

View File

@@ -30,6 +30,7 @@ func (c *sqlConn) Begin(ctx context.Context, opts *database.TransactionOptions)
// Query implements sql.Client. // Query implements sql.Client.
// Subtle: this method shadows the method (*Conn).Query of pgxConn.Conn. // Subtle: this method shadows the method (*Conn).Query of pgxConn.Conn.
func (c *sqlConn) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) { func (c *sqlConn) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) {
//nolint:sqlclosecheck // Rows.Close is called by the caller
rows, err := c.QueryContext(ctx, sql, args...) rows, err := c.QueryContext(ctx, sql, args...)
if err != nil { if err != nil {
return nil, wrapError(err) return nil, wrapError(err)

View File

@@ -31,6 +31,7 @@ func (c *sqlPool) Acquire(ctx context.Context) (database.Client, error) {
// Query implements [database.Pool]. // Query implements [database.Pool].
// Subtle: this method shadows the method (Pool).Query of pgxPool.Pool. // Subtle: this method shadows the method (Pool).Query of pgxPool.Pool.
func (c *sqlPool) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) { func (c *sqlPool) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) {
//nolint:sqlclosecheck // Rows.Close is called by the caller
rows, err := c.QueryContext(ctx, sql, args...) rows, err := c.QueryContext(ctx, sql, args...)
if err != nil { if err != nil {
return nil, wrapError(err) return nil, wrapError(err)

View File

@@ -74,6 +74,5 @@ func (r *Rows) CollectExactlyOneRow(dest any) (err error) {
// Close implements [database.Rows]. // Close implements [database.Rows].
// Subtle: this method shadows the method (Rows).Close of Rows.Rows. // Subtle: this method shadows the method (Rows).Close of Rows.Rows.
func (r *Rows) Close() error { func (r *Rows) Close() error {
r.Rows.Close() return r.Rows.Close()
return nil
} }

View File

@@ -43,6 +43,7 @@ func (tx *sqlTx) End(ctx context.Context, err error) error {
// Query implements [database.Transaction]. // Query implements [database.Transaction].
// Subtle: this method shadows the method (Tx).Query of pgxTx.Tx. // Subtle: this method shadows the method (Tx).Query of pgxTx.Tx.
func (tx *sqlTx) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) { func (tx *sqlTx) Query(ctx context.Context, sql string, args ...any) (database.Rows, error) {
//nolint:sqlclosecheck // Rows.Close is called by the caller
rows, err := tx.QueryContext(ctx, sql, args...) rows, err := tx.QueryContext(ctx, sql, args...)
if err != nil { if err != nil {
return nil, wrapError(err) return nil, wrapError(err)

View File

@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
) )
var NoChangesError = errors.New("Update must contain a change") var ErrNoChanges = errors.New("update must contain a change")
// NoRowFoundError is returned when QueryRow does not find any row. // NoRowFoundError is returned when QueryRow does not find any row.
// It wraps the dialect specific original error to provide more context. // It wraps the dialect specific original error to provide more context.

View File

@@ -105,7 +105,7 @@ func (i *instance) Create(ctx context.Context, instance *domain.Instance) error
// Update implements [domain.InstanceRepository]. // Update implements [domain.InstanceRepository].
func (i instance) Update(ctx context.Context, id string, changes ...database.Change) (int64, error) { func (i instance) Update(ctx context.Context, id string, changes ...database.Change) (int64, error) {
if len(changes) == 0 { if len(changes) == 0 {
return 0, database.NoChangesError return 0, database.ErrNoChanges
} }
var builder database.StatementBuilder var builder database.StatementBuilder

View File

@@ -77,7 +77,7 @@ func (i *instanceDomain) Remove(ctx context.Context, condition database.Conditio
// Subtle: this method shadows the method ([domain.InstanceRepository]).Update of instanceDomain.instance. // Subtle: this method shadows the method ([domain.InstanceRepository]).Update of instanceDomain.instance.
func (i *instanceDomain) Update(ctx context.Context, condition database.Condition, changes ...database.Change) (int64, error) { func (i *instanceDomain) Update(ctx context.Context, condition database.Condition, changes ...database.Change) (int64, error) {
if len(changes) == 0 { if len(changes) == 0 {
return 0, database.NoChangesError return 0, database.ErrNoChanges
} }
var builder database.StatementBuilder var builder database.StatementBuilder

View File

@@ -475,7 +475,7 @@ func TestUpdateInstanceDomain(t *testing.T) {
condition: domainRepo.DomainCondition(database.TextOperationEqual, domainName), condition: domainRepo.DomainCondition(database.TextOperationEqual, domainName),
changes: []database.Change{}, changes: []database.Change{},
expected: 0, expected: 0,
err: database.NoChangesError, err: database.ErrNoChanges,
}, },
} }

View File

@@ -105,7 +105,7 @@ func (o *org) Create(ctx context.Context, organization *domain.Organization) err
// Update implements [domain.OrganizationRepository]. // Update implements [domain.OrganizationRepository].
func (o *org) Update(ctx context.Context, id domain.OrgIdentifierCondition, instanceID string, changes ...database.Change) (int64, error) { func (o *org) Update(ctx context.Context, id domain.OrgIdentifierCondition, instanceID string, changes ...database.Change) (int64, error) {
if len(changes) == 0 { if len(changes) == 0 {
return 0, database.NoChangesError return 0, database.ErrNoChanges
} }
builder := database.StatementBuilder{} builder := database.StatementBuilder{}
builder.WriteString(`UPDATE zitadel.organizations SET `) builder.WriteString(`UPDATE zitadel.organizations SET `)

View File

@@ -67,7 +67,7 @@ func (o *orgDomain) Add(ctx context.Context, domain *domain.AddOrganizationDomai
// Subtle: this method shadows the method ([domain.OrganizationRepository]).Update of orgDomain.org. // Subtle: this method shadows the method ([domain.OrganizationRepository]).Update of orgDomain.org.
func (o *orgDomain) Update(ctx context.Context, condition database.Condition, changes ...database.Change) (int64, error) { func (o *orgDomain) Update(ctx context.Context, condition database.Condition, changes ...database.Change) (int64, error) {
if len(changes) == 0 { if len(changes) == 0 {
return 0, database.NoChangesError return 0, database.ErrNoChanges
} }
var builder database.StatementBuilder var builder database.StatementBuilder

View File

@@ -600,7 +600,7 @@ func TestUpdateOrganizationDomain(t *testing.T) {
condition: domainRepo.DomainCondition(database.TextOperationEqual, domainName), condition: domainRepo.DomainCondition(database.TextOperationEqual, domainName),
changes: []database.Change{}, changes: []database.Change{},
expected: 0, expected: 0,
err: database.NoChangesError, err: database.ErrNoChanges,
}, },
} }