Sql flatter_moor过滤器选择使用多个值的查询,其中
我正在尝试使用Flatter的Sql flatter_moor过滤器选择使用多个值的查询,其中,sql,sqlite,flutter,filter,flutter-moor,Sql,Sqlite,Flutter,Filter,Flutter Moor,我正在尝试使用Flatter的moor包对我的数据库实现一个多值过滤器 moor已经有了where方法,该方法接受表达式并将其转换为sql语句。比如: (select(exercisesTable)..where((e) => (e.name.equals(name)))).get(); 但是我需要过滤数据,因为有多个值。 在搜索文档后,我找到了两种可能的解决方案: 使用CutomExpressionClass: Expression Expression=CustomExpress
moor
包对我的数据库实现一个多值过滤器
moor
已经有了where
方法,该方法接受表达式并将其转换为sql语句。比如:
(select(exercisesTable)..where((e) => (e.name.equals(name)))).get();
但是我需要过滤数据,因为有多个值。
在搜索文档后,我找到了两种可能的解决方案:
CutomExpressionClass
:
Expression Expression=CustomExpression(“水在4.0和5.0之间,蛋白质在4.0和15.0之间,描述如CHESS%”;
但我得到了这个错误:*
SqliteException:near“;”:语法错误,SQL逻辑错误
自定义选择语句
:我没有尝试过这一点,因为我相信问题在于sql本身,而不是moor包
从SingleTableQueryMixin::where方法()的注释中: 根据这一点,您可以使用以下内容:
Future<List<TableData>> getTableList({int position, int type}) {
final _select = select(table);
if (position != null) {
_select..where((tbl) => tbl.position.equals(position));
}
if (type != null) {
_select..where((tbl) => tbl.type.equals(type));
}
return _select.get();
}
Future getTableList({int-position,int-type}){
最终选择=选择(表格);
如果(位置!=null){
_选择..其中((tbl)=>tbl.position.equals(position));
}
if(type!=null){
_选择..其中((tbl)=>tbl.type.equals(type));
}
返回_select.get();
}
所以,我应该学会如何仔细阅读。这绝对是我需要的,谢谢。
...
/// If a where condition has already been set before, the resulting filter
/// will be the conjunction of both calls.
...
Future<List<TableData>> getTableList({int position, int type}) {
final _select = select(table);
if (position != null) {
_select..where((tbl) => tbl.position.equals(position));
}
if (type != null) {
_select..where((tbl) => tbl.type.equals(type));
}
return _select.get();
}