Merge branch '3.4' into 3

This commit is contained in:
Daniel Hensby 2016-10-27 16:16:04 +01:00
commit 3859a1d7e7
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
5 changed files with 32 additions and 7 deletions

View File

@ -328,7 +328,7 @@ When in a particular scope, `$Up` takes the scope back to the previous level.
<% end_loop %>
Given the following structure, it will output the text.
My Page
|
+-+ Child 1
@ -343,6 +343,16 @@ Given the following structure, it will output the text.
Page 'Grandchild 1' is a grandchild of 'My Page'
Page 'Child 2' is a child of 'MyPage'
<div class="notice" markdown="1">
Additional selectors implicitely change the scope so you need to put additional `$Up` to get what you expect.
</div>
:::ss
<h1>Children of '$Title'</h1>
<% loop $Children.Sort('Title').First %>
<%-- We have two additional selectors in the loop expression so... --%>
<p>Page '$Title' is a child of '$Up.Up.Up.Title'</p>
<% end_loop %>
### Top

View File

@ -9,7 +9,7 @@ covers how to create an `Email` instance, customise it with a HTML template, the
Out of the box, SilverStripe will use the built-in PHP `mail()` command. If you are not running an SMTP server, you
will need to either configure PHP's SMTP settings (see [PHP documentation](http://php.net/mail) to include your mail
server configuration or use one of the third party SMTP services like [Mandrill](https://github.com/lekoala/silverstripe-mandrill)
server configuration or use one of the third party SMTP services like [SparkPost](https://github.com/lekoala/silverstripe-sparkpost)
and [Postmark](https://github.com/fullscreeninteractive/silverstripe-postmarkmailer).
## Usage

View File

@ -392,7 +392,8 @@ class DataQuery {
* automatically so must not contain double quotes.
*/
public function max($field) {
return $this->aggregate("MAX(\"$field\")");
$table = ClassInfo::table_for_object_field($this->dataClass, $field);
return $this->aggregate("MAX(\"$table\".\"$field\")");
}
/**
@ -402,7 +403,8 @@ class DataQuery {
* automatically so must not contain double quotes.
*/
public function min($field) {
return $this->aggregate("MIN(\"$field\")");
$table = ClassInfo::table_for_object_field($this->dataClass, $field);
return $this->aggregate("MIN(\"$table\".\"$field\")");
}
/**
@ -412,7 +414,8 @@ class DataQuery {
* automatically so must not contain double quotes.
*/
public function avg($field) {
return $this->aggregate("AVG(\"$field\")");
$table = ClassInfo::table_for_object_field($this->dataClass, $field);
return $this->aggregate("AVG(\"$table\".\"$field\")");
}
/**
@ -422,7 +425,8 @@ class DataQuery {
* automatically so must not contain double quotes.
*/
public function sum($field) {
return $this->aggregate("SUM(\"$field\")");
$table = ClassInfo::table_for_object_field($this->dataClass, $field);
return $this->aggregate("SUM(\"$table\".\"$field\")");
}
/**

View File

@ -196,7 +196,7 @@ class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
}
user_error(
"SS_Map is read-only. Please use $map->push($key, $value) to append values",
'SS_Map is read-only. Please use $map->push($key, $value) to append values',
E_USER_ERROR
);
}

View File

@ -363,6 +363,17 @@ class DataListTest extends SapphireTest {
$this->assertEquals($otherExpected, $otherMap);
}
public function testAmbiguousAggregate() {
// Test that we avoid ambiguity error when a field exists on two joined tables
// Fetch the sponsors in a round-about way to simulate this
$teamID = $this->idFromFixture('DataObjectTest_Team','team2');
$sponsors = DataObjectTest_EquipmentCompany::get()->filter('SponsoredTeams.ID', $teamID);
$this->assertNotNull($sponsors->Max('ID'));
$this->assertNotNull($sponsors->Min('ID'));
$this->assertNotNull($sponsors->Avg('ID'));
$this->assertNotNull($sponsors->Sum('ID'));
}
public function testEach() {
$list = DataObjectTest_TeamComment::get();