-- Verify numerus:user_profile on pg

begin;

select
  user_id
, email
, name
, role
, lang_tag
, csrf_token
from numerus.user_profile
where false;

select has_function_privilege('numerus.update_user_profile()', 'execute');

select 1/count(*)
from pg_trigger
where not tgisinternal
        and tgname = 'update_user_profile'
        and tgrelid = 'numerus.user_profile'::regclass
        and tgtype = b'01010001'::int;
                  --    │││││││
                  --    ││││││└─> row
                  --    │││││└──> before
                  --    ││││└───> insert
                  --    │││└────> delete
                  --    ││└─────> update
                  --    │└──────> truncate
                  --    └───────> instead
select 1/count(*)
from pg_trigger
where not tgisinternal
        and tgname = 'encrypt_password'
        and tgrelid = 'auth.user'::regclass
        and tgtype = b'00010111'::int;
                  --    │││││││
                  --    ││││││└─> row
                  --    │││││└──> before
                  --    ││││└───> insert
                  --    │││└────> delete
                  --    ││└─────> update
                  --    │└──────> truncate
                  --    └───────> instead

rollback;
