Skip to content

Commit

Permalink
Add Fully-Qualified class name in UnrecognizedField exception to ease…
Browse files Browse the repository at this point in the history
… debugging
  • Loading branch information
Kern046 committed Dec 27, 2022
1 parent 0aa45dd commit 47b3814
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ final protected function updateTable(
$targetType = PersisterHelper::getTypeOfField($targetMapping->identifier[0], $targetMapping, $this->em);

if ($targetType === []) {
throw UnrecognizedField::byName($targetMapping->identifier[0]);
throw UnrecognizedField::byFullyQualifiedName($this->class->name, $targetMapping->identifier[0]);
}

$types[] = reset($targetType);
Expand Down Expand Up @@ -1199,7 +1199,7 @@ final protected function getOrderBySQL(array $orderBy, string $baseTableAlias):
continue;
}

throw UnrecognizedField::byName($fieldName);
throw UnrecognizedField::byFullyQualifiedName($this->class->name, $fieldName);
}

return ' ORDER BY ' . implode(', ', $orderByList);
Expand Down Expand Up @@ -1757,7 +1757,7 @@ private function getSelectConditionStatementColumnSQL(
return [$field];
}

throw UnrecognizedField::byName($field);
throw UnrecognizedField::byFullyQualifiedName($this->class->name, $field);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ public static function byName(string $field): self
{
return new self(sprintf('Unrecognized field: %s', $field));
}

/** @param class-string $className */
public static function byFullyQualifiedName(string $className, string $field): self
{
return new self(sprintf('Unrecognized field: %s::%s', $className, $field));
}
}

0 comments on commit 47b3814

Please sign in to comment.