romeerez / orchid-orm

Orchid ORM
https://orchid-orm.netlify.app/
MIT License
494 stars 14 forks source link

[bug] some repo query is not working in subquery #423

Open bingtsingw opened 6 hours ago

bingtsingw commented 6 hours ago

https://github.com/bingtsingw/orchid-reproduction

bingtsingw commented 6 hours ago

Seems it's only not working in this parentId pattern, which joins the same table with a table name collision.

bingtsingw commented 3 hours ago

I just found that order() field has collisions too.

await commentRepo
  .find(comment.id)
  .selectForList()
  .select({ subcomments: (q) => q.subcomments.select('id', 'createdAt', 'rootId').order({ createdAt: 'ASC' })
  .order({createdAt: 'DESC'})

The order is totally chaotic