Преглед изворни кода

fix: 修复换源 SQL 查询 sourceGroup 为空时无法匹配 null 值

HapeLee пре 4 месеци
родитељ
комит
2a9153aa63
1 измењених фајлова са 3 додато и 2 уклоњено
  1. 3 2
      app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt

+ 3 - 2
app/src/main/java/io/legado/app/data/dao/SearchBookDao.kt

@@ -24,7 +24,8 @@ interface SearchBookDao {
         from searchBooks as t1 inner join book_sources as t2 
         from searchBooks as t1 inner join book_sources as t2 
         on t1.origin = t2.bookSourceUrl 
         on t1.origin = t2.bookSourceUrl 
         where t1.name = :name and t1.author like '%'||:author||'%' 
         where t1.name = :name and t1.author like '%'||:author||'%' 
-        and t2.enabled = 1 and t2.bookSourceGroup like '%'||:sourceGroup||'%'
+        and t2.enabled = 1
+        and (:sourceGroup = "" or t2.bookSourceGroup like '%'||:sourceGroup||'%')
         order by t2.customOrder"""
         order by t2.customOrder"""
     )
     )
     fun changeSourceByGroup(name: String, author: String, sourceGroup: String): List<SearchBook>
     fun changeSourceByGroup(name: String, author: String, sourceGroup: String): List<SearchBook>
@@ -36,7 +37,7 @@ interface SearchBookDao {
         from searchBooks as t1 inner join book_sources as t2 
         from searchBooks as t1 inner join book_sources as t2 
         on t1.origin = t2.bookSourceUrl 
         on t1.origin = t2.bookSourceUrl 
         where t1.name = :name and t1.author like '%'||:author||'%'
         where t1.name = :name and t1.author like '%'||:author||'%'
-        and t2.bookSourceGroup like '%'||:sourceGroup||'%'
+        and (:sourceGroup = "" or t2.bookSourceGroup like '%'||:sourceGroup||'%')
         and (originName like '%'||:key||'%' or t1.latestChapterTitle like '%'||:key||'%')
         and (originName like '%'||:key||'%' or t1.latestChapterTitle like '%'||:key||'%')
         and t2.enabled = 1 
         and t2.enabled = 1 
         order by t2.customOrder"""
         order by t2.customOrder"""