-
Notifications
You must be signed in to change notification settings - Fork 132
Open
Description
- I've validated the bug against the latest version of DB packages
Describe the bug
When using useLiveInfiniteQuery with orderBy(..., 'desc'), deleting an item from the current page does not update the live result if the page has fewer rows than pageSize. The item disappears in storage but remains in the hook’s data until something else changes.
To Reproduce
- Build a descending infinite query (e.g. messages ordered by id desc, pageSize N).
- Ensure the current page has < pageSize items (e.g. last page).
- Delete one item.
- Observe the hook still returns the deleted item; data never refills.
I created an example in stackblitz so you can understand the issue easier: https://stackblitz.com/edit/vitejs-vite-zhiz8bwg
Expected behavior
After a delete, the hook should fetch the next item in order and the deleted row should disappear.
Code
If you have a live infinite query like this and the response has less than 20 items, deletes do not updated the result. If you change the order to asc it works.
const messageListQuery = useLiveInfiniteQuery(
(q) =>
q
.from({ messages: messagesCollection })
.orderBy(({ messages }) => messages.id, 'desc'),
{
pageSize: 20,
getNextPageParam: (lastPage, allPages) =>
lastPage.length === 20 ? allPages.length : undefined,
},
[]
);Metadata
Metadata
Assignees
Labels
No labels