From f572a9450cb12cfc937302627e379bcc31b1bc0d Mon Sep 17 00:00:00 2001 From: Kevin De Porre Date: Thu, 2 Jul 2026 09:40:27 +0200 Subject: [PATCH] fix(angular-db): config-object input to injectLiveQuery now syncs 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) --- .changeset/angular-config-object-startsync.md | 7 +++++++ packages/angular-db/src/index.ts | 6 ++++-- packages/angular-db/tests/conformance.test.ts | 8 +------- 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 .changeset/angular-config-object-startsync.md 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 }, }