1129caf00cbb1a4a697e5d8f9c5f3182d11659bc
[squeep-indie-auther] / src / db / sqlite / sql / scope-in-use.sql
1 -- return whether a scope is currently in use, either a profile setting or on a token
2 SELECT EXISTS (
3 SELECT 1 FROM scope s
4 INNER JOIN profile_scope ps USING (scope_id)
5 WHERE s.scope = :scope
6 UNION All
7 SELECT 1 FROM scope s
8 INNER JOIN token_scope ts USING (scope_id)
9 WHERE s.scope = :scope
10 UNION All
11 SELECT 1 FROM scope s
12 WHERE s.scope = :scope AND s.is_permanent
13 ) AS in_use