You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: FINDONE_JOINS_BUG_INVESTIGATION.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,12 @@ const query = useLiveQuery(
12
12
q
13
13
.from({ todo: todoCollection })
14
14
.where(({ todo }) =>eq(todo.id, id))
15
-
.leftJoin({ todoOptions: todoOptionsCollection }, ({ todo, todoOptions }) =>
16
-
eq(todo.id, todoOptions.todoId)
15
+
.leftJoin(
16
+
{ todoOptions: todoOptionsCollection },
17
+
({ todo, todoOptions }) =>eq(todo.id, todoOptions.todoId)
17
18
)
18
19
.findOne() // ❌ Causes type of query.data to become never
19
-
);
20
+
)
20
21
```
21
22
22
23
### Workaround
@@ -29,11 +30,12 @@ const query = useLiveQuery(
29
30
q
30
31
.from({ todo: todoCollection })
31
32
.where(({ todo }) =>eq(todo.id, id))
32
-
.leftJoin({ todoOptions: todoOptionsCollection }, ({ todo, todoOptions }) =>
33
-
eq(todo.id, todoOptions.todoId)
33
+
.leftJoin(
34
+
{ todoOptions: todoOptionsCollection },
35
+
({ todo, todoOptions }) =>eq(todo.id, todoOptions.todoId)
34
36
)
35
37
.limit(1) // ✅ Works correctly
36
-
);
38
+
)
37
39
```
38
40
39
41
## Root Cause Analysis
@@ -62,6 +64,7 @@ const query = useLiveQuery(
62
64
Theissuewasinthe`MergeContextWithJoinType`typedefinition, which was forcing `singleResult` to be explicitly `false` instead of preserving its original value.
63
65
64
66
**Before (Buggy)**:
67
+
65
68
```typescript
66
69
export type MergeContextWithJoinType<
67
70
TContext extends Context,
@@ -87,6 +90,7 @@ export type MergeContextWithJoinType<
0 commit comments