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
2 changes: 1 addition & 1 deletion src/Database/Validator/IndexDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public function checkIndexLengths(Index $index): bool
}

if ($indexLength > $attributeSize) {
$this->message = 'Index length '.$indexLength.' is larger than the size for '.$attributeName.': '.$attributeSize.'"';
$this->message = 'Index length '.$indexLength.' is larger than the size for '.$attributeName.': '.$attributeSize;

return false;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/Adapter/Scopes/IndexTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function testIndexLengthExceedsAttributeSize(): void
$database->createIndex(__FUNCTION__, Index::key(key: 'index1', attributes: ['title1', 'title2'], lengths: [701, 50]));
$this->fail('Failed to throw exception');
} catch (Throwable $e) {
$this->assertEquals('Index length 701 is larger than the size for title1: 700"', $e->getMessage());
$this->assertEquals('Index length 701 is larger than the size for title1: 700', $e->getMessage());
}

$database->deleteCollection(__FUNCTION__);
Expand Down Expand Up @@ -681,7 +681,7 @@ public function testIndexValidation(): void
$validator = $this->indexValidator($attributes, $indexes);

if ($adapter->supports(Capability::IndexIdentical)) {
$errorMessage = 'Index length 701 is larger than the size for title1: 700"';
$errorMessage = 'Index length 701 is larger than the size for title1: 700';
$this->assertFalse($validator->isValid($indexes[0]));
$this->assertSame($errorMessage, $validator->getDescription());

Expand Down
8 changes: 8 additions & 0 deletions tests/unit/Validator/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ public function testTextAttributeWithoutASizeIsJudgedAgainstTheTextMaximum(): vo
$this->assertSame('Index length is longer than the maximum: 768', $validator->getDescription());
}

public function testIndexLengthLargerThanTheAttributeNamesBothSizes(): void
{
$validator = new IndexDefinition([Attribute::string(key: 'title', size: 64)], [], Profiles::of(capabilities: self::CAPABILITIES, indexLength: 768));

$this->assertFalse($validator->isValid(Index::key(key: 'by_title', attributes: ['title'], lengths: [65])));
$this->assertSame('Index length 65 is larger than the size for title: 64', $validator->getDescription());
}

public function testKeyAndUniqueIndexesAreRejectedWithoutAdapterSupport(): void
{
$validator = new IndexDefinition(
Expand Down
Loading