Skip to content

Commit 42fb59c

Browse files
kevin-dpclaude
andauthored
fix(angular-db): config-object input to injectLiveQuery now syncs (#1638)
The `{ query }` config-object branch called createLiveQueryCollection(opts) without defaulting startSync, unlike the query-fn and reactive-options branches (which force startSync: true). A bare `{ query }` therefore never synced and returned empty. Default startSync: true and gcTime: 0 while honoring explicit values in the config. Clears the angular-db conformance knownGap (config-object-input). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b2f305a commit 42fb59c

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@tanstack/angular-db': patch
3+
---
4+
5+
fix(angular-db): a `{ query }` config-object passed to `injectLiveQuery` now syncs
6+
7+
The config-object branch called `createLiveQueryCollection(opts)` without defaulting `startSync`, unlike the query-function and reactive-options branches (which force `startSync: true`), so a bare `{ query }` never started syncing and produced no data. It now defaults `startSync: true` and `gcTime: 0` while still honoring any explicit values in the config.

packages/angular-db/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ export function injectLiveQuery(opts: any) {
191191
})
192192
}
193193

194-
// Handle LiveQueryCollectionConfig objects
194+
// Handle LiveQueryCollectionConfig objects. Default startSync/gcTime to
195+
// match the query-fn and reactive-options paths, but let an explicit value
196+
// in the config win — otherwise a bare `{ query }` never syncs.
195197
if (opts && typeof opts === `object` && typeof opts.query === `function`) {
196-
return createLiveQueryCollection(opts)
198+
return createLiveQueryCollection({ startSync: true, gcTime: 0, ...opts })
197199
}
198200

199201
throw new Error(`Invalid options provided to injectLiveQuery`)

packages/angular-db/tests/conformance.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,7 @@ const angularDriver: LiveQueryDriver = {
214214
mountCollection,
215215
mountConfig,
216216
mountDisabled,
217-
// Divergence the suite surfaced: angular-db's plain `{ query }` config-object
218-
// path calls createLiveQueryCollection(opts) as-is, without injecting
219-
// startSync:true the way the query-fn path does — so a bare `{ query }` never
220-
// syncs and returns empty. React/Vue/Svelte/Solid all auto-start a config
221-
// object; Angular requires an explicit `startSync: true` (its own config test
222-
// passes it). Recorded until angular-db aligns.
223-
knownGaps: [`config-object-input`],
217+
knownGaps: [],
224218
features: { serverSnapshot: false, suspense: false },
225219
}
226220

0 commit comments

Comments
 (0)