Skip to content

Commit

Permalink
adds context to D and U experimental functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Lowenthal committed Mar 27, 2024
1 parent 61bf1c6 commit 05aa278
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pika_psql_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func (b *basePsql[T]) F(keyval ...any) QuerySet[T] {
return b.Args(args).Filter(queries...)
}

func (b *basePsql[T]) D(x *T) error {
func (b *basePsql[T]) D(ctx context.Context, x *T) error {
id := b.findID(x)
if id == nil {
return fmt.Errorf("id not found")
}

qs := b.F("id", id)
return qs.Delete(context.Background())
return qs.Delete(ctx)
}

func (b *basePsql[T]) Transaction(ctx context.Context) (QuerySet[T], error) {
Expand All @@ -62,12 +62,12 @@ func (b *basePsql[T]) Transaction(ctx context.Context) (QuerySet[T], error) {
return Q[T](ts), nil
}

func (b *basePsql[T]) U(x *T) error {
func (b *basePsql[T]) U(ctx context.Context, x *T) error {
id := b.findID(x)
if id == nil {
return fmt.Errorf("id not found")
}

qs := b.F("id", id)
return qs.Update(context.Background(), x)
return qs.Update(ctx, x)
}

0 comments on commit 05aa278

Please sign in to comment.