quick icon indicating copy to clipboard operation
quick copied to clipboard

Fixed issue where virtualAttributes were not being applied to discriminated child entities when loading through the parent

Open ryanalbrecht opened this issue 1 year ago • 15 comments

If you add a virtual attribute to a parent entity and load a discriminated child entity through that parent entity. The virtual attributes will not be applied to the child entity as quick will load a new instance of the child class and then use hydrate() to populate the entity. I fixed this by checking if the parent entity has any virtual attributes and then manually calling appendVirtualAttribute on the child class.

Additionally, thinking in terms of performance I cached the key name of all virtual entities in a new property called _virtualAttributes. This would eliminate the overhead (albeit a tiny one) of looping through all the attributes in the parent entity to check if it is a virtual attribute.

ryanalbrecht avatar Oct 24 '23 19:10 ryanalbrecht