Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql flatter_moor过滤器选择使用多个值的查询,其中_Sql_Sqlite_Flutter_Filter_Flutter Moor - Fatal编程技术网

Sql flatter_moor过滤器选择使用多个值的查询,其中

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

我正在尝试使用Flatter的
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();
     }