getStrSeek method
Returns a WHERE clause condition for query seek-based pagination.
Implementation
@protected
String getStrSeek(QueryDirection direction, {required bool first}) {
if (first) {
if (order.isEmpty) ////
return "1";
return order
.map((var o) => o.sql.isNotEqual(SqlL(null)))
.reduce((var v, var e) => v & e)
.str;
}
bool forward = direction == QueryDirection.forward;
bool distinctionRowId = distinction == QueryDistinction.rowid;
SqlI id = SqlI(distinctionRowId ? columnRowId : columnKeyId);
Sql seek = forward ? id > Sql(":0") : id < Sql(":0");
for (int i = order.length - 1; i >= 0; --i) {
Sql x = order[i].sql;
Sql p = Sql(":${order.length - i}");
bool ascending = order[i].sorting == QuerySorting.ascending;
if ((ascending && forward) || (!ascending && !forward))
seek = (x >= p) & ((x > p) | seek);
else
seek = (x <= p) & ((x < p) | seek);
}
return seek.str;
}