select
        ev.email_validation_public_id
        , i.identity_public_id
        , e.address
        , ev.code
        , ev.is_oauth_derived
        , ev.created_at
        , ev.expired_at
        , ev.validated_at
        , iev.revoked_at
        , iev.deleted_at
from email_validation               ev
join email                          e   using (email_id)
left join identity_email_validation iev using (email_validation_id)
left join identity                  i   using (identity_id)
where ((?1 is null) or (email_validation_public_id = ?1))
and   ((?2 is null) or (code = ?2));
--
