-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Same twoWayKey #327
Same twoWayKey #327
Conversation
Co-authored-by: Jake Barnby <[email protected]>
try { | ||
if ($attribute->getAttribute('type') === self::VAR_RELATIONSHIP | ||
&& \strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey) | ||
&& $attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId() | ||
) { | ||
throw new DuplicateException('Related attribute already exists'); | ||
} | ||
} catch (DuplicateException $e) { | ||
$twoWayKey ??= $collection->getId() . '_' . uniqid(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a try/catch here, we can use use the if:
try { | |
if ($attribute->getAttribute('type') === self::VAR_RELATIONSHIP | |
&& \strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey) | |
&& $attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId() | |
) { | |
throw new DuplicateException('Related attribute already exists'); | |
} | |
} catch (DuplicateException $e) { | |
$twoWayKey ??= $collection->getId() . '_' . uniqid(); | |
} | |
if ($attribute->getAttribute('type') === self::VAR_RELATIONSHIP | |
&& \strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey) | |
&& $attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId() | |
) { | |
$twoWayKey ??= $collection->getId() . '_' . uniqid(); | |
} |
throw new DuplicateException('Related attribute already exists'); | ||
} | ||
} catch (DuplicateException $e) { | ||
$twoWayKey ??= $collection->getId() . '_' . uniqid(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be $twoWayKey = $collection->getId() . '_' . uniqid();
, otherwise it will only assign if null
We tool care of this on Appwrite side |
No description provided.