Bug #26885
It's not possible to order by relation properties
Status: | Resolved | Start date: | 2011-05-18 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | Karsten Dambekalns | % Done: | 0% |
|
Category: | Persistence | |||
Target version: | - | |||
PHP Version: | Complexity: | |||
Has patch: | No | Affected Flow version: | FLOW3 1.0.0 |
Description
The following code (in a custom repository) won't work if "proposedSessionType" is a relation..
1protected $defaultOrderings = array( 2 'proposedSessionType' => QueryInterface::ORDER_ASCENDING, 3);
Also it does not work to order by properties of a relation like:
1protected $defaultOrderings = array( 2 'proposedSessionType.title' => QueryInterface::ORDER_ASCENDING, 3);
Associated revisions
[BUGFIX] It's not possible to order by relation properties
setOrderings() of Doctrine\Query did not work on relation attributes.
Now using the getPropertyNameWithAlias - method to implicit join needed
relations.
Change-Id: Ib6d967ccc97ed64828bea8765edea5dd8c63aa0a
Resolves: #26885
History
#1 Updated by Karsten Dambekalns about 4 years ago
- Status changed from New to Accepted
#2 Updated by Ferdinand Kuhl almost 4 years ago
a bit more on this issue: setOrderings() appends rootAlias . "proposedSessionType"
to the orderBy-Clause. And appearently multi-dot-notation has been dropped
shortly by doctrine:
http://www.doctrine-project.org/projects/orm/2.1/docs/whats-new/en
The only possibility I can see at the moment is detect "." in the argument,
do a join for this table and rewrite the order by statement.
Has anyone problems with that? Should I try to prepare a patch?
#3 Updated by Ferdinand Kuhl almost 4 years ago
Great! As there is already a method "getPropertyNameWithAlias" its extremely easy to fix this:
Just change
1public function setOrderings(array $orderings) {
2 $this->orderings = $orderings;
3 $this->queryBuilder->resetDQLPart('orderBy');
4 foreach ($this->orderings AS $propertyName => $order) {
5 $this->queryBuilder->addOrderBy($this->queryBuilder->getRootAlias() . '.' . $propertyName, $order);
6
7 }
8 return $this;
9 }
to
1public function setOrderings(array $orderings) {
2 $this->orderings = $orderings;
3 $this->queryBuilder->resetDQLPart('orderBy');
4 foreach ($this->orderings AS $propertyName => $order) {
5 $this->queryBuilder->addOrderBy($this->getPropertyNameWithAlias($propertyName), $order);
6 }
7 return $this;
8 }
#4 Updated by Ferdinand Kuhl almost 4 years ago
- File issue26885.patch added
Prepared a patch using git, but as I have not yet signed the CLA I am not allowed to commit it to gerrit.
Hope it helps to speed things up. Have I really have to send a fax?
#5 Updated by Mr. Hudson almost 4 years ago
- Status changed from Accepted to Under Review
Patch set 1 of change Ib6d967ccc97ed64828bea8765edea5dd8c63aa0a has been pushed to the review server.
It is available at http://review.typo3.org/4725
#6 Updated by Mr. Hudson almost 4 years ago
Patch set 2 of change Ib6d967ccc97ed64828bea8765edea5dd8c63aa0a has been pushed to the review server.
It is available at http://review.typo3.org/4725
#7 Updated by Karsten Dambekalns almost 4 years ago
- Affected Flow version set to FLOW3 1.0.0
#8 Updated by Sebastian Kurfuerst over 3 years ago
- Status changed from Under Review to Resolved
- Has patch set to No
already merged long ago