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
5.6.16 fails with Cannot read properties of undefined (reading '__helper')
#4216
Comments
I need a complete reproduction for such issues. Note that you should have
But that's probably not related. |
Thanks for the quick response!
I'll see if I can work on that in the next couple of days, but I might not get to that until next week.
Ok, I gave that a shot, but it didn't seem to have any effect that I could see in the tests. 🤷 |
It comes from this commit most probably: But it sounds really weird that the value wouldn't be there, so without a failing repro I don't know what to fix. |
@B4nan I've uploaded a reproduction that's failing on 5.6.16 at https://github.com/strmer15/MikroOrmBug - let me know if you have any trouble using it to reproduce the problem. Thanks again! |
Weird, I can't reproduce this in the ORM codebase, but I see your repro failing. Even when I simplified the setup to use sqlite and put everything into one file - the same code copied to the ORM test case is passing, even though they use the exact same version (just updated to the very last dev one). |
Ok, found it, this is about your TS config, you use ES2022 as the target, which has enabled You have two options, disable that in your tsconfig or use |
Thanks @B4nan ! I'll try using the |
The target itself is not a problem, it's only about |
Oh, gotcha - yeah, I'll just disable it in our compiler options, that would be a lot simpler 😁 |
this issue ( |
I think I know a way to get around this, although it has a measurable perf impact, so doing some smart detection during discovery and making it conditionally would be best. We need to first call Since we will be already detecting it, we can start with a warning during discovery and provide a fallback later. Not sure how easy this will be to detect, I'd rather not read stuff from tsconfig, as the same problem could be there on compiled output. Maybe checking the entities provided by user, if we see a relation property, we can be quite sure it should store data in |
…lassFields` enabled Propagation on new entities you create via constructor are supported too, by modifying the entity class prototype, but this technique fails when `useDefineForClassFields` TypeScript compiler flag is enabled (which is true when targeting `ES2022` or higher). You can get around this by using `declare` keyword in your entity definition, or by creating entity instances via `em.create()`, which will ensure the propagation is enabled. Closes #4216
…lassFields` enabled Propagation on new entities you create via constructor are supported too, by modifying the entity class prototype, but this technique fails when `useDefineForClassFields` TypeScript compiler flag is enabled (which is true when targeting `ES2022` or higher). You can get around this by using `declare` keyword in your entity definition, or by creating entity instances via `em.create()`, which will ensure the propagation is enabled. Closes #4216
…lassFields` enabled Propagation on new entities you create via constructor are supported too, by modifying the entity class prototype, but this technique fails when `useDefineForClassFields` TypeScript compiler flag is enabled (which is true when targeting `ES2022` or higher). You can get around this by using `declare` keyword in your entity definition, or by creating entity instances via `em.create()`, which will ensure the propagation is enabled. Closes #4216
…lassFields` enabled Propagation on new entities you create via constructor are supported too, by modifying the entity class prototype, but this technique fails when `useDefineForClassFields` TypeScript compiler flag is enabled (which is true when targeting `ES2022` or higher). You can get around this by using `declare` keyword in your entity definition, or by creating entity instances via `em.create()`, which will ensure the propagation is enabled. Closes #4216
…neForClassFields` Propagation on new entities you create via constructor are supported too, by modifying the entity class prototype, but this technique fails when `useDefineForClassFields` TypeScript compiler flag is enabled (which is true when targeting `ES2022` or higher). You can get around this by using `declare` keyword in your entity definition, or by creating entity instances via `em.create()`, which will ensure the propagation is enabled. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
FYI with #4730 merged, v6 should work fine with the |
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
…neForClassFields` (#4730) Propagation failed when `useDefineForClassFields` TypeScript compiler flag was enabled (which is true when targeting `ES2022` or higher). This PR ensures the propagation works regardless of the flag, by ensuring the getters are set up when registering entity as managed (and on few other places) via the new `EntityHelper.ensurePropagation()` method. Moreover, this PR also enables the `useDefineForClassFields` flag, and since v6 is targeting es2022, we get no transpilation for class properties thanks to this. Closes #4216
Describe the bug
After updating to MikroORM 5.6.16, our tests are now failing with
Cannot read properties of undefined (reading '__helper')
. When pinning back to 5.6.15, everything works as expected.Stack trace
To Reproduce
Steps to reproduce the behavior:
Expected behavior
MikroORM allows the entities to be queried.
Additional context
We actually have two OneToMany / ManyToOne that use the same child model, e.g. from Order->LineItem and Shipment->LineItem. Here's some of declarations:
In the
Order
entity:In the
Shipment
entity:In the
LineItem
entity:Not sure if that matters, I haven't been able to find a workaround for this problem, so I'm not sure what's relevant or not.
Versions
The text was updated successfully, but these errors were encountered: