lab2: fix review — cache consistency, readiness, timeouts, uuid validation, tuple index
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-10 01:14:56 +03:00
parent a327909856
commit 40f260612f
21 changed files with 185 additions and 189 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ func NewMessageRepository(pool *pgxpool.Pool) *MessageRepository {
func (r *MessageRepository) Create(ctx context.Context, msg *domain.Message) error {
const q = `
INSERT INTO messages (id, chat_id, sender_id, text, created_at)
VALUES ($1, $2::uuid, $3::uuid, $4, $5)
VALUES ($1::uuid, $2::uuid, $3::uuid, $4, $5)
`
if _, err := r.pool.Exec(ctx, q, msg.ID, msg.ChatID, msg.SenderID, msg.Text, msg.CreatedAt); err != nil {
return fmt.Errorf("insert message: %w", err)
@@ -34,7 +34,7 @@ func (r *MessageRepository) ListByChat(ctx context.Context, chatID string, curso
SELECT id, chat_id, sender_id, text, created_at
FROM messages
WHERE chat_id = $1::uuid
AND (created_at > $2 OR (created_at = $2 AND id > $3::uuid))
AND (created_at, id) > ($2::timestamptz, $3::uuid)
ORDER BY created_at, id
LIMIT $4
`