mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
getArrayResult or getSql not working properly ? #5872
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 @poolerMF on GitHub (Feb 3, 2018).
Originally assigned to: @Ocramius on GitHub.
I got entity, that have manyToOne (user)
I made simple QB (select table)
$queryBuilder->getQuery()->getSQL():
I'm calling $queryBuilder->getQuery()->getArrayResult()
real executed SQL from profiler:
where is problem ? should getSql select user ? or should getArrayResult return user ?
@Ocramius commented on GitHub (Feb 3, 2018):
@poolerMF what are the mappings involved in this query? Also, did you make sure there is no caching?
@poolerMF commented on GitHub (Feb 3, 2018):
query:
mapping:
@Ocramius commented on GitHub (Feb 3, 2018):
Ah, that's normal then, since the association is not part of the entity.
@poolerMF commented on GitHub (Feb 3, 2018):
@Ocramius association is not part of the entity ?
sorry what ? maybe I do not understand
can you send me example, when is it part of the entity ?
and still issue - is getSql returning correct SQL ? becose it is different from real one
@Ocramius commented on GitHub (Feb 3, 2018):
I made a quick test to show how this works:
Also, yes, fields that do not need to be fetched are also removed from the
SELECTclause.If you still want the ID of the association, you should add it to your
SELECTwith theIDENTITY()function.@poolerMF commented on GitHub (Feb 3, 2018):
when I use
then I will get manyToOne columns
but getSql() SHOULD NOT RETURN COLUMNS THAT WILL BE NOT FETCHED
I still think, getSql is not working correctly
@Ocramius commented on GitHub (Feb 3, 2018):
In the test above, try these two:
This one is the default:
@poolerMF commented on GitHub (Feb 3, 2018):
I don't want to be rude, but you are not answering to my question/point
getSql is not returning real sql that will be executed
@Ocramius commented on GitHub (Feb 3, 2018):
@poolerMF
getSqlreturns the SQL for the matching hydration mode (https://github.com/doctrine/doctrine2/issues/7036#issuecomment-362796456)