Skip to content

Add type-safe property paths overloads (#2126)#2128

Open
emilienbev wants to merge 2 commits into
AddFTSfrom
AddTypeSafetyPropertyReferences
Open

Add type-safe property paths overloads (#2126)#2128
emilienbev wants to merge 2 commits into
AddFTSfrom
AddTypeSafetyPropertyReferences

Conversation

@emilienbev

@emilienbev emilienbev commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2126

  • You have read the Spring Data contribution guidelines.
  • There is a ticket in the bug tracker for the project in our JIRA.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

This comment was marked as low quality.

@emilienbev emilienbev force-pushed the AddTypeSafetyPropertyReferences branch from 574f973 to 4096ed0 Compare April 9, 2026 08:28

@mp911de mp911de left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a great start. I suggest to consider using <T> someMethod(TypedPropertyPath<P, ?>... paths) instead of TypedPropertyPath<?, ?> to constrain the originating entity type to a single type T. The context is e.g. distinct(Person::getName, Person::getAge) where you would likely want to avoid property references to other entities such as distinct(Person::getName, Order::getId). distinct(Person::getName, TypedPropertyPath.of(Person::getOrder).then(Order::getId) would still work because T is in both cases Person as the origin entity.

* @param distinctFields the property paths to use as distinct fields.
* @since 6.1
*/
default Object distinct(TypedPropertyPath<?, ?>... distinctFields) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Introducing <T> to distinct(TypedPropertyPath<T, ?>... distinctFields) allows to limit property paths originating in the same type. This e.g. prevents distinct(Person::getName, Order::getName) as both properties come from different entities.

*
* @param fields the property paths to project.
* @since 6.1
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Constraining to R could make sense.

@mp911de

mp911de commented Jul 2, 2026

Copy link
Copy Markdown
Member

This pull requests is fine, thanks for addressing earlier comments.

Add TypedPropertyPath overloads for query criteria, distinct,
projections, mutate-in and FTS sort/highlight/fields.

Fixes #2126

Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
Typed overloads baked raw property names into N1QL, KV projections and
mutate-in paths, ignoring @field aliases. Resolve them through the
converter, mirroring the FTS overloads.

Signed-off-by: Emilien Bevierre <emilien.bevierre@couchbase.com>
@emilienbev emilienbev force-pushed the AddTypeSafetyPropertyReferences branch from e95e3ad to 786e4fc Compare July 3, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants