From 05aa2787b2fe23548560fd8f2fa74b7163f68549 Mon Sep 17 00:00:00 2001 From: Christopher Lowenthal Date: Wed, 27 Mar 2024 17:46:47 -0400 Subject: [PATCH] adds context to D and U experimental functions --- pika_psql_experimental.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pika_psql_experimental.go b/pika_psql_experimental.go index 99d9256..b5396b0 100644 --- a/pika_psql_experimental.go +++ b/pika_psql_experimental.go @@ -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) { @@ -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) }