mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
"LEFT JOIN" with "WHERE" - "WHERE" appearing in SQL as ON instead of WHERE #5181
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 @audoh on GitHub (Jul 7, 2016).
Here's my query:
$query = $qb->select('p')->from('PackageBundle:Package', 'p')->where('p.slug = :slug')->setParameter('slug', $slug)->leftJoin('PackageBundle:PackageCategory', 'pc')->andWhere('pc.slug = :categorySlug')->setParameter('categorySlug', $categorySlug);Here's the runnable that results from that:
SELECT p0_.id AS id_0, p0_.name AS name_1, p0_.brief AS brief_2, p0_.slug AS slug_3, p0_.package_category_id AS package_category_id_4 FROM package p0_ LEFT JOIN package_category p1_ ON (p0_.slug = 'slammin-sofas' AND p1_.slug = 'hmo-packse');It still returns the slammin-sofas package despite the category's actual slug being hmo-packs, not hmo-packse. Testing the same SQL query as it should be directly via MySQL (
WHERE p0_.slug = 'slammin-sofas' AND p1_.slug = 'hmo-packse') works as it should.This is with Doctrine 2.4.8 in Symfony 2.8.8 (DoctrineBundle 1.4, I believe).
The order of the builder statements makes no difference (putting andWhere before the leftJoin doesn't change anything).
@audoh commented on GitHub (Jul 7, 2016):
That's my fault, I absentmindedly put the wrong thing in the join. Should've been:
->leftJoin('pc.packageCategory', 'pc')