I have a component that's ordering with nulls first on an optional inserted_at field:
const { data: threads } = useLiveQuery(
(query) =>
query
.from({ thread: threadCollection })
.innerJoin(
{ membership: membershipCollection },
({ thread, membership }) => eq(thread.id, membership.thread_id)
)
.orderBy(({ thread }) => thread.inserted_at, {
direction: 'desc',
nulls: 'first',
})
.select(({ thread }) => ({
id: thread.id,
name: thread.name,
}))
.where(({ membership }) => eq(membership.user_id, currentUserId)),
[currentUserId]
)
console.log('threads', threads)
This was working fine at this commit of this now merged PR 5f070a0 (I was developing against this as a local workspace dependency). By "worked" I mean I could insert a new thread with a membership locally, have the optimistic state without the inserted_at shown first and then when the write synced back, it updated the row with the correct inserted_at and still sorted first. No flickering, no issues.
Since upgrading to version 0.1.3, the behaviour has regressed. Specifically, I insert locally and it's fine but then when the write syncs back and the optimistic state is removed, my collection seems to lose the previous thread (which was synced data) to just leave the newly inserted thread in the results:
If I refresh the page, I get the correct synced data. If I switch the field to a non-optional field like thread.name it works fine (i.e.: .orderBy(({ thread }) => thread.name, { direction: 'desc', nulls: 'first' }) works fine.
I wonder if it's possibly related to either:
I have a component that's ordering with nulls first on an optional
inserted_atfield:This was working fine at this commit of this now merged PR 5f070a0 (I was developing against this as a local workspace dependency). By "worked" I mean I could insert a new thread with a membership locally, have the optimistic state without the inserted_at shown first and then when the write synced back, it updated the row with the correct inserted_at and still sorted first. No flickering, no issues.
Since upgrading to version
0.1.3, the behaviour has regressed. Specifically, I insert locally and it's fine but then when the write syncs back and the optimistic state is removed, my collection seems to lose the previous thread (which was synced data) to just leave the newly inserted thread in the results:If I refresh the page, I get the correct synced data. If I switch the field to a non-optional field like
thread.nameit works fine (i.e.:.orderBy(({ thread }) => thread.name, { direction: 'desc', nulls: 'first' })works fine.I wonder if it's possibly related to either: