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
Support mapping the same column across discriminator subclasses #2388
Comments
Interesting thing to note, this behavior seems to be related to the fact that the class property names are different. In the example above, the |
I believe we have a single hydration functions for this, and in general everything is processed in the same way, just the entity class is picked based on the discriminator. This is simply not supported use case right now, I believe there is even a validation that should forbid overriding properties defined in base STI entities, but here you are defining it on the same level so it fails to trigger. |
i'm not sure what the implications are w/r/t propagation and other internals, but as far as fixing my insertion issues, it just requires some de-dupe work inside here: mikro-orm/packages/knex/src/AbstractSqlDriver.ts Lines 243 to 274 in f0cbcc2
i have a local patch working that i'll run with and see if i run into any weird behavior before considering a PR |
Fixed in v6 via #4769 |
Describe the bug
In order to make it easier for developers to understand models that rely on single-table design (in particular, managed ManyToMany tables), we "alias" some of our ManyToOne's so that you don't have to remember which logical data model maps to which generically named column. Other examples would be tables with a
to
/from
orparent/child
naming convention.When attempting to insert a discriminated subclass, the ORM will inject the activeId twice into the SQL query and it will fail. Using a getter/setter per subclass to "mimick" the alias isn't useful because it will likely cause problems when using the API (eg: filtering or populating).
Expected behavior
ORM should only use metadata of parent class and subclass to generate queries and access identity map.
Versions
The text was updated successfully, but these errors were encountered: