-
Notifications
You must be signed in to change notification settings - Fork 158
Open
Description
When using syncMode: 'on-demand' collections in a join query, the "lazy" side of the join never receives data.
Reproduction
// All collections use syncMode: 'on-demand' with Electric (offset: 'now')
const { data } = useLiveQuery((query) =>
query
.from({ users: usersCollection })
.leftJoin({ memberships: membershipCollection }, ({ users, memberships }) =>
eq(users.id, memberships.userId)
)
);
// Result: empty array, even though data exists in the databaseWorkaround
Trigger sync on the lazy collection before the join query:
useUsers(); // Simple query that triggers usersCollection sync
// Then the join query worksIn collection-subscriber.ts, subscribeToMatchingChanges() only calls requestSnapshot() when includeInitialState is true. For lazy aliases in joins, includeInitialState is false, so on-demand collections never trigger data loading.
Metadata
Metadata
Assignees
Labels
No labels