Skip to content

Commit

Permalink
feat: method Persister.FlushInactiveLoginSessions supports for limit
Browse files Browse the repository at this point in the history
  • Loading branch information
r.v.stupnikov committed Jul 4, 2022
1 parent 3c21f1e commit ca7970e
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions persistence/sql/persister_consent.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,26 +447,31 @@ func (p *Persister) FlushInactiveLoginSessions(ctx context.Context, _ time.Time,

// "hydra_oauth2_authentication_session"
var ls consent.LoginSession
return p.Connection(ctx).RawQuery(fmt.Sprintf(`
DELETE
query := fmt.Sprintf(`
DELETE FROM %[1]s WHERE id in
(SELECT id
FROM %[1]s
WHERE NOT EXISTS
(
SELECT NULL
FROM %[2]s
WHERE %[2]s.login_session_id = %[1]s.id
)
(
SELECT NULL
FROM %[2]s
WHERE %[2]s.login_session_id = %[1]s.id
)
AND NOT EXISTS
(
SELECT NULL
FROM %[3]s
WHERE %[3]s.login_session_id = %[1]s.id
)
(
SELECT NULL
FROM %[3]s
WHERE %[3]s.login_session_id = %[1]s.id
)
LIMIT %[4]d)
`,
(&ls).TableName(),
(&lr).TableName(),
(&cr).TableName()),
).Exec()
(&cr).TableName(),
limit,
)

return p.Connection(ctx).RawQuery(query).Exec()
})
}

Expand Down

0 comments on commit ca7970e

Please sign in to comment.