Skip to content

Commit

Permalink
Us adapter values
Browse files Browse the repository at this point in the history
  • Loading branch information
fogelito committed Jan 15, 2025
1 parent 851963b commit 38f9760
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/Database/Adapter/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ public function getCountOfAttributes(Document $collection): int
{
$attributes = \count($collection->getAttribute('attributes') ?? []);

// +1 ==> virtual columns count as total, so add as buffer
return $attributes + static::getCountOfDefaultAttributes() + 1;
return $attributes + static::getCountOfDefaultAttributes();
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -5935,9 +5935,11 @@ private function validateSelections(Document $collection, array $queries): array
*/
public function getLimitForAttributes(): int
{
// If negative, return 0
// -1 ==> virtual columns count as total, so treat as buffer
return \max($this->adapter->getLimitForAttributes() - $this->adapter->getCountOfDefaultAttributes() - 1, 0);
if($this->adapter->getLimitForAttributes() === 0){
return 0;
}

return $this->adapter->getLimitForAttributes() - $this->adapter->getCountOfDefaultAttributes();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/Adapter/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -5482,11 +5482,11 @@ public function testExceptionAttributeLimit(): void
return;
}

$limit = static::getDatabase()->getAdapter()->getLimitForAttributes() - 7; // Internal attributes
$limit = static::getDatabase()->getAdapter()->getLimitForAttributes() - static::getDatabase()->getAdapter()::getCountOfDefaultAttributes();

$attributes = [];

for ($i = 0; $i < $limit; $i++) {
for ($i = 0; $i <= $limit; $i++) {
$attributes[] = new Document([
'$id' => ID::custom("attr_{$i}"),
'type' => Database::VAR_INTEGER,
Expand Down

0 comments on commit 38f9760

Please sign in to comment.