From e6980596a27aab4cd02c00ce3d0f3bb17bdbfd1f Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Jun 2018 00:11:35 +0200 Subject: [PATCH] make db queries involving paths case insensitive --- .../simplemobiletools/gallery/interfaces/DirectoryDao.kt | 6 +++--- .../com/simplemobiletools/gallery/interfaces/MediumDao.kt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/DirectoryDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/DirectoryDao.kt index c61717d95..ad1b5afab 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/DirectoryDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/DirectoryDao.kt @@ -17,12 +17,12 @@ interface DirectoryDao { @Insert(onConflict = REPLACE) fun insertAll(directories: List) - @Query("DELETE FROM directories WHERE path = :path") + @Query("DELETE FROM directories WHERE path = :path COLLATE NOCASE") fun deleteDirPath(path: String) - @Query("UPDATE OR REPLACE directories SET thumbnail = :thumbnail, media_count = :mediaCnt, last_modified = :lastModified, date_taken = :dateTaken, size = :size, media_types = :mediaTypes WHERE path = :path") + @Query("UPDATE OR REPLACE directories SET thumbnail = :thumbnail, media_count = :mediaCnt, last_modified = :lastModified, date_taken = :dateTaken, size = :size, media_types = :mediaTypes WHERE path = :path COLLATE NOCASE") fun updateDirectory(path: String, thumbnail: String, mediaCnt: Int, lastModified: Long, dateTaken: Long, size: Long, mediaTypes: Int) - @Query("UPDATE directories SET thumbnail = :thumbnail, filename = :name, path = :newPath WHERE path = :oldPath") + @Query("UPDATE directories SET thumbnail = :thumbnail, filename = :name, path = :newPath WHERE path = :oldPath COLLATE NOCASE") fun updateDirectoryAfterRename(thumbnail: String, name: String, newPath: String, oldPath: String) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt index 13c0278e1..a5dd5e221 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/interfaces/MediumDao.kt @@ -8,7 +8,7 @@ import com.simplemobiletools.gallery.models.Medium @Dao interface MediumDao { - @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite FROM media WHERE parent_path = :path") + @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite FROM media WHERE parent_path = :path COLLATE NOCASE") fun getMediaFromPath(path: String): List @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite FROM media WHERE is_favorite = 1") @@ -23,12 +23,12 @@ interface MediumDao { @Insert(onConflict = REPLACE) fun insertAll(media: List) - @Query("DELETE FROM media WHERE full_path = :path") + @Query("DELETE FROM media WHERE full_path = :path COLLATE NOCASE") fun deleteMediumPath(path: String) - @Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath") + @Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE") fun updateMedium(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String) - @Query("UPDATE media SET is_favorite = :isFavorite WHERE full_path = :path") + @Query("UPDATE media SET is_favorite = :isFavorite WHERE full_path = :path COLLATE NOCASE") fun updateFavorite(path: String, isFavorite: Boolean) }