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
Describe the bug
When using the find method on a repository changing the order of an $and children returns wrong results. See down below Query1 and Query2 that should provide identical results. Check the where conditions aliases and see e1.id, e1.name, e1.created_at for Query1 and e0.id, e0.name, e1.created_at for Query2 that are different. In Query1 it seems to be using only the tag table for filtering while in Query2 it uses both article and tag correctly.
select "e0".* from "blog"."article" as "e0"
left join "blog"."article_tag" as "e2" on "e0"."id" = "e2"."article_id"
left join "blog"."tag" as "e1" on "e2"."tag_id" = "e1"."id"
where
"e1"."name" in ('tag1') and
"e1"."id" != 6 and
"e1"."created_at" > '2020-08-26T20:01:48.863Z'
order by "e0"."created_at" asc limit 7
select "e0".* from "blog"."article" as "e0"
left join "blog"."article_tag" as "e2" on "e0"."id" = "e2"."article_id"
left join "blog"."tag" as "e1" on "e2"."tag_id" = "e1"."id"
where
"e0"."id" != 6 and
"e0"."created_at" > '2020-08-26T20:01:48.863Z' and
"e1"."name" in ('tag1')
order by "e0"."created_at" asc limit 7
providing us with expected results.
To Reproduce
Steps to reproduce the behavior:
Create 2 entities Article(id, createdAt), Tag(id, name, createdAt) and add a ManyToMany relationship between them.
Use the ArticleEntityRepository to run these 2 queries and see the difference.
Expected behavior
The expected behavior is to have the same result no matter the order of the operations.
Additional context
Versions
Dependency
Version
node
14.7.0
@mikro-orm/cli
^4.0.0-rc.4
@mikro-orm/core
^4.0.0-rc.4
@mikro-orm/migrations
^4.0.0-rc.4
@mikro-orm/nestjs
^4.0.0-alpha.3
@mikro-orm/postgresql
^4.0.0-rc.4
@mikro-orm/reflection
^4.0.0-rc.4
typescript
^3.7.4
The text was updated successfully, but these errors were encountered:
I agree but I'm working on a graphql endpoint that should support all versions of the query that's all. I've only given you a purely theoretical example above 😛 . Thanks for the fast response and all the hard work 👍 🥇
Describe the bug
When using the
find
method on a repository changing the order of an$and
children returns wrong results. See down below Query1 and Query2 that should provide identical results. Check thewhere
conditions aliases and seee1.id
,e1.name
,e1.created_at
for Query1 ande0.id
,e0.name
,e1.created_at
for Query2 that are different. In Query1 it seems to be using only thetag
table for filtering while in Query2 it uses botharticle
andtag
correctly.Stack trace
Query 1:
transforms into:
providing us with wrong results.
Query 2:
transforms into:
providing us with expected results.
To Reproduce
Steps to reproduce the behavior:
ManyToMany
relationship between them.Expected behavior
The expected behavior is to have the same result no matter the order of the operations.
Additional context
Versions
The text was updated successfully, but these errors were encountered: