Task #9710
Refactor QueryResultProxy behaviour
| Status: | Resolved | Start date: | ||
|---|---|---|---|---|
| Priority: | Must have | Due date: | ||
| Assigned To: | Karsten Dambekalns | % Done: | 100% |
|
| Category: | Persistence | |||
| Target version: | TYPO3 Flow Base Distribution - 1.0 alpha 12 | |||
| Sprint: | Has patch: | |||
| PHP Version: | Complexity: |
Description
- rename
QueryResultProxytoQueryResult - get rid of
FETCH_*and haveexecut()@e always return @QueryResult - add
QueryResult->getFirst()(or similar) to replicate FETCH_OBJECT - add
toArray()(or similar) toQueryResultto easeiterator_to_array()hassle
Hint: inject DataMapper and PersistenceManager to QueryResult to get actual data there instead of through no-loger-existing-FETCH_ARRAY...
Related issues
Associated revisions
[!!!][~TASK] FLOW3 (Persistence): Refactor QueryResultProxy into QueryResult
Query->execute() now only returns QueryResultInterface instances, those
results have a toArray() method to get the result as array of objects
and a getFirst() which returns the first object found.
The count() method has been removed from the Query class and is now
expected to be used on the query result, so that each $query->count()
now should read $query->execute()->count().
Change-Id: Ib3fb13bce47772b34992cb357b2b4493850b832e
Resolves: #9710
[~TASK] FLOW3: Make codebase use new QueryResult properly
The change introduced in Ib3fb13bce47772b34992cb357b2b4493850b832e was
not reflected properly in PropertyMapper and AccountRepository.
Relates to: #9710
Change-Id: I17e1138c1ec8aaa74ac6a7d1d944a0b8312b7e1c
History
#1 Updated by Karsten Dambekalns almost 5 years ago
- Category set to Persistence
- Start date deleted (
2010-09-13)
#2 Updated by Bastian Waidelich almost 5 years ago
Note: As discussed QueryResult::getFirst() should return NULL instead of FALSE if the result set is empty
#3 Updated by Karsten Dambekalns almost 5 years ago
- Status changed from New to Accepted
- Assigned To set to Karsten Dambekalns
#4 Updated by Karsten Dambekalns almost 5 years ago
- Status changed from Accepted to Needs Feedback
getFirst() would be pure syntactic sugar, as it's the same as $result->current() - I'd say we sip that.
toArray()- misleading, as it's not the equivalent of a typecastasArray()- well it's not the QueryResult that's being returned, but the objects insidegetObjectsInAnArray()- seems quite longgetResultAsArray()- similar to asArray(), same problem
Any more?
#5 Updated by Sebastian Kurfuerst almost 5 years ago
Karsten Dambekalns wrote:
getFirst()would be pure syntactic sugar, as it's the same as$result->current()- I'd say we sip that.
I'd still prefer to have a "getFirst()" method, as it is a lot more intuitive to read "getFirst()" instead of "current()".
More interesting is the name of the array-returning method. Should it be
toArray()- misleading, as it's not the equivalent of a typecast
I'd suggest that, as for the user, it looks like as the query result is converted to an array.
So "toArray" reads most natural for me.
Greets,
Sebastian
#6 Updated by Bastian Waidelich almost 5 years ago
Karsten Dambekalns wrote:
getFirst()would be pure syntactic sugar, as it's the same as$result->current()- I'd say we sip that.
I'd prefer to keep the getFirst(). It could internally clone the query and call setLimit(1) for greater performance
More interesting is the name of the array-returning method. Should it be
toArray()- misleading, as it's not the equivalent of a typecastasArray()- well it's not the QueryResult that's being returned, but the objects insidegetObjectsInAnArray()- seems quite longgetResultAsArray()- similar to asArray(), same problem
I like toArray() best. And in fact it should behave the same as iterator_to_array($result) doesn't it?
#7 Updated by Karsten Dambekalns almost 5 years ago
Bastian Waidelich wrote:
I like
toArray()best. And in fact it should behave the same asiterator_to_array($result)doesn't it?
Yes, but not the same as (array)$result... which is the difference to __toString()
#8 Updated by Bastian Waidelich almost 5 years ago
Karsten Dambekalns wrote:
Bastian Waidelich wrote:
I like
toArray()best. And in fact it should behave the same asiterator_to_array($result)doesn't it?Yes, but not the same as
(array)$result... which is the difference to__toString()
I still think to the user it's the same.$result->__toArray() would be a different issue IMO
#9 Updated by Karsten Dambekalns almost 5 years ago
- Status changed from Needs Feedback to Under Review
#10 Updated by Karsten Dambekalns almost 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 1396898d2d764e28a1c01ac48e59ed7c51b77363.