From 9417bcbd5ac5a01f936bfdc65cccb3833a94dfa6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 16 Dec 2025 21:46:34 +1300 Subject: [PATCH] Update limit message --- src/Database/Database.php | 6 +++--- tests/e2e/Adapter/Scopes/AttributeTests.php | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 83b7b6b66..d5595df38 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -2712,7 +2712,7 @@ public function updateAttribute(string $collection, string $id, ?string $type = $this->adapter->getDocumentSizeLimit() > 0 && $this->adapter->getAttributeWidth($collectionDoc) >= $this->adapter->getDocumentSizeLimit() ) { - throw new LimitException('Row width limit reached. Cannot update attribute.'); + throw new LimitException('Row width limit reached. Cannot update attribute. Current row width is ' . $this->adapter->getAttributeWidth($collectionDoc) . ' bytes but the maximum is ' . $this->adapter->getDocumentSizeLimit() . ' bytes. Reduce the size of existing attributes or remove some attributes to free up space.'); } if (in_array($type, self::SPATIAL_TYPES, true) && !$this->adapter->getSupportForSpatialIndexNull()) { @@ -2829,14 +2829,14 @@ public function checkAttribute(Document $collection, Document $attribute): bool $this->adapter->getLimitForAttributes() > 0 && $this->adapter->getCountOfAttributes($collection) > $this->adapter->getLimitForAttributes() ) { - throw new LimitException('Column limit reached. Cannot create new attribute.'); + throw new LimitException('Column limit reached. Cannot create new attribute. Current attribute count is ' . $this->adapter->getCountOfAttributes($collection) . ' but the maximum is ' . $this->adapter->getLimitForAttributes() . '. Remove some attributes to free up space.'); } if ( $this->adapter->getDocumentSizeLimit() > 0 && $this->adapter->getAttributeWidth($collection) >= $this->adapter->getDocumentSizeLimit() ) { - throw new LimitException('Row width limit reached. Cannot create new attribute.'); + throw new LimitException('Row width limit reached. Cannot create new attribute. Current row width is ' . $this->adapter->getAttributeWidth($collection) . ' bytes but the maximum is ' . $this->adapter->getDocumentSizeLimit() . ' bytes. Reduce the size of existing attributes or remove some attributes to free up space.'); } return true; diff --git a/tests/e2e/Adapter/Scopes/AttributeTests.php b/tests/e2e/Adapter/Scopes/AttributeTests.php index 92ebdb9a9..c428f3f01 100644 --- a/tests/e2e/Adapter/Scopes/AttributeTests.php +++ b/tests/e2e/Adapter/Scopes/AttributeTests.php @@ -957,7 +957,8 @@ public function testExceptionAttributeLimit(): void $this->fail('Failed to throw exception'); } catch (\Throwable $e) { $this->assertInstanceOf(LimitException::class, $e); - $this->assertEquals('Column limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('Column limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('Remove some attributes to free up space.', $e->getMessage()); } try { @@ -965,7 +966,8 @@ public function testExceptionAttributeLimit(): void $this->fail('Failed to throw exception'); } catch (\Throwable $e) { $this->assertInstanceOf(LimitException::class, $e); - $this->assertEquals('Column limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('Column limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('Remove some attributes to free up space.', $e->getMessage()); } } @@ -1035,7 +1037,9 @@ public function testExceptionWidthLimit(): void $this->fail('Failed to throw exception'); } catch (\Exception $e) { $this->assertInstanceOf(LimitException::class, $e); - $this->assertEquals('Row width limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('Row width limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('bytes but the maximum is 65535 bytes', $e->getMessage()); + $this->assertStringContainsString('Reduce the size of existing attributes or remove some attributes to free up space.', $e->getMessage()); } try { @@ -1043,7 +1047,9 @@ public function testExceptionWidthLimit(): void $this->fail('Failed to throw exception'); } catch (\Throwable $e) { $this->assertInstanceOf(LimitException::class, $e); - $this->assertEquals('Row width limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('Row width limit reached. Cannot create new attribute.', $e->getMessage()); + $this->assertStringContainsString('bytes but the maximum is 65535 bytes', $e->getMessage()); + $this->assertStringContainsString('Reduce the size of existing attributes or remove some attributes to free up space.', $e->getMessage()); } }