From 27a80ffed5c357317a75c35bf210fe89b53c0d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Wed, 8 Mar 2023 14:51:15 +0100 Subject: [PATCH] api/artifacts: Use SelectAll and ScanAll While working on hut I found a problem with my last patch concerning the pruned URL feature [1]. The current implementation only works if the GraphQL query contains the "created" timestamp, otherwise the "url" field will always be null. That is caused by the zero value for time which is used when created is not populated by the database query. [1]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/39275 --- api/graph/schema.resolvers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/graph/schema.resolvers.go b/api/graph/schema.resolvers.go index 03a2d61..4f65af3 100644 --- a/api/graph/schema.resolvers.go +++ b/api/graph/schema.resolvers.go @@ -90,7 +90,7 @@ func (r *jobResolver) Artifacts(ctx context.Context, obj *model.Job) ([]*model.A }, func(tx *sql.Tx) error { artifact := (&model.Artifact{}).As(`a`) rows, err := database. - Select(ctx, artifact). + SelectAll(artifact). From(`artifact a`). Where(`a.job_id = ?`, obj.ID). RunWith(tx). @@ -101,7 +101,7 @@ func (r *jobResolver) Artifacts(ctx context.Context, obj *model.Job) ([]*model.A defer rows.Close() for rows.Next() { var artifact model.Artifact - if err := rows.Scan(database.Scan(ctx, &artifact)...); err != nil { + if err := rows.Scan(database.ScanAll(&artifact)...); err != nil { panic(err) } -- 2.38.5