feat: Add attachJoinRef extension method#86
Merged
chinhtrung merged 4 commits intomainfrom Jan 14, 2026
Merged
Conversation
luanpotter
reviewed
Dec 30, 2025
yawn-api/src/main/kotlin/com/faire/yawn/criteria/builder/TypeSafeCriteriaBuilder.kt
Outdated
Show resolved
Hide resolved
luanpotter
reviewed
Dec 30, 2025
yawn-api/src/main/kotlin/com/faire/yawn/criteria/builder/TypeSafeCriteriaBuilder.kt
Outdated
Show resolved
Hide resolved
luanpotter
reviewed
Dec 30, 2025
|
|
||
| // Check if a join already exists for this column definition | ||
| val existingJoin = query.joins.find { existingJoin -> | ||
| existingJoin.columnDef === joinColumnDef |
Member
There was a problem hiding this comment.
will column def equality work like that?
Contributor
Author
There was a problem hiding this comment.
yes I think so, I think we want to check the same object reference in this case.
luanpotter
reviewed
Dec 30, 2025
Member
luanpotter
left a comment
There was a problem hiding this comment.
My only concern with getOrCreateJoinRef is that when it is hidden within attachJoinRef it makes it a bit less clear and more magical that you might be re-using joins. the design behind having join refs in the first place was to separate intent on re-using a join versus creating a duplicate join (which is totally valid in SQL). having such a function will hide this distinction, making the existence of join refs in the first place less grounded
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
Add attachJoinRef extension method to TypeSafeCriteriaBuilder that creates joins and returns both the criteria and join reference for reuse.
Motivation
I have seen some cases that we implement a base helper method that can be reused in different query methods. However, it's a bit troublesome when the usage wants to reuse the join reference that has been called in the base query. This method help us ease the process.
What's Changed
Benefits
Example Usage