~comcloudway/builds.sr.ht

27a80ffed5c357317a75c35bf210fe89b53c0d4c — Thorben Günther 1 year, 7 months ago 71f10ce
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
1 files changed, 2 insertions(+), 2 deletions(-)

M api/graph/schema.resolvers.go
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +2 -2
@@ 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)
			}