From 47b381482b843ae5f64e996b1c7aef3d5f9ca19b Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Mon, 26 Dec 2022 14:25:41 +0100 Subject: [PATCH] Add Fully-Qualified class name in UnrecognizedField exception to ease debugging --- lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php | 6 +++--- lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 6e6877e8952..0b655254dfd 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -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); @@ -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); @@ -1757,7 +1757,7 @@ private function getSelectConditionStatementColumnSQL( return [$field]; } - throw UnrecognizedField::byName($field); + throw UnrecognizedField::byFullyQualifiedName($this->class->name, $field); } /** diff --git a/lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php b/lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php index dd89fde1a4b..e9b0d7ec353 100644 --- a/lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php +++ b/lib/Doctrine/ORM/Persisters/Exception/UnrecognizedField.php @@ -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)); + } }