Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Cannot update Relationship Entity, nothing happens #152

Open
CristianSitov opened this issue Sep 5, 2017 · 4 comments
Open

Cannot update Relationship Entity, nothing happens #152

CristianSitov opened this issue Sep 5, 2017 · 4 comments

Comments

@CristianSitov
Copy link

CristianSitov commented Sep 5, 2017

Trying to update a relationship, but nothing happens.
Relation looks like this: Resource -> IsRelatedTo -> Actor

                foreach ($actor->getIsRelatedTo() as $rel) {
                    if ($rel->getId() == $inputRelationship) {
                        $rel->setRelation($data['relation'][$inputRelationship]);
                        $rel->setMain((bool) $data['main'][$inputRelationship]);
                    }
                }
                $this->em->flush();

Result is still the same: <id>: 1028, relation: business and setMain(true) has no effect. The expected result should be <id>: 1028, relation: business, main: true.

Am I doing something wrong? Is this documented somewhere?

@ikwattro
Copy link
Member

ikwattro commented Sep 6, 2017

The relationship entity should be removed on both Node entities. Where are you removing the relationship from the Resource and Actor ?

http://neo4j-php-ogm.readthedocs.io/en/latest/getting_started/tutorial/#removing-relationships

@CristianSitov
Copy link
Author

Ok. I skipped that part.
So, as far as I understand, I have to destroy the relationship that is supposed to be "edited", and create it back again with the new values.

@ikwattro
Copy link
Member

ikwattro commented Sep 6, 2017

Ho I am sorry, I misread delete instead of update.

This should be ok normally. I will investigate. Would you be able to share your models so I can put them in a test.

@CristianSitov
Copy link
Author

Nevermind. Found a workaround. Once I wrap the project, I'll create a pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants