Bug #64362
closed
Sorting records by a related tables label column not possible
Added by Jan Kornblum over 9 years ago.
Updated over 8 years ago.
Category:
Backend User Interface
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 ;)
Files
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.
- 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 :)
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?
- Status changed from Needs Feedback to New
- Target version changed from 7.4 (Backend) to 7.5
- 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. ;-)
- Target version changed from 7.5 to 7 LTS
- Status changed from New to In Progress
- Assignee set to Jan Helke
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.
- Status changed from In Progress to Under Review
- 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