mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-26 02:05:31 +00:00
fix(timeline): serve an empty older page before a retired first turn in SQLite
The SQLite backend's `before` selection had the same gap as the memory projection fixed on the base branch: with no active row by the cursor it returned the first later row as the start of an empty page. It now serves the empty page, matching the memory backend in the contract and differential tests.
This commit is contained in:
@@ -1062,7 +1062,14 @@ class StoredPageSelection {
|
||||
|
||||
private selectBefore(input: ProjectedTimelinePageOptions): ProjectedTimelinePageSelection {
|
||||
const endSeq = Math.min(input.bounds.maxSeq, (input.cursorSeq ?? input.bounds.maxSeq + 1) - 1);
|
||||
if (endSeq < input.bounds.minSeq) {
|
||||
const lastInPage = this.sql.get<RowShape>(
|
||||
`SELECT ${SHAPE_COLUMNS} FROM timeline_rows WHERE ${ACTIVE} AND seq_start <= ? ` +
|
||||
"ORDER BY seq_start DESC LIMIT 1",
|
||||
this.scopeId,
|
||||
endSeq,
|
||||
);
|
||||
// No active row starts by `endSeq`, as when a rewind retired everything before the cursor.
|
||||
if (endSeq < input.bounds.minSeq || !lastInPage) {
|
||||
return {
|
||||
entries: [],
|
||||
startSeq: null,
|
||||
@@ -1082,13 +1089,7 @@ class StoredPageSelection {
|
||||
this.scopeId,
|
||||
endSeq,
|
||||
);
|
||||
const lastInPage = this.sql.get<RowShape>(
|
||||
`SELECT ${SHAPE_COLUMNS} FROM timeline_rows WHERE ${ACTIVE} AND seq_start <= ? ` +
|
||||
"ORDER BY seq_start DESC LIMIT 1",
|
||||
this.scopeId,
|
||||
endSeq,
|
||||
);
|
||||
if (input.wholeTurns && after && lastInPage) {
|
||||
if (input.wholeTurns && after) {
|
||||
// Choose the window before extending the right edge, so a prompt jump cannot lose its
|
||||
// target when the next turn is arbitrarily large.
|
||||
let previous = lastInPage;
|
||||
|
||||
Reference in New Issue
Block a user