From 4a94b0a5a0689008673c9f4c043984609507d02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Thu, 22 Oct 2026 16:10:23 +0300 Subject: [PATCH] fix(postgres):lab4 add missing ExistingKeys to AttachmentRepo --- .../internal/storage/postgres/attachments.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/backend/internal/storage/postgres/attachments.go b/backend/internal/storage/postgres/attachments.go index 57c2efd..c824e8c 100644 --- a/backend/internal/storage/postgres/attachments.go +++ b/backend/internal/storage/postgres/attachments.go @@ -174,3 +174,27 @@ func (r *AttachmentRepo) DeletePending(ctx context.Context, id string) error { } return nil } + +func (r *AttachmentRepo) ExistingKeys(ctx context.Context, keys []string) ([]string, error) { + if len(keys) == 0 { + return []string{}, nil + } + const q = `SELECT object_key FROM attachments WHERE object_key = ANY($1::text[])` + rows, err := r.pool.Query(ctx, q, keys) + if err != nil { + return nil, mapError(err) + } + defer rows.Close() + + out := make([]string, 0, len(keys)) + for rows.Next() { + var k string + if err := rows.Scan(&k); err != nil { + return nil, mapError(err) + } + out = append(out, k) + } + return out, mapError(rows.Err()) +} + +var _ domain.AttachmentRepository = (*AttachmentRepo)(nil)