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
Following is the error produced when running the test:
[Nest] 70996 - 26/09/2022, 21:09:53 ERROR [ExceptionsHandler] Trying to query by not existing property OrderEvent.orderId
Error: Trying to query by not existing property OrderEvent.orderId
at /Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/CriteriaNode.js:28:27
at Array.forEach (<anonymous>)
at new CriteriaNode (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/CriteriaNode.js:23:17)
at new ScalarCriteriaNode (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/ScalarCriteriaNode.js:9:1)
at Function.createScalarNode (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/CriteriaNodeFactory.js:25:22)
at Function.createNode (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/CriteriaNodeFactory.js:22:21)
at Function.createObjectItemNode (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/CriteriaNodeFactory.js:54:25)
at /Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/CriteriaNodeFactory.js:45:28
at Array.reduce (<anonymous>)
at Function.createObjectNode (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/query/CriteriaNodeFactory.js:44:45)
Removing orphanRemoval: true from the Order entity produces a different error.
TypeError: Cannot read properties of undefined (reading '0')
at /Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:343:88
at Array.forEach (<anonymous>)
at /Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:333:23
at Array.forEach (<anonymous>)
at /Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:331:29
at Set.forEach (<anonymous>)
at PostgreSqlDriver.nativeUpdateMany (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:329:14)
at ChangeSetPersister.persistManagedEntitiesBatch (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:174:27)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at ChangeSetPersister.persistManagedEntities (/Users/jbw/code/composite-key-one-to-many-relationship/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:147:13)
mikro-orm version is 5.4.2
The text was updated successfully, but these errors were encountered:
Next time I would appreciate simpler reproductions, not complex web apps with migrations and unrelated stuff to the thing you are actually trying to showcase. You will always get faster response if you do that, it took me 30 minutes to prepare a test case from your repro.
Removing orphanRemoval: true from the Order entity produces a different error.
If you would do that, it means removing items from collection nulls the owning side, but you define that as non-null and primary key, so that would be invalid even without the runtime error. You'd have to make the Event.order a nullable property (hence not a PK).
FYI this is the test minimal test case I'd hope you provide directly:
Code to reproduce and instructions are in the following repo: https://github.com/jbw/composite-key-one-to-many-relationship
Expected behavior
What happens
Relevant code
Entities with composite key and one to many relationship (order 1-* orderItem):
Code which removes items from the
order.events
collectionSteps to reproduce
1. Create a postgresql database in Docker
2. Apply migrations
3. Run the tests
yarn test
Error produced
Following is the error produced when running the test:
Removing
orphanRemoval: true
from theOrder
entity produces a different error.Rerun tests and the following error is produced:
mikro-orm version is
5.4.2
The text was updated successfully, but these errors were encountered: