Преглед изворни кода

Use proper prepared statements for ArchiveEntries

jvoisin пре 2 година
родитељ
комит
b054506e3a
1 измењених фајлова са 3 додато и 3 уклоњено
  1. 3 3
      internal/storage/entry.go

+ 3 - 3
internal/storage/entry.go

@@ -342,13 +342,13 @@ func (s *Storage) ArchiveEntries(status string, days, limit int) (int64, error)
 					status=$2 AND
 					starred is false AND
 					share_code='' AND
-					created_at < now () - '%d days'::interval
+					created_at < now () - $3::interval
 				ORDER BY
-					created_at ASC LIMIT %d
+					created_at ASC LIMIT $4
 				)
 	`
 
-	result, err := s.db.Exec(fmt.Sprintf(query, days, limit), model.EntryStatusRemoved, status)
+	result, err := s.db.Exec(query, model.EntryStatusRemoved, status, fmt.Sprintf("%d days", days), limit)
 	if err != nil {
 		return 0, fmt.Errorf(`store: unable to archive %s entries: %v`, status, err)
 	}