silverstripe/sapphire — pull request #1175 by dhensby (2013-02-11 13:19:39+00:00)
Title: BUG Default Sort table not always joined

I encountered a bug when doing:

CustomPage::get()->map()->toArray();

where CustomPage has public static $default_sort = "Date"; with a column called Date in that class's $db static.

An SQL error was thrown unkown column 'Date'. This was because the table for CustomPage was not included in the query as a join or from.

This is a rather inelegant fix and I'd love some guidence on how to select the join field more appropriately, as sometimes it should be ID and sometimes RecordID.

This seems to fix the issue for me, but I'm sure it's not very robust (with things like versioning and so on)