Query constructor

Query(
  1. SQLite sqlite,
  2. List<Sql> columns,
  3. Sql? search,
  4. Sql? where,
  5. List<QueryOrdering> order,
  6. QueryDistinction distinction,
  7. int limit,
)

Creates a Query using the given query configuration parameters.

Implementation

Query(
  this.sqlite,
  this.columns,
  this.search,
  this.where,
  this.order,
  this.distinction,
  this.limit,
) {
  checkState(
    limit == -1 || limit > 0,
    message: () =>
        "Query.new: the limit argument must be -1 to indicate no limit "
        "or greater than 0 to set the limit; got $limit",
  );
  String strAllColumns = [
    columnRowId,
    columnKeyId,
    for (var ordering in order) ////
      ordering.sql.str,
    for (var column in columns) ////
      column.str,
  ].join(", ");
  String strFrom = search == null ? tableMapping : search!.str;
  String strWhere = where == null ? "" : "(${where!.str}) AND ";
  _msgSelect = MessageFormat(
    "SELECT ${escapeFormat(strAllColumns)} FROM ${escapeFormat(strFrom)} "
    "WHERE ${escapeFormat(strWhere)}{0} ORDER BY {1} LIMIT $limit",
  );
  initialize();
}