[DDC-1927] Pagination of a SELECT of specific fields results in a RuntimeException Created: 16/Jul/12 Updated: 18/Apr/13 Resolved: 25/Nov/12 |
|
| Status: | Resolved |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Zacharias Luiten | Assignee: | Benjamin Eberlei |
| Resolution: | Can't Fix | Votes: | 0 |
| Labels: | paginator | ||
| Description |
|
When paginating a DQL string which selects specific fields it results in the following error: PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Not all identifier properties can be found in the ResultSetMapping: id' NOT working: 'SELECT c.id, c.number FROM Application\Entity\Course c' Setting hydration mode to scalar results makes no difference. Gist to example code and stack trace: https://gist.github.com/d5cd6d0b0ac28e722dd7 |
| Comments |
| Comment by Benjamin Eberlei [ 29/Jul/12 ] |
|
First results: This is very complicated to support, the pagination was designed for entity results. I have to check this when I have more time. |
| Comment by dquintard [ 08/Aug/12 ] |
|
Hi Benjamin, |
| Comment by Matt Pinkston [ 13/Nov/12 ] |
|
The reason this error occurs is because the Paginator creates its own ResultSetMapping and relies on the SqlWalker to configure it (see Doctrine\ORM\Query\SqlWalker::walkSelectExpression). Doctrine will interpret each field in the first example (SELECT c.id, c.number...) as a PathExpression and add it to the result set mapping as a scalar result. This makes it impossible for the paginator to reliably know which field can be considered an identifier. A quick fix might be to re-write the query to use PartialObjectExpression: SELECT partial c. {id, number}... (edited after a re-read and realization that a custom ResultSetMapping wouldn't cut it) |
| Comment by Benjamin Eberlei [ 25/Nov/12 ] |
|
Allowing generic+complex pagination on scalar results is impossible for us, closing as can't fix. Just use LIMITs yourself here or as suggested partial objects. |
| Comment by Stefano [ 18/Apr/13 ] |
|
imho this pagination feature is quite useless if we are forced to fetch the complete Entity. Take for example a big table with a lot of data: extracting all the infos will take a lot of time... There should be a way to support the first query type |