diff --git a/src/Database/Database.php b/src/Database/Database.php index 948fbf373..19c86dcda 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -5910,6 +5910,21 @@ private function validateSelections(Document $collection, array $queries): array return $selections; } + /** + * Get adapter attribute limit, accounting for internal metadata + * Returns 0 to indicate no limit + * + * @return int + */ + public function getLimitForAttributes(): int + { + if ($this->adapter->getLimitForAttributes() === 0) { + return 0; + } + + return $this->adapter->getLimitForAttributes() - $this->adapter->getCountOfDefaultAttributes(); + } + /** * Get adapter index limit * diff --git a/tests/e2e/Adapter/Base.php b/tests/e2e/Adapter/Base.php index 507241f09..040b2005a 100644 --- a/tests/e2e/Adapter/Base.php +++ b/tests/e2e/Adapter/Base.php @@ -5736,6 +5736,11 @@ public function testUniqueIndexDuplicateUpdate(): void static::getDatabase()->updateDocument('movies', $document->getId(), $document->setAttribute('name', 'Frozen')); } + public function testGetAttributeLimit(): void + { + $this->assertIsInt($this->getDatabase()->getLimitForAttributes()); + } + public function testGetIndexLimit(): void { $this->assertEquals(58, $this->getDatabase()->getLimitForIndexes());