mongodb-odm icon indicating copy to clipboard operation
mongodb-odm copied to clipboard

Skip non-mapped typed properties with default values when using Proxies

Open franmomu opened this issue 3 years ago • 4 comments

Q A
Type bug
BC Break yes
Fixed issues #2349

Summary

Taking a look at #2349 seems like the problem is that the proxy is not initialized when it's managed.

~Looking at the code, if the document is an instance of GhostObjectInterface and it not initialized, it calls to $document->setProxyInitializer(null); which removes the initialization.~

To be honest I'm not sure if it's the right fix, maybe that code was there for some reason.

The test is from https://github.com/andythorne/doctrine-odm-example-error

Update: I was taking a look again to this issue, apparently one way to solve it is to skip those properties when using a proxy.

franmomu avatar Dec 26 '21 12:12 franmomu

I was taking a look again at this issue and one possible solution would be to skip these properties.

I've skipped the typed non-mapped properties that have a default value. What about this? maybe is there something else to take into account? 🤔

franmomu avatar Mar 03 '22 11:03 franmomu

@malarzm any chance that this might be merged? We are experiencing this issue with Doctrine 2.3 and were hoping to see it solved when we upgrade to 2.4

carlos-granados avatar Mar 17 '23 13:03 carlos-granados

2.4 is already released. I'll take a look at this after the weekend for inclusion in a 2.5 patch release.

alcaeus avatar Mar 17 '23 17:03 alcaeus

I made some adjustments to the tests to no longer rely on the absence of an error (and instead running an assertion), as well as applying the logic to all unmapped properties, not only those with default values.

alcaeus avatar Mar 22 '23 12:03 alcaeus