From 79ed2c9613ed894b04ae189dc5d7c97e4adbd05d Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 6 Aug 2025 09:29:14 +0300 Subject: [PATCH] getSeuqnce null --- src/Database/Document.php | 20 ++++++++++++++------ tests/e2e/Adapter/Scopes/DocumentTests.php | 3 --- tests/unit/DocumentTest.php | 8 ++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Database/Document.php b/src/Database/Document.php index 566a37444..e8a7a3a08 100644 --- a/src/Database/Document.php +++ b/src/Database/Document.php @@ -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; } /** @@ -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; } /** diff --git a/tests/e2e/Adapter/Scopes/DocumentTests.php b/tests/e2e/Adapter/Scopes/DocumentTests.php index 58334135d..31587e096 100644 --- a/tests/e2e/Adapter/Scopes/DocumentTests.php +++ b/tests/e2e/Adapter/Scopes/DocumentTests.php @@ -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 diff --git a/tests/unit/DocumentTest.php b/tests/unit/DocumentTest.php index a9ca44e1e..9a41ab534 100644 --- a/tests/unit/DocumentTest.php +++ b/tests/unit/DocumentTest.php @@ -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()); + } }