graphaware / neo4j-php-ogm

Neo4j Object Graph Mapper for PHP
MIT License
153 stars 55 forks source link

Relations between Nodes of the same type do not respect direction #167

Closed cebe closed 6 years ago

cebe commented 6 years ago

Example:

Classes like they are defined in the tests:

https://github.com/graphaware/neo4j-php-ogm/blob/0d7bc53b4570f2c45798f117d923ab9940209bfc/tests/Integration/RelationshipEntityBetweenSameModelTest.php#L92-L243

Data in the database looks like this:

bildschirmfoto von 2017-11-12 23-30-11

When I retrieve the relation Follows on a user that is on both sides of a relation, e.g. B in A -follows-> B -follows-> C, the relation data contains wrong records, which seems as if the relation direction is not taken into account. Though I have not figured out the cause of the issue yet.

For the example in the image, the relation count for all users should be 1, in some cases its 2 though.

I have created a test case which I will send a PR. Test output:

There was 1 failure:

1) GraphAware\Neo4j\OGM\Tests\Integration\RelationshipEntityBetweenSameModelTest::testUserWithReCanBeRetrievedChain
followee0 should follow exactly one user, but the relation contains:
me --follows--> followee0
followee0 --follows--> followee1
Failed asserting that 2 matches expected 1.
cebe commented 6 years ago

I don't like the amount of "guess" in comments and method names in \GraphAware\Neo4j\OGM\Hydrator\EntityHydrator... :-/

cebe commented 6 years ago

Proposed a fix in #168