Skip to content
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

OrderBy ignored when doing leftJoinAndSelect #1171

Closed
AzariasB opened this issue Dec 7, 2020 · 3 comments
Closed

OrderBy ignored when doing leftJoinAndSelect #1171

AzariasB opened this issue Dec 7, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@AzariasB
Copy link
Contributor

AzariasB commented Dec 7, 2020

Describe the bug
When using the query builder, and doing a leftJoinAndSelect followed by a orderBy, the order is not taken into account (seems like it's then ordered by ids instead)

Stack trace

// No stack trace, just a bad result

To Reproduce
Steps to reproduce the behavior:

  1. Create a QueryBuilder
  2. Do a left join and select with it
  3. Add an orderBy clause
  4. Get the result list

Here's a reproduction repo

Expected behavior
When doing an orderby, the order of the resulting list should be the same, whether there is a join or not.

Additional context
The current workaround for this issue is to use the sort method, but it can be costly for long lists

Versions

Dependency Version
node 14.15
typescript 4.1.2
mikro-orm 4.3.3
your-driver postgresql
@B4nan B4nan added the bug Something isn't working label Dec 8, 2020
@B4nan
Copy link
Member

B4nan commented Dec 8, 2020

Interesting, another issue there is that .leftJoinAndSelect('b', 'b') is not populating the b property - that is because of the same table and alias name apparently, as .leftJoinAndSelect('b', 'b0') fixes that particular problem.

@AzariasB
Copy link
Contributor Author

AzariasB commented Dec 8, 2020

Well that's two birds with one stone for you :)

@B4nan B4nan closed this as completed in 7453816 Dec 8, 2020
B4nan added a commit that referenced this issue Dec 8, 2020
Previously fetch-joining failed when there was a conflict in aliased property name
and parent entity property name and the alias is same as the parent property name
(e.g. property `Book.author` and alias `author`).

Related #1171
@AzariasB
Copy link
Contributor Author

AzariasB commented Dec 8, 2020

As always, thank your very much for the excellent work you put in this awesome ORM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants