Add lateral join methods
See original GitHub issueI’ve been monkey-patching knex to include some lateral join methods but it’d be nice if the library actually supported them. Adding some kind of extra parameter to the existing join methods would be a potentially breaking change, not to mention the existing method signatures aren’t all compatible (lateral joins have to use a subquery). So I propose adding 8 additional methods:
- innerJoinLateral
- leftJoinLateral
- leftOuterJoinLateral
- rightJoinLateral
- rightOuterJoinLateral
- outerJoinLateral
- fullOuterJoinLateral
- crossJoinLateral
Signatures would look something like:
(raw: Raw): QueryBuilder;
(subquery: QueryCallback, on: JoinCallback): QueryBuilder;
(subquery: QueryCallback, on: Raw): QueryBuilder;
(subquery: QueryCallback, columns: { [key: string]: string | number | boolean | Raw }): QueryBuilder;
(subquery: QueryCallback, column1: string, column2: string): QueryBuilder;
(subquery: QueryCallback, column1: string, column2: Raw): QueryBuilder;
(subquery: QueryCallback, column1: string, operator: string, column2: string): QueryBuilder;
I can try to put together a PR, but I wanted to confirm this sort of change would be acceptable first.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:9 (2 by maintainers)
Top Results From Across the Web
How to Use Lateral Joins in PostgreSQL - PopSQL
The lateral keyword allows us to access columns after the FROM statement, and reference these columns "earlier" in the query ("earlier" meaning "written...
Read more >LATERAL Join - Apache Drill
A lateral join is essentially a foreach loop in SQL. A lateral join is represented by the keyword LATERAL with an inner subquery...
Read more >Understanding LATERAL joins in PostgreSQL - CYBERTEC
LATERAL joins are one of the lesser-known features of PostgreSQL and other relational databases such as Oracle, DB2 and MS SQL.
Read more >Lateral Joins - YouTube
How to use Lateral Joins to more efficiently aggregate columns. This episode is brought to you by Hashrocket, a consultancy with expertise ...
Read more >How to Use Lateral Joins | Analysis | Postgre SQL
This section is all about Lateral Joins, import csv, query json column, etc in PosgreSQl.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
And MySQL 8 seems support it too, at least I am using this query without troubles:
Yep it would. If we can come up with some abstraction, which works in multiple databases more work is needed to investigate how exactly each DB supports it and design some API for it which can be supported by most of the drivers.