Skip to content

Commit

Permalink
fix relationship type guesser
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Jan 25, 2019
1 parent a3d7dc1 commit 47d6aa3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core/Directus/Database/Schema/Object/FieldRelationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,28 @@ public function isOneToMany()
*/
protected function guessType()
{
$fieldName = $this->fromField->getName();
$isAlias = $this->fromField->isAlias();
$type = null;

if (!$this->fromField) {
$type = null;
} else if (
return $type;
}

$fieldName = $this->fromField->getName();
$fieldCollectionName = $this->fromField->getCollectionName();
$isAlias = $this->fromField->isAlias();

if (
!$isAlias &&
$this->getCollectionOne() !== null &&
$this->getFieldMany() === $fieldName &&
$this->getCollectionMany() !== null
$this->getCollectionMany() === $fieldCollectionName
) {
$type = static::MANY_TO_ONE;
} else if (
$isAlias &&
$this->getCollectionMany() !== null &&
$this->getFieldOne() === $fieldName &&
$this->getCollectionOne() !== null
$this->getCollectionOne() === $fieldCollectionName
) {
$type = static::ONE_TO_MANY;
}
Expand Down

0 comments on commit 47d6aa3

Please sign in to comment.