Skip to content

Commit 59f4f0a

Browse files
committed
Fix search bug
1 parent ce97396 commit 59f4f0a

File tree

1 file changed

+10
-2
lines changed
  • app/src/main/java/com/vladshurakov/jetnotesapp/feature_notes/data/data_source

1 file changed

+10
-2
lines changed

app/src/main/java/com/vladshurakov/jetnotesapp/feature_notes/data/data_source/NoteDao.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ interface NoteDao {
3838
@Query("SELECT * FROM note WHERE folder = :folder ORDER BY pinned DESC, timestamp ASC")
3939
fun getAsc(folder: Folder): Flow<List<NoteEntity>>
4040

41-
@Query("SELECT * FROM note WHERE (title LIKE '%' || :query || '%' OR content LIKE '%' || :query || '%') ORDER BY pinned DESC, timestamp DESC")
41+
@Query(
42+
"SELECT * FROM note WHERE " +
43+
"(title LIKE '%' || :query || '%' OR content LIKE '%' || :query || '%') " +
44+
"AND folder = 'NOTES' ORDER BY pinned DESC, timestamp DESC"
45+
)
4246
fun getDesc(query: String): Flow<List<NoteEntity>>
4347

44-
@Query("SELECT * FROM note WHERE (title LIKE '%' || :query || '%' OR content LIKE '%' || :query || '%') ORDER BY pinned ASC, timestamp ASC")
48+
@Query(
49+
"SELECT * FROM note WHERE " +
50+
"(title LIKE '%' || :query || '%' OR content LIKE '%' || :query || '%') " +
51+
"AND folder = 'NOTES' ORDER BY pinned ASC, timestamp ASC"
52+
)
4553
fun getAsc(query: String): Flow<List<NoteEntity>>
4654
}

0 commit comments

Comments
 (0)