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
We see that that userpermission has primary key that consists of the two foreign keys combined.
This means that the combination of those two is meant to be unique.
This is why, I can not simply write permissions: 3x @permission_* in the Main\V1\Entity\User fixture, but need to have unique values for this case.
When I am using unique here, which I know make the fixture unique across the whole fixture set, the database table permission will contain the four entries from the Main\V1\Entity\Permission fixture AND as duplicates the three that are used in the Main\V1\Entity\User fixture's line: permissions (unique): 3x @permission_*.
I know from Doctrine that is store references to managed objects by the spl_object_hash of objects. Since the \Nelmio\Alice\Definition\Value\UniqueValuedeep_clones the object, a new object is created which therefor has another spl_object_hash, which messes up the reference. By the way:\Nelmio\Alice\Definition\Value\UniqueValue does this in the __constructor and in getValue(). Shouldn't one time be enough? 🤔
I would figure that this, if not intended, does not play well with other entity mangers as well.
Is this intended behavior?
And if so, how would you go about to have an isolated unique case. (i know, this is a question not a bug report and kinda off-topic).
The text was updated successfully, but these errors were encountered:
I know from Doctrine that is store references to managed objects by the spl_object_hash of objects. Since the \Nelmio\Alice\Definition\Value\UniqueValue deep_clones the object, a new object is created which therefor has another spl_object_hash, which messes up the reference.
I do not think this should be an issue as alice there takes fixtures and outputs objects, although there might be deep cloning within those objects should not be known by Doctrine yet. Or do you mean this is happening for injected objects?
If by "injcted objects" you mean those, you can add additionally to the ones created from fixtures files, no.
The fact that Doctrine does not know about the objects at that point in time, does not matter for this issue.
The object generated for permission_text has for example the the object hash 1234.
If that fixture object is chosen by the user_random fixture, it is cloned by UniqueValue, which changes its object hash to abcd.
So the objects might be equal but not the same, which will is a problem for the entity managers (e.g. Doctrine).
Hey there,
I think I came to the right place for this, though my usecase might be doctrine-specific.
Given the following fixture set:
And the following tables in the database:
We see that that
userpermission
has primary key that consists of the two foreign keys combined.This means that the combination of those two is meant to be unique.
This is why, I can not simply write
permissions: 3x @permission_*
in theMain\V1\Entity\User
fixture, but need to have unique values for this case.When I am using
unique
here, which I know make the fixture unique across the whole fixture set, the database tablepermission
will contain the four entries from theMain\V1\Entity\Permission
fixture AND as duplicates the three that are used in theMain\V1\Entity\User
fixture's line:permissions (unique): 3x @permission_*
.I know from Doctrine that is store references to managed objects by the
spl_object_hash
of objects. Since the\Nelmio\Alice\Definition\Value\UniqueValue
deep_clone
s the object, a new object is created which therefor has anotherspl_object_hash
, which messes up the reference.By the way:
\Nelmio\Alice\Definition\Value\UniqueValue
does this in the__construct
or and ingetValue()
. Shouldn't one time be enough? 🤔I would figure that this, if not intended, does not play well with other entity mangers as well.
Is this intended behavior?
And if so, how would you go about to have an isolated
unique
case. (i know, this is a question not a bug report and kinda off-topic).The text was updated successfully, but these errors were encountered: