-
Notifications
You must be signed in to change notification settings - Fork 239
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
Support JOIN ... USING ( col1, col2, ... )
#730
Comments
I don't know if this is worth the complication in the code. Especially if we did this in the most type-safe way possible, we should only accept columns both tables have. That'd be tricky. But if we do add this, we could add it to the join builder db.selectFrom('person as a')
.innerJoin('person as b', (join) => join.using(['first_name', 'last_name']))
.select(['a.id', 'b.id']) |
@koskimas Apparently, they behave differently:
https://dev.mysql.com/doc/refman/8.0/en/join.html
https://www.postgresql.org/docs/current/queries-table-expressions.html#QUERIES-JOIN So it's not just syntactic sugar. But is it an important enough difference worth adding 3-4 methods for everywhere and the type complexity of query context (e.g. columns |
Interesting. There is a difference when using an unqualified
Kysely seems to overwrite columns with the same name, so you get the same results in either case. There is only a single |
I'm not concerned with
So if query context is the same, and there's no difference in result (in Kysely), this is all just syntactic sugar. As such, the importance of having this in the API is quite low. |
Yes, the query context is the same |
Is there any update on the implementation of this ? @igalklebanov @koskimas |
We use kysely extensively and love it. I just wanted to upvote this request as it make joins more concise. We use the |
I have an open PR for this in #862 |
Many databases support this shorthand for joins when the column names are the same in both tables.
From Postgres docs:
PostgreSQL: https://www.postgresql.org/docs/current/queries-table-expressions.html
MySQL https://dev.mysql.com/doc/refman/8.0/en/join.html
Sqlite: https://www.sqlite.org/syntax/join-constraint.html
Oracle: https://docs.oracle.com/javadb/10.6.2.1/ref/rrefsqljusing.html
SQL Server: not supported
Usage could be something like
The text was updated successfully, but these errors were encountered: