Skip to content

Conversation

@kevin-dp
Copy link
Contributor

@kevin-dp kevin-dp commented Jul 9, 2025

This PR adds support for a SQL-like distinct operator on queries.
It works on top of electric-sql/d2ts#80 so we need to wait until that PR is merged and a new version of d2mini is released. Until then CI will be red.

@changeset-bot
Copy link

changeset-bot bot commented Jul 9, 2025

🦋 Changeset detected

Latest commit: d24f71e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@tanstack/db Patch
@tanstack/electric-db-collection Patch
@tanstack/query-db-collection Patch
@tanstack/react-db Patch
@tanstack/vue-db Patch
@tanstack/db-example-react-todo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 9, 2025

@tanstack/db-example-react-todo

@tanstack/db

npm i https://pkg.pr.new/@tanstack/db@244

@tanstack/electric-db-collection

npm i https://pkg.pr.new/@tanstack/electric-db-collection@244

@tanstack/query-db-collection

npm i https://pkg.pr.new/@tanstack/query-db-collection@244

@tanstack/react-db

npm i https://pkg.pr.new/@tanstack/react-db@244

@tanstack/vue-db

npm i https://pkg.pr.new/@tanstack/vue-db@244

commit: d24f71e

@samwillis samwillis marked this pull request as ready for review July 9, 2025 15:47
Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

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

This is great!

We should add a test to validate the behaviour when there is no select. We either support that, or don't. If it doesn't worth with no select it should throw an error when you try to use without a select. (I think it should work)

@samwillis
Copy link
Collaborator

@kevin-dp note that I bumped d2mini on your branch after releasing it. CI is green 😁

@kevin-dp
Copy link
Contributor Author

kevin-dp commented Jul 9, 2025

This is great!

We should add a test to validate the behaviour when there is no select. We either support that, or don't. If it doesn't worth with no select it should throw an error when you try to use without a select. (I think it should work)

Yes distinct without select works. There's a test for that here: https://github.com/TanStack/db/pull/244/files#diff-92b5216ddf806ff91a92eeda5701f1093a170697b0328f3297f31ae30d2cde7bR180-R189
But it's not very useful because every row has a unique ID so there's nothing to de-duplicate.

@KyleAMathews
Copy link
Collaborator

If not useful should we just disallow it?

@samwillis
Copy link
Collaborator

Yep, let's require a select with a distinct. It make it much more explicit what it is doing - fewer foot guns.

@kevin-dp
Copy link
Contributor Author

@KyleAMathews @samwillis i added an explicit check to disallow DISTINCT without a SELECT and modified the corresponding unit test accordingly.

Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

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

🚢

Copy link
Collaborator

@KyleAMathews KyleAMathews left a comment

Choose a reason for hiding this comment

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

:shipit:

@kevin-dp kevin-dp merged commit aeee9a1 into TanStack:main Jul 15, 2025
5 checks passed
@github-actions github-actions bot mentioned this pull request Jul 15, 2025
cursor bot pushed a commit that referenced this pull request Jul 16, 2025
Co-authored-by: Sam Willis <sam.willis@gmail.com>
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