DoctrineORMQuerySourceIterator only works if query has ORDER BY defined
sirbaconjr opened this issue · 4 comments
I recently was creating my own export function, outside SonataAdminBundle, by I was getting a "File not found" error. After a while, and looking in some issues in SonataAdminBundle, I found out that the DoctrineORMQuerySourceIterator only works if ORDER BY is defined in the query. Like this:
$query = $em->createQuery(
'SELECT c FROM PoPGerenciamentoBundle:Circuit c
ORDER BY c.id ASC'
);
Is this the normal behavior?
In a doctrine project (out of symfony) I can use $em->createQuery('SELECT c FROM Entity c')
as query then export without problem, so that's surely not the expected behavior.
What do you mean by "only works if ..." ? Is there any error or do you got an empty result ?
The query works, but somethings goes wrong in the DoctrineORMQuerySourceIterator
and I got a 500 error and a "File Not Found" message. In the moment I added this line ORDER BY c.id ASC
to the query, the export was working.
I suspect that your error was coming from a different problem.
Maybe a wrong syntax before adding the ORDER BY
in the query , or from a totally different location in your code.
I just made a test, I have no idea of what went wrong, but it's working. I'm sorry for the trouble, was some mistake mine. Thank you for helping me. I will close the issue now.