X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=src%2Fdb%2Fsqlite%2Fsql%2Fscope-in-use.sql;fp=src%2Fdb%2Fsqlite%2Fsql%2Fscope-in-use.sql;h=1129caf00cbb1a4a697e5d8f9c5f3182d11659bc;hp=0000000000000000000000000000000000000000;hb=b0103b0d496262c438b40bc20304081dbfe41e73;hpb=8ed81748bce7cea7904cac7225b20a60cafdfc16 diff --git a/src/db/sqlite/sql/scope-in-use.sql b/src/db/sqlite/sql/scope-in-use.sql new file mode 100644 index 0000000..1129caf --- /dev/null +++ b/src/db/sqlite/sql/scope-in-use.sql @@ -0,0 +1,13 @@ +-- return whether a scope is currently in use, either a profile setting or on a token +SELECT EXISTS ( + SELECT 1 FROM scope s + INNER JOIN profile_scope ps USING (scope_id) + WHERE s.scope = :scope + UNION All + SELECT 1 FROM scope s + INNER JOIN token_scope ts USING (scope_id) + WHERE s.scope = :scope + UNION All + SELECT 1 FROM scope s + WHERE s.scope = :scope AND s.is_permanent +) AS in_use