Bug #64362

Sorting records by a related tables label column not possible

Added by Jan Kornblum over 4 years ago. Updated over 3 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
Category:
Backend User Interface
Target version:
Start date:
2015-01-19
Due date:
% Done:

0%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
nightmare
Is Regression:
No
Sprint Focus:

Description

Using the list module, it is not possible to sort records by the "label" column of a related (n:1) table.

Although TCA definition ("default_sortby", "label", etc.) is correct for both related tables, the records are sorted by the foreign records uid instead of its label column.

In my opinion this rather is a bug than a missing features, because the foreign tables "label" column is display correctly - but cannot be sorted.

I don't know if this only affects 4.5, but i could imagine it is the same behaviour with 6+. Core-people should know exactly ;)

testext_0.0.1.zip (6.46 KB) Jan Helke, 2015-10-30 18:38

History

#1 Updated by Jan Kornblum over 4 years ago

I don't know if this only affects 4.5, but i could imagine it is the same behaviour with 6+. Core-people should know exactly ;)

I can confirm the same behaviour in 6.2.3.

#2 Updated by Mathias Schreiber over 4 years ago

  • Status changed from New to Needs Feedback
  • Target version set to 7.4 (Backend)

That would mean that we'd need to join each related table whose field is visible to the table that is being listed.

I'd set the complexity to somewhere between "hard" and "nightmare" because it'd need a pretty solid rewrite of RecordList :)

#3 Updated by Jan Kornblum over 4 years ago

Oh, i didn't know that this would be so difficult. I've assumed that a join is already done for related tables columns and in this case respecting a "table.column" notation for default_sortby could be enough. How are the related labels fetched else? Single lookups?

#4 Updated by Alexander Opitz about 4 years ago

  • Status changed from Needs Feedback to New

#5 Updated by Susanne Moog almost 4 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#6 Updated by Felix Oertel almost 4 years ago

  • Priority changed from Must have to Should have
  • TYPO3 Version changed from 4.5 to 7

I am pretty sure this worked before.

As a temporary "solution" you can - please don't hurt me - do this:

[columns][category][config][foreign_table_where] => 'ORDER BY category.name'

I know it sounds wrong to put your ORDER-BY-string-SQL inside an option that is named something with "_where", but it is even in the official docs. ;-)

#7 Updated by Benni Mack almost 4 years ago

  • Target version changed from 7.5 to 7 LTS

#8 Updated by Jan Helke over 3 years ago

  • Status changed from New to In Progress
  • Assignee set to Jan Helke

#9 Updated by Jan Helke over 3 years ago

Attached you'll find a test extension to easily reproduce the issue. After installing there is a sql file containing a couple of data rows. Just replace the PID in the file with a value suitable for your system.

#10 Updated by Gerrit Code Review over 3 years ago

  • Status changed from In Progress to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44421

#11 Updated by Gerrit Code Review over 3 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44421

#12 Updated by Gerrit Code Review over 3 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44421

#13 Updated by Gerrit Code Review over 3 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44421

#14 Updated by Gerrit Code Review over 3 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44421

#15 Updated by Jan Helke over 3 years ago

  • Status changed from Under Review to Rejected
  • Complexity set to nightmare

I will abbanden my patch, because it came up, that this is not entirely fixable. I was able to fix it as long as we only deal with internal tables. But at the point somebody infused some addWhere stuff thru TCA (compare Felix coment about "order" in the where clause) without proper namespacing that (tablename.fieldname) it will break. And I see no reasonable way to write a parser that ensures sanitization in all cases.

Also available in: Atom PDF