mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Wrong result with custom left join #5509
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Sohorev on GitHub (Apr 22, 2017).
When I run the query
SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.review_id AS review_id_2 FROM review r0_ LEFT JOIN review_short r1_ ON (r0_.id = r1_.review_id)on the database, I get 82 rows (it is right). But $qb->getQuery()->getResult() return 164 rows - it is wrong@Ocramius commented on GitHub (Apr 22, 2017):
There's a lot of confusion with your intent in this query, since:
WITHjoin conditionCould you print out the generated DQL string, and explain what you wanted
to achieve, and why no association is being used?
On 22 Apr 2017 7:20 a.m., "Sohorev Sergey" notifications@github.com wrote:
namespace FrontfaceBundle\Model\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
/
class Review {
/*
allocationSize=1, initialValue=1)
*/
private $id;
/**
*/
public function getId() {
return $this->id;
}
}
namespace FrontfaceBundle\Model\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
*/
class ReviewShort {
/**
allocationSize=1, initialValue=1)
*/
private $id;
/**
*/
public function setReview(\FrontfaceBundle\Model\Entity\Review
$review = null) {
$this->review = $review;
}
/**
*/
public function getReview() {
return $this->review;
}
}
Expr\Join::WITH, 'r.id = rshort.review')
;
print_r(count($qb->getQuery()->getResult()));
// will print 164
print_r($qb->getQuery()->getSQL());
// SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.review_id AS
review_id_2 FROM review r0_ LEFT JOIN review_short r1_ ON (r0_.id =
r1_.review_id)
When I run the query SELECT r0_.id AS id_0, r1_.id AS id_1, r1_.review_id
AS review_id_2 FROM review r0_ LEFT JOIN review_short r1_ ON (r0_.id =
r1_.review_id) on the database, I get 82 rows (it is right). But
$qb->getQuery()->getResult() return 164 rows - it is wrong
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6411, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakHhuS8FegBg4EbqftxMXjaYRSpqgks5ryY4cgaJpZM4NE-oB
.
@beberlei commented on GitHub (Dec 8, 2020):
Closing for lack of feedback.