Open
Conversation
Adds a new stringAgg aggregate function that concatenates string values within groups with configurable separator and ordering. Uses a two-tier architecture: a stateful incremental path with O(log n) binary search for efficient delta updates, and a stateless fallback for simpler use cases. Includes query builder overloads, compiler integration, docs, and comprehensive test coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-browser-wa-sqlite-persisted-collection
@tanstack/db-ivm
@tanstack/db-react-native-sqlite-persisted-collection
@tanstack/db-sqlite-persisted-collection-core
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Contributor
|
Size Change: +272 B (+0.25%) Total Size: 110 kB
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 4.23 kB ℹ️ View Unchanged
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
stringAggaggregate function that concatenates string values within groups, with configurable separators and ordering. Available across the full stack: query builder, compiler, and IVM engine.Approach
Two-tier IVM architecture:
rowKeyExtractor): Simple sort-and-join on each update. Used when row identity isn't available.Query builder overloads disambiguate the flexible API surface:
The compiler distinguishes separator (literal string) from orderBy (column reference) by expression type, and always provides a
rowKeyExtractorto enable the incremental path.Key invariants
entriesByKeyandorderedEntriesmust stay synchronized —removeStringAggEntrynow throws on desynchronization rather than silently returningtextDirtyfor a full rebuildstring_aggsemantics)Non-goals
Verification
All 140 tests pass, including new coverage for:
rowKeyExtractor)Files changed
packages/db-ivm/src/operators/groupBy.tsstringAggimplementation with binary search, incremental text maintenance, and fallback pathpackages/db-ivm/src/operators/reduce.tspackages/db/src/query/builder/functions.tsstringAggbuilder with 4 overloads andOrderByLiketypepackages/db/src/query/compiler/group-by.tsstringAggpackages/db/src/query/index.tsstringAggdocs/guides/live-queries.md🤖 Generated with Claude Code