You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inner joining to left joined table returns 0 rows #3080
Steps to reproduce or a small repository showing the problem:
Hey,
We ran into a problem with joining some relations and getting 0 results. The problem (and the solution) is described best in this StackOverflow.
I, therefore, don't know if this should be considered a bug or a feature request, because the order of the ON keywords and joins seems to matter in this instance as can be seen from the accepted answer in the StackOverflow question.
I guess a solution could be to move the ON logic to underneath all the LEFT and INNER joins and reverse the order. Or would this be too simple if there's a whole bunch of joins instead of just 2?
For the time being, we're planning on making sure the child relations are always LEFT JOIN instead of 'INNER JOIN' so at least we're getting our results. This will give artefacts, but the amount of instances in our codebase like this at the moment is not that high.
Did you already test/debug the output SQL and running it without typeorm? It would be helpful if you provide a code snippet.
You can specify explicitly which columns should be joined, by using the third parameter. One time I had the issue that the relation was not resolved properly and invalid SQL was generated. This was the workaround.
Activity
jonaaix commentedon Nov 9, 2018
Did you already test/debug the output SQL and running it without typeorm? It would be helpful if you provide a code snippet.
You can specify explicitly which columns should be joined, by using the third parameter. One time I had the issue that the relation was not resolved properly and invalid SQL was generated. This was the workaround.
Kononnable commentedon Dec 8, 2018
@harm-less
Without code snippet, generated query and query you want to generate we wont't be able to help.
pleerock commentedon Jan 7, 2019
@harm-less did you find a solution for your issue?
harm-less commentedon Jan 7, 2019
I didn't yet, I'm still trying to find time to properly reply to this topic but other priorities keep coming up at work atm.
pleerock commentedon Jan 7, 2019
let me close this issue then, create a new one with additional information once you'll have a time