diff options
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud')
3 files changed, 7 insertions, 5 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java index 3bbd1e97..4dc4b2c9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java @@ -19,7 +19,7 @@ public interface CategoryDao { * * @param accountId The user accountId */ - @Query("DELETE FROM CategoryEntity WHERE accountId = :accountId AND id NOT IN (SELECT category FROM NoteEntity)") + @Query("DELETE FROM CategoryEntity WHERE accountId = :accountId AND id NOT IN (SELECT category_id FROM NoteEntity)") void removeEmptyCategory(long accountId); @Insert diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java index 9fcdfd7b..136d1703 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java @@ -4,6 +4,7 @@ import androidx.room.Dao; import androidx.room.Insert; import androidx.room.Query; +import java.util.List; import java.util.Map; import java.util.Set; @@ -35,8 +36,8 @@ public interface NoteDao { * @param accountId get the remoteIds from all notes of this account * @return {@link Set<String>} remoteIds from all notes */ - @Query("SELECT remoteId FROM NoteEntity WHERE accountId = :accountId AND status != \"LOCAL_DELETED\"") - Set<String> getRemoteIds(long accountId); + @Query("SELECT DISTINCT remoteId FROM NoteEntity WHERE accountId = :accountId AND status != \"LOCAL_DELETED\"") + List<Long> getRemoteIds(long accountId); /** @@ -45,9 +46,9 @@ public interface NoteDao { * @param remoteId int - remote ID of the requested Note * @return {@link DBNote#getId()} */ - @Query("SELECT id FROM noteentity WHERE accountId = :accountId AND remoteId = :remoteId AND status != \"LOCAL_DELETED\"") + @Query("SELECT id FROM NoteEntity WHERE accountId = :accountId AND remoteId = :remoteId AND status != \"LOCAL_DELETED\"") Long getLocalIdByRemoteId(long accountId, long remoteId); - @Query("SELECT favorite, COUNT(*) FROM noteentity WHERE status != \"LOCAL_DELETED\" AND accountId = :accountId GROUP BY favorite ORDER BY favorite") + @Query("SELECT favorite, COUNT(*) FROM NoteEntity WHERE status != \"LOCAL_DELETED\" AND accountId = :accountId GROUP BY favorite ORDER BY favorite") Map<String, Integer> getFavoritesCount(long accountId); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java index 9d277b1a..e98f8e94 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java @@ -25,6 +25,7 @@ public class NoteEntity { private String eTag; private String excerpt; private int scrollY; + @Embedded(prefix = "category_") private CategoryEntity category; public long getId() { |