Skip to content

Commit

Permalink
fix: Double results when iterating after deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 authored and transistive committed Aug 9, 2024
1 parent 7681d10 commit 108ccb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Types/AbstractCypherSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ public function __serialize(): array
$this->preload();

$tbr = get_object_vars($this);
$tbr['generator'] = new ArrayIterator($this->cache);
$tbr['generator'] = new ArrayIterator();
$tbr['currentPosition'] = 0;
$tbr['generatorPosition'] = 0;

Expand Down
15 changes: 15 additions & 0 deletions tests/Unit/CypherListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ public function setUp(): void
$this->list = new CypherList(['A', 'B', 'C']);
}

// https://github.com/neo4j-php/neo4j-php-client/issues/220
public function testNoDoubleResultsAfterDeserialization(): void
{
$list = new CypherList(['A', 'B', 'C']);
$serialized = serialize($list);
$unserialized = unserialize($serialized);

$count = 0;
foreach ($unserialized as $item) {
++$count;
}

self::assertEquals(3, $count);
}

public function testFromIterableEqual(): void
{
$fromIterable = CypherList::fromIterable($this->list);
Expand Down

0 comments on commit 108ccb6

Please sign in to comment.