-
Notifications
You must be signed in to change notification settings - Fork 238
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
Implement JOIN ... USING
query
#862
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
because they are mutually exclusive
To implement I see that // merge into person using pet using (id)
db.mergeInto('person').using('pet', (join) => join.using(['id'])) There are a couple ways to solve that (if maintainers here think it's worth solving):
|
* inner join "pet" using ("name") | ||
* ``` | ||
*/ | ||
using(columns: [C, ...C[]]): JoinBuilder<DB, TB, C> { |
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.
Does it make sense to have an overload for a single column? I noticed that other APIs like select
have this.
.innerJoin('pet', join => join.using('col'))
.innerJoin('pet', join => join.using(['col1', 'col2', 'col3']))
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.
Seems OK to me.
I'm not sure about enforcing non-empty with [C, ...C[]]
, I don't think we're THAT strict in other places.
Hi! This is very useful feature for me and I would love to see it in kysely, so thank you @dwickern! Also are there any improvements needed to be done by the community to move this PR forward to be merged? |
@@ -15,7 +16,7 @@ export interface JoinNode extends OperationNode { | |||
readonly kind: 'JoinNode' | |||
readonly joinType: JoinType | |||
readonly table: OperationNode | |||
readonly on?: OnNode | |||
readonly on?: OnNode | JoinUsingNode |
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.
That's a breaking change not worth doing, and also a surprise - how's on
related to using
?
This should make things quite simple, and no need for an extra node type:
readonly on?: OnNode | JoinUsingNode | |
readonly on?: OnNode | |
readonly using?: ReadonlyArray<ColumnNode> |
Sounds like it's not crucial and could've been placed on the method/s. We're usually quite conservative when it comes to adding more generic parameters to existing builders. There has to be a good reason.. e.g. proving TypeScript compile performance is much better this way.
That's fine for now, not worth the extra builder/s IMHO. BYOSK (bring your own SQL knowledge). |
@dwickern Hope you have time to finish the pull request and insure that it gets merged. Since it is a very nice feature and very nice work. |
Fixes #730