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
Specifying a default sort order on relations is very useful to ensure that no matter where a relation is expanded, the sort order will be "correct" without the need to specify an explicit (nested) sorting index. It also prevents unwanted behavior from accidental sorting index omissions in parts of the codebase.
Unfortunately, this seems to have broken with the new 6.x release, to the point where related code is failing due to the ORM attempting to sort the root entity by a non-existant index.
Run yarn install, then try yarn run start. You will see that mikro-orm will attempt to resolve the List entity with ListItems, but fails with the error Trying to query by not existing property List.index. The application code does not specify any order by property, let alone index, it is erroneously taken from the relation.
The error does not occur if the index on the relation in List.entity.ts is removed, but we would lose the sorting order.
This used to work correctly in 5.9.7, you can check for yourself by checking out the working-with-5.x branch (and run yarn install to get to 5.9.7) that resolves the relation without any issues.
Describe the bug
Specifying a default sort order on relations is very useful to ensure that no matter where a relation is expanded, the sort order will be "correct" without the need to specify an explicit (nested) sorting index. It also prevents unwanted behavior from accidental sorting index omissions in parts of the codebase.
Unfortunately, this seems to have broken with the new 6.x release, to the point where related code is failing due to the ORM attempting to sort the root entity by a non-existant index.
Reproduction
Sample repository here: https://github.com/RobTS/mikro-orm-bug-sample
Run
yarn install
, then tryyarn run start
. You will see that mikro-orm will attempt to resolve the List entity with ListItems, but fails with the errorTrying to query by not existing property List.index
. The application code does not specify any order by property, let aloneindex
, it is erroneously taken from the relation.The error does not occur if the index on the relation in List.entity.ts is removed, but we would lose the sorting order.
This used to work correctly in 5.9.7, you can check for yourself by checking out the
working-with-5.x
branch (and runyarn install
to get to 5.9.7) that resolves the relation without any issues.What driver are you using?
@mikro-orm/postgresql
MikroORM version
6.1.4
Node.js version
v20.9.0
Operating system
MacOS
Validations
The text was updated successfully, but these errors were encountered: