Skip to content

Conversation

@samwillis
Copy link
Contributor

No description provided.

@samwillis samwillis force-pushed the samwillis/groupby-with-no-aggrigate branch from 7621a22 to e912543 Compare June 17, 2025 17:12
@samwillis samwillis changed the title make aggrigates explicity optional on a groupBy make aggregates explicitly optional on a groupBy Jun 17, 2025
@samwillis samwillis review requested due to automatic review settings June 17, 2025 17:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes the aggregates parameter on groupBy optional, adds a test case covering the new default behavior, and updates the project’s changeset.

  • Allow callers to omit the aggregates argument in groupBy by defaulting to an empty object.
  • Add a unit test verifying groupBy works without any aggregates.
  • Update the changeset description to reflect the optional-aggregates change.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/d2mini/src/operators/groupBy.ts Default aggregates parameter to {}
packages/d2mini/tests/operators/groupBy.test.ts New test: groupBy without aggregates
.changeset/clear-impalas-stare.md Release notes for optional-aggregates feature
Comments suppressed due to low confidence (1)

packages/d2mini/tests/operators/groupBy.test.ts:18

  • [nitpick] The test name 'with no aggregate' could be clearer as 'without aggregates' to better describe running groupBy with zero aggregates.
    test('with no aggregate', () => {

'@electric-sql/d2mini': patch
---

make aggrigates explicity optional on a groupBy
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct spelling in the changeset description: 'aggrigates' → 'aggregates' and 'explicity' → 'explicitly'.

Suggested change
make aggrigates explicity optional on a groupBy
make aggregates explicitly optional on a groupBy

Copilot uses AI. Check for mistakes.
K extends GroupKey,
A extends Record<string, AggregateFunction<T, any, any>>,
>(keyExtractor: (data: T) => K, aggregates: A) {
>(keyExtractor: (data: T) => K, aggregates: A = {} as A) {
Copy link

Copilot AI Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using {} as A to default aggregates can hide type mismatches. Consider adding an overload or refining the type parameters to support an omitted-aggregates case without forcing a cast.

Copilot uses AI. Check for mistakes.
@samwillis samwillis merged commit 32d3a0f into main Jun 17, 2025
1 check passed
@samwillis samwillis deleted the samwillis/groupby-with-no-aggrigate branch June 17, 2025 17:19
cursor bot pushed a commit to samwillis/d2ts that referenced this pull request Jul 13, 2025
* make aggrigates explicity optional on a groupBy

* changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants