-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Allow hydration of virtual properties in embeddables #5578
Comments
You said the properties don't map to actual db columns, right? So what hydration, how is it triggered (e.g.
|
@B4nan I've updated the description with the |
That's surely not what embeddables were meant for, they represent actual values stored in the database. |
@B4nan What would you suggest doing? I'm trying to find a solution in the documentation but I can't find a good solution. Is there already something we could use to map the query result? Maybe doing it this way via the Also here you're mentioning a solution by using virtual properties by doing |
I am not completely opposed to the idea, especially since it's not breaking anything apparently. It feels a bit weird to achieve this by adding |
@B4nan should the |
I don't think it should override anything, by declaring it on the parent you make everything inside virtual. |
@B4nan but what to do in this case? Should it persist @Entity()
class User {
@PrimaryKey()
id!: number;
@Embedded(() => Statistic, { prefix: false, nullable: true, persist: false })
statistic?: Statistic;
}
@Embeddable()
class Statistic {
@Property({ type: DoubleType })
total: number;
@Property({ type: DoubleType, persist: true })
views!: number;
constructor(total: number) {
this.total = total;
}
} |
No, I don't think so. This couldn't work in object mode at all anyway. |
I'm not using object mode right? And if it should not persist the view |
It should work in both modes, and yes, I would override it, since |
Maybe I need to add a test case for object mode as well then? |
Let's focus on the default inline mode now. |
Do no more changes are required? |
Closes #5578 --------- Co-authored-by: Martin Adámek <banan23@gmail.com>
Is your feature request related to a problem? Please describe.
Assume we're having the follow code. As you can see all the properties on the embeddable are marked as
persistent: false
. This because they are not actual database column. The embeddable documentation states it help you separate concern by allowing the embeddable to be defined on multiple entities. In our use case we have multiple entities making use of this embeddable.Right now as part of the metadata discovery process all
persistent: false
are ignored on embeddable properties. This is causes the hydration to fail since it doesn't know about those properties.Describe the solution you'd like
I would expect this query to be mapped correctly to the classes described above
Describe alternatives you've considered
We tried to look at the virtual entities but this requires us to make a whole new entity and doesn't give use the freedom around sorting and mapping the results right now.
The text was updated successfully, but these errors were encountered: