Use prepared statement for intervals
This commit is contained in:
parent
b054506e3a
commit
7660910232
2 changed files with 4 additions and 4 deletions
|
@ -128,9 +128,9 @@ func (s *Storage) CleanOldSessions(days int) int64 {
|
|||
DELETE FROM
|
||||
sessions
|
||||
WHERE
|
||||
created_at < now() - interval '%d days'
|
||||
created_at < now() - $1::interval
|
||||
`
|
||||
result, err := s.db.Exec(fmt.Sprintf(query, days))
|
||||
result, err := s.db.Exec(query, fmt.Sprintf("%d days", days))
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -170,9 +170,9 @@ func (s *Storage) CleanOldUserSessions(days int) int64 {
|
|||
DELETE FROM
|
||||
user_sessions
|
||||
WHERE
|
||||
created_at < now() - interval '%d days'
|
||||
created_at < now() - $1::interval
|
||||
`
|
||||
result, err := s.db.Exec(fmt.Sprintf(query, days))
|
||||
result, err := s.db.Exec(query, fmt.Sprintf("%d days", days))
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue