Select alias when multiple matching identities

This commit is contained in:
M66B
2019-12-06 08:32:03 +01:00
parent 2153df6fc7
commit a0397e068a
2 changed files with 17 additions and 10 deletions

View File

@@ -49,24 +49,23 @@ public interface DaoIdentity {
" ORDER BY name COLLATE NOCASE")
List<EntityIdentity> getIdentities(long account);
@Query("SELECT * FROM identity" +
" WHERE account = :account" +
" AND email = :email COLLATE NOCASE")
List<EntityIdentity> getIdentities(long account, String email);
@Query("SELECT identity.* FROM identity" +
" JOIN account ON account.id = identity.account" +
" WHERE identity.account = :account" +
" AND identity.synchronize AND account.synchronize")
List<EntityIdentity> getSynchronizingIdentities(long account);
@Query("SELECT * FROM identity WHERE id = :id")
EntityIdentity getIdentity(long id);
@Query("SELECT * FROM identity" +
" WHERE account = :account AND email = :email COLLATE NOCASE" +
" ORDER BY CASE WHEN synchronize THEN 0 ELSE 1 END" +
" LIMIT 1")
EntityIdentity getIdentity(long account, String email);
@Query("SELECT COUNT(*) FROM identity WHERE synchronize")
int getSynchronizingIdentityCount();
@Query("SELECT * FROM identity WHERE id = :id")
EntityIdentity getIdentity(long id);
@Insert
long insertIdentity(EntityIdentity identity);