我有以下颤动的沼泽查询
(select(recipeGarnishes)..where((tbl) => tbl.postGarnish.equals(true))).get();
如何将distinct
条件添加到查询中?
更新:我想写的查询是:
select DISTINCT garnishName from RecipeGarnishes where postGarnish = 'true'
garnishName
并且postGarnish
是我RecipeGarnishes
表中的列
更新 2:
根据答案,我尝试了这个。
final query = selectOnly(recipeGarnishes, distinct: true)
..addColumns([recipeGarnishes.garnishName])
..where(recipeGarnishes.postGarnish.equals(postGarnish));
List<TypedResult> result = await query.get();
return result.map((row) => row.readTable(recipeGarnishes)).toList();
但它给了我以下错误
Moor:发送 SELECT DISTINCT recipe_garnishes.garnish_name AS "recipe_garnishes.garnish_name" FROM recipe_garnishes WHERE recipe_garnishes.post_garnish = ?; 带参数 [1]
[错误:flutter/lib/ui/ui_dart_state.cc(166)] 未处理的异常:NoSuchMethodError:在 null 上调用了 getter 'garnishName'。