Commit e12514a
Fix isReady return value for early useLiveQuery exits (#886)
* fix(react-db): return isReady true for disabled queries in useLiveQuery
When useLiveQuery's query function returns null or undefined, the query
is effectively "disabled" - there's no async operation to wait for. The
hook should be considered "ready" immediately since there's nothing loading.
This change updates isReady to return true (instead of false) when status
is 'disabled', matching user expectations when conditionally enabling queries.
Fixes #883
* chore: add changeset for isReady disabled queries fix
* fix: return isReady true for disabled queries in all frameworks
Extended the fix for disabled queries to solid-db, vue-db, and svelte-db.
All frameworks now properly handle when query functions return null/undefined
by:
- Returning null for the collection
- Setting status to 'disabled'
- Returning isReady: true (since there's nothing to wait for)
This provides a consistent API across all framework packages and fixes the
common conditional query pattern.
Related to #883
* feat: add TypeScript overloads for disabled queries in all frameworks
Added explicit TypeScript overloads to support returning null/undefined
from query functions across all framework packages:
- solid-db: useLiveQuery
- vue-db: useLiveQuery
- svelte-db: useLiveQuery
- angular-db: injectLiveQuery
This makes the disabled query pattern type-safe, allowing developers to
conditionally enable queries with proper type inference.
Related to #883
* fix(angular-db): fix TypeScript overload compatibility
* test: add disabled query tests for solid-db and vue-db
Added tests to verify that disabled queries (returning null/undefined)
properly return isReady: true. Solid tests pass. Vue tests added but
need additional debugging of the reactive deps implementation.
Related to #883 - addressing Sam's review feedback
* fix(angular-db): fix isReady to return true for disabled queries
- Updated InjectLiveQueryResult interface to support nullable collection and disabled status
- Fixed isReady computed to return true when status is 'disabled'
- Added TypeScript overloads for query functions that can return null/undefined
- Added tests for disabled query functionality with reactive params
* fix(vue-db): add disabled query support with TODO for test pattern
- Added check for query functions that return null/undefined
- Sets status to 'disabled' when collection is null
- Fixed isReady to return true for disabled status
- Added tests but marked as skipped due to Vue reactivity limitations
- TODO: Need different test pattern that works with Vue's reactivity system
* fix(vue-db): fix disabled query support and avoid double-invocation
- Fixed toValue() being called on query functions, which was treating them as getters
- Wrapped query functions to handle null/undefined returns without double-invocation
- All 25 tests now passing including disabled query tests
- Performance improvement: query function only called once by createLiveQueryCollection
---------
Co-authored-by: Claude <[email protected]>1 parent 747c147 commit e12514a
File tree
10 files changed
+543
-34
lines changed- .changeset
- packages
- angular-db
- src
- tests
- react-db
- src
- tests
- solid-db
- src
- tests
- svelte-db/src
- vue-db
- src
- tests
10 files changed
+543
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
64 | 77 | | |
65 | 78 | | |
66 | 79 | | |
| |||
89 | 102 | | |
90 | 103 | | |
91 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
92 | 114 | | |
93 | 115 | | |
94 | 116 | | |
| |||
106 | 128 | | |
107 | 129 | | |
108 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
109 | 141 | | |
110 | 142 | | |
111 | 143 | | |
| |||
123 | 155 | | |
124 | 156 | | |
125 | 157 | | |
126 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
127 | 161 | | |
128 | 162 | | |
129 | 163 | | |
| |||
145 | 179 | | |
146 | 180 | | |
147 | 181 | | |
| 182 | + | |
148 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
149 | 188 | | |
150 | 189 | | |
151 | 190 | | |
| |||
185 | 224 | | |
186 | 225 | | |
187 | 226 | | |
188 | | - | |
| 227 | + | |
189 | 228 | | |
190 | 229 | | |
191 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1031 | 1031 | | |
1032 | 1032 | | |
1033 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1034 | 1149 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2005 | 2005 | | |
2006 | 2006 | | |
2007 | 2007 | | |
2008 | | - | |
| 2008 | + | |
2009 | 2009 | | |
2010 | 2010 | | |
2011 | 2011 | | |
| |||
2044 | 2044 | | |
2045 | 2045 | | |
2046 | 2046 | | |
2047 | | - | |
| 2047 | + | |
2048 | 2048 | | |
2049 | 2049 | | |
2050 | 2050 | | |
| |||
2085 | 2085 | | |
2086 | 2086 | | |
2087 | 2087 | | |
2088 | | - | |
| 2088 | + | |
2089 | 2089 | | |
2090 | 2090 | | |
2091 | 2091 | | |
| |||
0 commit comments