You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Skip map a destination field if source's field are unset
Problem:
In my Symfony project, when I map from model to entity, and persist my entity to DB. I don't need to define fields that not necessary in model. The problem are after map, entity's fields will be set to null if the same don't exists in model. So, database data are lost.
skipNull option should not use in this situation. Because if fields in model are null, I want them to be update to entity.
Solution 1:
Add option skipUnset. Then catch NoSuchPropertyException in map() function. $value will be set to null if skipUnset not used, otherwise continue the loop.
Solution 2:
Skip unset property in buildDefaultMap() by default.
In this solution, catch for NoSuchPropertyExceptionMAY become unreach.
The text was updated successfully, but these errors were encountered:
Skip map a destination field if source's field are unset
Problem:
Solution 1:
skipUnset
. Then catchNoSuchPropertyException
inmap()
function.$value
will be set tonull
if skipUnset not used, otherwise continue the loop.Solution 2:
buildDefaultMap()
by default.NoSuchPropertyException
MAY become unreach.The text was updated successfully, but these errors were encountered: