From 633a4420465cd1da4d75b21448562cece32ac50e Mon Sep 17 00:00:00 2001 From: Tomasz Darmetko Date: Mon, 6 Mar 2017 19:39:27 +0100 Subject: [PATCH 1/2] Add path expresion to QueryException::associationPathInverseSideNotSupported() --- lib/Doctrine/ORM/Query/QueryException.php | 8 +++++--- lib/Doctrine/ORM/Query/SqlWalker.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index 8245722a9..bde84579e 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -204,13 +204,15 @@ class QueryException extends \Doctrine\ORM\ORMException } /** + * @param object $pathExpr + * * @return QueryException */ - public static function associationPathInverseSideNotSupported() + public static function associationPathInverseSideNotSupported($pathExpr) { return new self( - "A single-valued association path expression to an inverse side is not supported". - " in DQL queries. Use an explicit join instead." + "A single-valued association path expression to an inverse side is not supported in DQL queries. " . + "Instead of '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "' use an explicit join." ); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index a4b5089e8..269859528 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -671,7 +671,7 @@ class SqlWalker implements TreeWalker $assoc = $class->associationMappings[$fieldName]; if ( ! $assoc['isOwningSide']) { - throw QueryException::associationPathInverseSideNotSupported(); + throw QueryException::associationPathInverseSideNotSupported($pathExpr); } // COMPOSITE KEYS NOT (YET?) SUPPORTED From b21cb3e2a0ef3e2da8fee00ea3bb157ef6a6ce7b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Wed, 21 Jun 2017 08:16:24 +0200 Subject: [PATCH 2/2] #6325 adding IDE hints, type hints, replacing double quotes with single quotes --- lib/Doctrine/ORM/Query/QueryException.php | 10 ++++++---- lib/Doctrine/ORM/Query/SqlWalker.php | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Query/QueryException.php b/lib/Doctrine/ORM/Query/QueryException.php index bde84579e..b78e27bcf 100644 --- a/lib/Doctrine/ORM/Query/QueryException.php +++ b/lib/Doctrine/ORM/Query/QueryException.php @@ -19,6 +19,8 @@ namespace Doctrine\ORM\Query; +use Doctrine\ORM\Query\AST\PathExpression; + /** * Description of QueryException. * @@ -204,15 +206,15 @@ class QueryException extends \Doctrine\ORM\ORMException } /** - * @param object $pathExpr + * @param PathExpression $pathExpr * * @return QueryException */ - public static function associationPathInverseSideNotSupported($pathExpr) + public static function associationPathInverseSideNotSupported(PathExpression $pathExpr) { return new self( - "A single-valued association path expression to an inverse side is not supported in DQL queries. " . - "Instead of '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "' use an explicit join." + 'A single-valued association path expression to an inverse side is not supported in DQL queries. ' . + 'Instead of "' . $pathExpr->identificationVariable . '.' . $pathExpr->field . '" use an explicit join.' ); } diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 269859528..98f58ad8c 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -644,6 +644,7 @@ class SqlWalker implements TreeWalker { $sql = ''; + /* @var $pathExpr Query\AST\PathExpression */ switch ($pathExpr->type) { case AST\PathExpression::TYPE_STATE_FIELD: $fieldName = $pathExpr->field;