-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve relations recipe #1081
Merged
Merged
Improve relations recipe #1081
Conversation
This file contains 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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
koskimas
force-pushed
the
improve-relations-recipe
branch
from
July 16, 2024 08:41
6e10e73
to
90762d9
Compare
koskimas
force-pushed
the
improve-relations-recipe
branch
from
July 16, 2024 08:49
90762d9
to
d5c21b0
Compare
igalklebanov
approved these changes
Jul 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
Hey 👋 Shouldn't this land on |
True. I'll rebase. |
koskimas
force-pushed
the
improve-relations-recipe
branch
from
July 16, 2024 14:13
d5c21b0
to
83d42fe
Compare
koskimas
force-pushed
the
improve-relations-recipe
branch
from
July 16, 2024 14:13
83d42fe
to
bb65b22
Compare
thecodrr
pushed a commit
to thecodrr/kysely
that referenced
this pull request
Sep 3, 2024
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.
I don't know why it took so long to figure out that this is how we should tell people to write their relation helper functions:
Instead of the old suggestion:
The former only takes in the dependencies (the foreign key) as an argument and provides just as much type-safety as the old way.
The old way had a number of issues: It specified the exact
ExpressionBuilder
type, which doesn't work if the parent query has any joins or uses an alias for theperson
table.Another benefit is that we can work with the
db
type instead of the more complexeb
type. Especially if the relations are deeply nested, the deepesteb
types become really slow, as they inherit their DB types from the parentExpressionBuilders
and etc.Also, this is in line with how we instruct people to write any helper functions:
Another benefit: You can't accidentally select stuff from the parent scope.