Skip to content

Commit

Permalink
fix(tx): added context in tx.QueryBuilder and tx.QueryRowBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlangzi committed Apr 23, 2024
1 parent edb8304 commit c23fb11
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ func (tx *Tx) Query(query string, args ...any) (*Rows, error) {
return tx.QueryContext(context.Background(), query, args...)
}

func (tx *Tx) QueryBuilder(b *Builder) (*Rows, error) {
func (tx *Tx) QueryBuilder(ctx context.Context, b *Builder) (*Rows, error) {

Check warning on line 43 in tx.go

View check run for this annotation

Codecov / codecov/patch

tx.go#L43

Added line #L43 was not covered by tests
query, args, err := b.Build()
if err != nil {
return nil, err
}

return tx.QueryContext(context.TODO(), query, args...)
return tx.QueryContext(ctx, query, args...)

Check warning on line 49 in tx.go

View check run for this annotation

Codecov / codecov/patch

tx.go#L49

Added line #L49 was not covered by tests
}

func (tx *Tx) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error) {
Expand Down Expand Up @@ -76,15 +76,15 @@ func (tx *Tx) QueryRow(query string, args ...any) *Row {
return tx.QueryRowContext(context.Background(), query, args...)
}

func (tx *Tx) QueryRowBuilder(b *Builder) *Row {
func (tx *Tx) QueryRowBuilder(ctx context.Context, b *Builder) *Row {

Check warning on line 79 in tx.go

View check run for this annotation

Codecov / codecov/patch

tx.go#L79

Added line #L79 was not covered by tests
query, args, err := b.Build()
if err != nil {
return &Row{
err: err,
}
}

return tx.QueryRowContext(context.TODO(), query, args...)
return tx.QueryRowContext(ctx, query, args...)

Check warning on line 87 in tx.go

View check run for this annotation

Codecov / codecov/patch

tx.go#L87

Added line #L87 was not covered by tests
}

func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *Row {
Expand Down

0 comments on commit c23fb11

Please sign in to comment.