Merge branch '3'

This commit is contained in:
Daniel Hensby 2017-03-03 15:09:17 +00:00
commit f225b83e2b
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
3 changed files with 18 additions and 3 deletions

View File

@ -22,7 +22,7 @@
<ul class="cms-tabset-nav-primary"> <ul class="cms-tabset-nav-primary">
<% loop $ManagedModelTabs %> <% loop $ManagedModelTabs %>
<li class="tab-$ClassName $LinkOrCurrent<% if $LinkOrCurrent == 'current' %> ui-tabs-active<% end_if %>"> <li class="tab-$ClassName $LinkOrCurrent<% if $LinkOrCurrent == 'current' %> ui-tabs-active<% end_if %>">
<a href="$Link" class="cms-panel-link" title="Form_EditForm">$Title</a> <a href="$Link" class="cms-panel-link" title="$Title.ATT">$Title</a>
</li> </li>
<% end_loop %> <% end_loop %>
</ul> </ul>

View File

@ -360,10 +360,12 @@ class SQLSelect extends SQLConditionalExpression
if (strpos($clause, '(') !== false || strpos($clause, " ") !== false) { if (strpos($clause, '(') !== false || strpos($clause, " ") !== false) {
// Move the clause to the select fragment, substituting a placeholder column in the sort fragment. // Move the clause to the select fragment, substituting a placeholder column in the sort fragment.
$clause = trim($clause); $clause = trim($clause);
do {
$column = "_SortColumn{$i}"; $column = "_SortColumn{$i}";
++$i;
} while (array_key_exists('"' . $column . '"', $this->orderby));
$this->selectField($clause, $column); $this->selectField($clause, $column);
$clause = '"' . $column . '"'; $clause = '"' . $column . '"';
$i++;
} }
$orderby[$clause] = $dir; $orderby[$clause] = $dir;
} }

View File

@ -141,6 +141,19 @@ class SQLSelectTest extends SapphireTest
$this->assertTrue($query->canSortBy('Name')); $this->assertTrue($query->canSortBy('Name'));
} }
/**
* Test multiple order by SQL clauses.
*/
public function testAddOrderBy()
{
$query = new SQLSelect();
$query->setSelect('ID', "Title")->setFrom('Page')->addOrderBy('(ID % 2) = 0', 'ASC')->addOrderBy('ID > 50', 'ASC');
$this->assertSQLEquals(
'SELECT ID, Title, (ID % 2) = 0 AS "_SortColumn0", ID > 50 AS "_SortColumn1" FROM Page ORDER BY "_SortColumn0" ASC, "_SortColumn1" ASC',
$query->sql($parameters)
);
}
public function testSelectWithChainedFilterParameters() public function testSelectWithChainedFilterParameters()
{ {
$query = new SQLSelect(); $query = new SQLSelect();