Skip to content

Commit 102d3fd

Browse files
committed
fix: tests.
1 parent cb9705f commit 102d3fd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship

src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function __construct()
8989
public function action(string $databaseId, string $collectionId, string $relatedCollectionId, string $type, bool $twoWay, ?string $key, ?string $twoWayKey, string $onDelete, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void
9090
{
9191
$key ??= $relatedCollectionId;
92+
$twoWayKeyWasProvided = $twoWayKey !== null;
9293
$twoWayKey ??= $collectionId;
9394

9495
$database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId));
@@ -122,7 +123,10 @@ public function action(string $databaseId, string $collectionId, string $related
122123
\strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey) &&
123124
$attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId()
124125
) {
125-
throw new Exception($this->getDuplicateException(), params: [$twoWayKey]);
126+
// If user explicitly provided twoWayKey, report that.
127+
// Otherwise report the key that they're trying to create.
128+
$conflictingKey = $twoWayKeyWasProvided ? $twoWayKey : $key;
129+
throw new Exception($this->getDuplicateException(), params: [$conflictingKey]);
126130
}
127131

128132
if (

0 commit comments

Comments
 (0)