copyWith method
Creates a copy of this query with optional overrides for specific properties.
This method implements the copy-with pattern, allowing you to create a new
Sqler instance based on the current one but with some properties modified.
Any parameter that is null
will use the value from the current instance.
Returns a new Sqler instance with the specified modifications.
Example:
var baseQuery = Sqler().from(QField('users'));
var modifiedQuery = baseQuery.copyWith(
selects: [QSelect('name'), QSelect('email')],
limit: Limit(0, 10)
); // Creates a new query with different SELECT and LIMIT
Implementation
Sqler copyWith({
List<QSelectField>? selects,
bool? delete,
List<QField>? from,
List<Where>? where,
Map<String, QVar>? params,
List<QField>? groupBy,
List<Having>? having,
List<QOrder>? orderBy,
Limit? limit,
List<Join>? joins,
List<Map<String, QVar>>? insert,
Map<String, QVar>? update,
}) {
var newQuery = Sqler();
newQuery._select = selects ?? _select;
newQuery._delete = delete ?? _delete;
newQuery._from = from ?? _from;
newQuery._where = where ?? _where;
newQuery._params = params ?? _params;
newQuery._groupBy = groupBy ?? _groupBy;
newQuery._having = having ?? _having;
newQuery._orderBy = orderBy ?? _orderBy;
newQuery._limit = limit ?? _limit;
newQuery._joins = joins ?? _joins;
newQuery._insert = insert ?? _insert;
newQuery._update = update ?? _update;
return newQuery;
}