mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1067: Doctrine 2 QuerryBuilder vs Handcoded DQL - different results #1335
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 @doctrinebot on GitHub (Mar 11, 2011).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user gdobrowolski:
As per Guilherme Blanco request I'm submitting this weird behaviour I have experienced:
(Original post can be found here: http://stackoverflow.com/questions/5261891/doctrine-2-querrybuilder-vs-handcoded-dql-different-results
My handcrafted query looks like this:
Now, I'm trying to reproduce it like this with QueryBuilder:
This however is producing this DQL query:
As you can see there is part of this missing comapring to handcrafted one (First line):
I'm not sure why these joins are missing as I am defining them here:
Update:
The fun part starts, when DQL gets translated into SQL - in this case MySQL:
Handcrafted one becomes:
Where generated one looks like this:
And this is invalid statement, as database returns with:
Column not found: 1054 Unknown column 'f1_.site_id' in 'on clause'
@doctrinebot commented on GitHub (Mar 12, 2011):
Comment created by @beberlei:
This are different DQLs you are generitng with the query builder. You are calling $qb->from() twice, but you only have one FROM clause in your original dql!
Edit: Oh no you have two from classes, this really looks weird.
Edit 2: The SQL Error is to be expected because of the resorting of the DQL parts.
@doctrinebot commented on GitHub (Mar 12, 2011):
Comment created by @beberlei:
Fixed formatting
@doctrinebot commented on GitHub (Mar 20, 2011):
Comment created by @beberlei:
The issue here is that the QueryBuilder does preserve the order of from and join calls.
@doctrinebot commented on GitHub (May 12, 2011):
Comment created by @guilhermeblanco:
Fixed on master
@doctrinebot commented on GitHub (May 12, 2011):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (May 20, 2011):
Comment created by gdobrowolski:
I have just tried with ORM and DBAL versions 2.0.5 and Common version 2.0.2 (2.0.5 doesn't seem to be available) and the issue is still there.
Has this been released in 2.0.5 or is it going to land in 2.1?
Thanks,
Greg