Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/Database/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ public function getId(): string
}

/**
* @return string
* @return string|null
*/
public function getSequence(): string
public function getSequence(): ?string
{
return $this->getAttribute('$sequence', '');
$sequence = $this->getAttribute('$sequence');

if ($sequence === null) {
return null;
}

return $sequence;
}

/**
Expand Down Expand Up @@ -172,10 +178,12 @@ public function getUpdatedAt(): ?string
public function getTenant(): ?int
{
$tenant = $this->getAttribute('$tenant');
if ($tenant !== null) {
return (int)$tenant;

if ($tenant === null) {
return null;
}
return null;

return (int) $tenant;
}

/**
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/Adapter/Scopes/DocumentTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -1968,9 +1968,6 @@ public function testFindByInternalID(array $data): void
]);

$this->assertEquals(1, count($documents));

$empty = new Document();
$this->assertEquals('', $empty->getSequence());
}

public function testFindOrderBy(): void
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,12 @@ public function testGetArrayCopy(): void
], $this->document->getArrayCopy());
$this->assertEquals([], $this->empty->getArrayCopy());
}

public function testEmptyDocumentSequence(): void
{
$empty = new Document();

$this->assertNull($empty->getSequence());
$this->assertNotSame('', $empty->getSequence());
}
}