Skip to content

Commit

Permalink
Update DAO query for the trash can feature
Browse files Browse the repository at this point in the history
  • Loading branch information
z-huang committed Feb 12, 2022
1 parent ea7fd10 commit a0d002d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/com/zionhuang/music/db/daos/SongDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface SongDao {

@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
@Transaction
@Query("SELECT * FROM song WHERE title LIKE '%' || :query || '%'")
@Query("SELECT * FROM song WHERE title LIKE '%' || :query || '%' AND NOT isTrash")
fun searchSongsAsPagingSource(query: String): PagingSource<Int, Song>

@Insert(onConflict = OnConflictStrategy.IGNORE)
Expand Down Expand Up @@ -73,16 +73,16 @@ interface SongDao {
)

companion object {
private const val QUERY_ALL_SONG = "SELECT * FROM song"
private const val QUERY_ARTIST_SONG = "SELECT * FROM song WHERE artistId = %d"
private const val QUERY_ALL_SONG = "SELECT * FROM song WHERE NOT isTrash"
private const val QUERY_ARTIST_SONG = "SELECT * FROM song WHERE artistId = %d AND NOT isTrash"
private const val QUERY_ORDER = " ORDER BY %s %s"
private const val QUERY_PLAYLIST_SONGS =
"""
SELECT song.*, playlist_song.idInPlaylist
FROM playlist_song
JOIN song
ON playlist_song.songId = song.id
WHERE playlistId = :playlistId
WHERE playlistId = :playlistId AND NOT song.isTrash
ORDER BY playlist_song.idInPlaylist
"""
}
Expand Down

0 comments on commit a0d002d

Please sign in to comment.