mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR remove sort direction when running canSortBy. Also added test coverage for this. (from r96428) (from r98138)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102610 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
10537d5133
commit
9b650a4e6c
@ -455,6 +455,8 @@ class SQLQuery {
|
||||
* "false" more often that is strictly necessary.
|
||||
*/
|
||||
function canSortBy($fieldName) {
|
||||
$fieldName = preg_replace('/(\s+?)(A|DE)SC$/', '', $fieldName);
|
||||
|
||||
$sql = $this->sql();
|
||||
|
||||
$selects = $this->select;
|
||||
|
@ -50,6 +50,13 @@ class SQLQueryTest extends SapphireTest {
|
||||
$this->assertEquals("SELECT Name, Meta FROM MyTable WHERE (Name = 'Name') AND (Meta = 'Test')", $query->sql());
|
||||
}
|
||||
|
||||
function testCanSortBy() {
|
||||
$query = new SQLQuery();
|
||||
$query->select("Name","Meta")->from("MyTable")->where("Name", "Name")->where("Meta", "Test");
|
||||
$this->assertTrue($query->canSortBy('Name ASC'));
|
||||
$this->assertTrue($query->canSortBy('Name'));
|
||||
}
|
||||
|
||||
function testSelectWithChainedFilterParameters() {
|
||||
$query = new SQLQuery();
|
||||
$query->select(array("Name","Meta"))->from("MyTable");
|
||||
|
Loading…
x
Reference in New Issue
Block a user