diff --git a/.changeset/angular-config-object-startsync.md b/.changeset/angular-config-object-startsync.md new file mode 100644 index 0000000000..20c2486093 --- /dev/null +++ b/.changeset/angular-config-object-startsync.md @@ -0,0 +1,7 @@ +--- +'@tanstack/angular-db': patch +--- + +fix(angular-db): a `{ query }` config-object passed to `injectLiveQuery` now syncs + +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. diff --git a/packages/angular-db/src/index.ts b/packages/angular-db/src/index.ts index 1bce5c6843..59eb1b11cd 100644 --- a/packages/angular-db/src/index.ts +++ b/packages/angular-db/src/index.ts @@ -194,9 +194,11 @@ export function injectLiveQuery(opts: any) { }) } - // Handle LiveQueryCollectionConfig objects + // Handle LiveQueryCollectionConfig objects. Default startSync/gcTime to + // match the query-fn and reactive-options paths, but let an explicit value + // in the config win — otherwise a bare `{ query }` never syncs. if (opts && typeof opts === `object` && typeof opts.query === `function`) { - return createLiveQueryCollection(opts) + return createLiveQueryCollection({ startSync: true, gcTime: 0, ...opts }) } throw new Error(`Invalid options provided to injectLiveQuery`) diff --git a/packages/angular-db/tests/conformance.test.ts b/packages/angular-db/tests/conformance.test.ts index 06fadf4f64..46a51602b2 100644 --- a/packages/angular-db/tests/conformance.test.ts +++ b/packages/angular-db/tests/conformance.test.ts @@ -213,13 +213,7 @@ const angularDriver: LiveQueryDriver = { mountCollection, mountConfig, mountDisabled, - // Divergence the suite surfaced: angular-db's plain `{ query }` config-object - // path calls createLiveQueryCollection(opts) as-is, without injecting - // startSync:true the way the query-fn path does — so a bare `{ query }` never - // syncs and returns empty. React/Vue/Svelte/Solid all auto-start a config - // object; Angular requires an explicit `startSync: true` (its own config test - // passes it). Recorded until angular-db aligns. - knownGaps: [`config-object-input`], + knownGaps: [], features: { serverSnapshot: false, suspense: false }, }