-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[5.2] Cross join support for query builder #12950
Conversation
What about SQL Server? |
Looks like SQL Server supports them too, with no difference in the syntax: https://technet.microsoft.com/en-us/library/ms190690(v=sql.105).aspx |
I looks to broke the old way to crossjoin
The output query of this, after upgrade from 5.2.20 to 5.2.29 doesn't include the ON statement, it broke the query. Also the new crossjoin syntax doesn't support an ON statement. |
As i see the changes from this patch
@GrahamCampbell I recommend to add ON statement support to cross join type. because I have used cross join ON statement with previous latest of Laravel and now it return query without ON statement. 5.2.x => where new (x) shouldn't break any functionality with old(x) |
@xavadu @shahidnajam interesting, so there are use cases that require adding I'll submit a PR with an new test case and fix for this asap! I'll also do some research on this, but based on the output from MySQL's select * from tableA cross join tableB on tableA.column1 = tableB.column2; Is equivalent to the following: select * from tableA cross join tableB where tableA.column1 = tableB.column2; So you could use that as a hotfix? Also, @shahidnajam, cross joins were never officially supported (there's no reference to them in the code, documentation and tests), so you can't really call that a regression. |
@raphaelsaunier Thanks for the answer, we move to use where, @shahidnajam did some benchmark and it have the same performance that using ON (we are working with huge amount of data). The unexpected was that the app got broken after update a patch version upgrade. |
@xavadu Ok, cool! Sorry about that guys! At least it's good to know that you're getting the same performance results as I did. Can you take a quick look at the updated test case here and let me know if it solves your use case? |
I looked at test case. It is OK. Thank you! |
This PR adds a
crossJoin($table)
method to Laravel's query builder to support SQL cross joins.Cross joins are useful in a variety of situations and they are supported by MySQL, PostgreSQL and SQLite so I think it makes sense to add them to the query builder.