我已经在会议室中定义了此功能:
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Quer
@Dao
interface PlaceDao {
@Query("SELECT * from place_table")
suspend fun getAllPlaces(): List<Place>
// This query throws IndexOutOfBoundsException
@Query("SELECT * FROM place_table WHERE masterId IN (:guid)")
suspend fun getPlacesByGuids(guid: List<String>): List<Place>?
}
但是,每当我调用getPlacesByGuids
传递的Guid列表在place_table
中没有可用的位置时,而不是返回空列表或null,它会抛出IndexOutOfBoundException。另一方面,getAllPlaces
似乎工作正常,即使place_table
中没有任何内容,也不会导致异常。对我在这里缺少什么有任何想法吗?