silverstripe/sapphire — pull request #1043 by tractorcow (2012-12-17 04:24:31+00:00)
Title: Fix for issue #7975 - Issue with retrieving deleted pages

Issue: http://open.silverstripe.org/ticket/7975

When working with deleted pages, later queries to retrieve these objects would return incorrect values for the ID field. This was due to mangling of the query between Versioned and DataQuery on the ID column when ensuring that the query is properly sorted.

The fix I made was to:

* Make test cases to demonstrate the incorrect behaviour.
* Correctly apply a sort order expression for the query that retrieves deleted records.
* Ensure that DataQuery maintained the custom query expression for the ID field (_versioned.RecordID)
* Update the DataQuery::expressionForField function to only require one parameter, as it was used slightly incorrectly across the codebase, while at the same time fixing the function to behave better when ID has a custom expression.

This issue was discovered quite a long time ago, and my apologies for taking so long to get around to fixing this.