room hilt @Query 不符合我的预期 return
room hilt @Query doesn't return what i expected
一些查询 return 在 RecipeDao.kt 中得到正确结果,ide 的 side 面板写道:在 com.example.mypackage.data.RecipeDao_Impl 中实现
但其他人没有 return 结果
就像这个给定日期的问题我提取应用程序数据库并在其他 sqlite 浏览器应用程序中查询它并成功执行
like this image
CoroutineScope(Dispatchers.IO).launch {
dateNoDay?.get(pos)?.let { dateQuery -> //dateQuery here is yyyy/M
allRecipesByMonth = async {
recipeDao.getAllRecipesByMonth(
"'$dateQuery/01'",
"'$dateQuery/31'"
)
}
}
withContext(Dispatchers.Main) {
allRecipesByMonth.await()
archiveRecipesAdapter = context?.let {
ArchiveRecipesAdapter(
allFactorsByMonthOfYear.await(),
it
)
}
archiveRecipesAdapter?.notifyDataSetChanged()
}
}
}
更新
无法比较作为日期的字符串。我有两个解决方案。
1.change 它变成 long 并使用它(推荐)
2.change 到 INTEGER 的 3 列(不推荐)
出于某种原因,我采用了第二种方法并且它奏效了。
一些查询 return 在 RecipeDao.kt 中得到正确结果,ide 的 side 面板写道:在 com.example.mypackage.data.RecipeDao_Impl 中实现 但其他人没有 return 结果 就像这个给定日期的问题我提取应用程序数据库并在其他 sqlite 浏览器应用程序中查询它并成功执行
like this image
CoroutineScope(Dispatchers.IO).launch {
dateNoDay?.get(pos)?.let { dateQuery -> //dateQuery here is yyyy/M
allRecipesByMonth = async {
recipeDao.getAllRecipesByMonth(
"'$dateQuery/01'",
"'$dateQuery/31'"
)
}
}
withContext(Dispatchers.Main) {
allRecipesByMonth.await()
archiveRecipesAdapter = context?.let {
ArchiveRecipesAdapter(
allFactorsByMonthOfYear.await(),
it
)
}
archiveRecipesAdapter?.notifyDataSetChanged()
}
}
}
更新
无法比较作为日期的字符串。我有两个解决方案。
1.change 它变成 long 并使用它(推荐)
2.change 到 INTEGER 的 3 列(不推荐)
出于某种原因,我采用了第二种方法并且它奏效了。