mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '3'
This commit is contained in:
commit
e7df10dc52
18
docs/en/04_Changelogs/3.6.1.md
Normal file
18
docs/en/04_Changelogs/3.6.1.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# 3.6.1
|
||||||
|
|
||||||
|
<!--- Changes below this line will be automatically regenerated -->
|
||||||
|
|
||||||
|
## Change Log
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
* 2017-05-25 [c25478b](https://github.com/silverstripe/silverstripe-installer/commit/c25478bef75cc5482852e80a1fa6f1f0e6460e39) SVG uploads disabled by default (Daniel Hensby) - See [ss-2017-017](http://www.silverstripe.org/download/security-releases/ss-2017-017)
|
||||||
|
* 2017-05-25 [25b77a2](https://github.com/silverstripe/silverstripe-framework/commit/25b77a2ff8deabe8e8894002b9a5647eaec27b0a) SVG uploads disabled by default (Daniel Hensby) - See [ss-2017-017](http://www.silverstripe.org/download/security-releases/ss-2017-017)
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
* 2017-06-14 [1073eca](https://github.com/silverstripe/silverstripe-framework/commit/1073eca2fac1b05c0e20b02aea78e8a2f550cfe5) Complex (curly) syntax (Marcz Hermo)
|
||||||
|
* 2017-06-14 [fd57bd9](https://github.com/silverstripe/silverstripe-framework/commit/fd57bd9100634682fc5b2d9f493e3c54ce0444ad) Update help link from 3.5 to 3.6 (Robbie Averill)
|
||||||
|
* 2017-06-12 [f0c00bf](https://github.com/silverstripe/silverstripe-framework/commit/f0c00bfb7819c0350fa882f899d0c820a2aefa81) ing language typo in docs (3Dgoo)
|
||||||
|
* 2017-06-02 [a52ed03](https://github.com/silverstripe/silverstripe-framework/commit/a52ed03b49b8f62573eb3e295bfde84d1ef68f46) Upgrade old style constructors that were missed (Daniel Hensby)
|
||||||
|
* 2017-05-29 [b436819](https://github.com/silverstripe/silverstripe-framework/commit/b4368196d1bcee9fd1714b044c8ae6580c7941c9) Use plural name for ModelAdmin tab name (Robbie Averill)
|
18
docs/en/04_Changelogs/alpha/3.6.1-alpha1.md
Normal file
18
docs/en/04_Changelogs/alpha/3.6.1-alpha1.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# 3.6.1-alpha1
|
||||||
|
|
||||||
|
<!--- Changes below this line will be automatically regenerated -->
|
||||||
|
|
||||||
|
## Change Log
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
* 2017-05-25 [c25478b](https://github.com/silverstripe/silverstripe-installer/commit/c25478bef75cc5482852e80a1fa6f1f0e6460e39) SVG uploads disabled by default (Daniel Hensby) - See [ss-2017-017](http://www.silverstripe.org/download/security-releases/ss-2017-017)
|
||||||
|
* 2017-05-25 [25b77a2](https://github.com/silverstripe/silverstripe-framework/commit/25b77a2ff8deabe8e8894002b9a5647eaec27b0a) SVG uploads disabled by default (Daniel Hensby) - See [ss-2017-017](http://www.silverstripe.org/download/security-releases/ss-2017-017)
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
|
* 2017-06-14 [1073eca](https://github.com/silverstripe/silverstripe-framework/commit/1073eca2fac1b05c0e20b02aea78e8a2f550cfe5) Complex (curly) syntax (Marcz Hermo)
|
||||||
|
* 2017-06-14 [fd57bd9](https://github.com/silverstripe/silverstripe-framework/commit/fd57bd9100634682fc5b2d9f493e3c54ce0444ad) Update help link from 3.5 to 3.6 (Robbie Averill)
|
||||||
|
* 2017-06-12 [f0c00bf](https://github.com/silverstripe/silverstripe-framework/commit/f0c00bfb7819c0350fa882f899d0c820a2aefa81) ing language typo in docs (3Dgoo)
|
||||||
|
* 2017-06-02 [a52ed03](https://github.com/silverstripe/silverstripe-framework/commit/a52ed03b49b8f62573eb3e295bfde84d1ef68f46) Upgrade old style constructors that were missed (Daniel Hensby)
|
||||||
|
* 2017-05-29 [b436819](https://github.com/silverstripe/silverstripe-framework/commit/b4368196d1bcee9fd1714b044c8ae6580c7941c9) Use plural name for ModelAdmin tab name (Robbie Averill)
|
5
docs/en/04_Changelogs/alpha/3.6.1-alpha2.md
Normal file
5
docs/en/04_Changelogs/alpha/3.6.1-alpha2.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# 3.6.1-alpha2
|
||||||
|
|
||||||
|
<!--- Changes below this line will be automatically regenerated -->
|
||||||
|
|
||||||
|
## Change Log
|
@ -6,10 +6,10 @@ summary: Fix bugs and add new features to help make SilverStripe better.
|
|||||||
SilverStripe will never be finished, and we need your help to keep making it better. If you're a developer a great way to get involved is to contribute patches to our modules and core codebase, fixing bugs or adding features.
|
SilverStripe will never be finished, and we need your help to keep making it better. If you're a developer a great way to get involved is to contribute patches to our modules and core codebase, fixing bugs or adding features.
|
||||||
|
|
||||||
The SilverStripe core modules (`framework` and `cms`), as well as some of the more popular modules are in
|
The SilverStripe core modules (`framework` and `cms`), as well as some of the more popular modules are in
|
||||||
git version control. SilverStripe hosts its modules on [github.com/silverstripe](http://github.com/silverstripe) and [github.com/silverstripe-labs](http://github.com/silverstripe-labs). After [installing git](http://help.github.com/git-installation-redirect) and creating a [free github.com account](https://github.com/signup/free), you can "fork" a module,
|
git version control. SilverStripe hosts its modules on [github.com/silverstripe](https://github.com/silverstripe/). After [installing git](https://help.github.com/articles/set-up-git/) and creating a [free github.com account](https://github.com/join/), you can "fork" a module,
|
||||||
which creates a copy that you can commit to (see github's [guide to "forking"](http://help.github.com/forking/)).
|
which creates a copy that you can commit to (see github's [guide to "forking"](https://help.github.com/articles/fork-a-repo/)).
|
||||||
|
|
||||||
For other modules, our [add-ons site](http://addons.silverstripe.org/add-ons) lists the repository locations, typically using the version control system like "git".
|
For other modules, our [add-ons site](https://addons.silverstripe.org/add-ons/) lists the repository locations, typically using the version control system like "git".
|
||||||
|
|
||||||
If you are modifying CSS or JavaScript files in core modules, you'll need to regenerate some files.
|
If you are modifying CSS or JavaScript files in core modules, you'll need to regenerate some files.
|
||||||
Please check out our [client-side build tooling](build_tooling) guide for details.
|
Please check out our [client-side build tooling](build_tooling) guide for details.
|
||||||
@ -145,8 +145,8 @@ The current GitHub labels are grouped into five sections:
|
|||||||
|
|
||||||
### Quickfire Do's and Don't's
|
### Quickfire Do's and Don't's
|
||||||
|
|
||||||
If you aren't familiar with git and GitHub, try reading the ["GitHub bootcamp documentation"](http://help.github.com/).
|
If you aren't familiar with git and GitHub, try reading the ["GitHub bootcamp documentation"](https://help.github.com/).
|
||||||
We also found the [free online git book](http://git-scm.com/book/) and the [git crash course](http://gitref.org/) useful.
|
We also found the [free online git book](https://git-scm.com/book/en/v2) and the [git crash course](https://services.github.com/) useful.
|
||||||
If you're familiar with it, here's the short version of what you need to know. Once you fork and download the code:
|
If you're familiar with it, here's the short version of what you need to know. Once you fork and download the code:
|
||||||
|
|
||||||
* **Don't develop on the master branch.** Always create a development branch specific to "the issue" you're working on (on our [GitHub repository's issues](https://github.com/silverstripe/silverstripe-framework/issues)). Name it by issue number and description. For example, if you're working on Issue #100, a `DataObject::get_one()` bugfix, your development branch should be called 100-dataobject-get-one. If you decide to work on another issue mid-stream, create a new branch for that issue--don't work on both in one branch.
|
* **Don't develop on the master branch.** Always create a development branch specific to "the issue" you're working on (on our [GitHub repository's issues](https://github.com/silverstripe/silverstripe-framework/issues)). Name it by issue number and description. For example, if you're working on Issue #100, a `DataObject::get_one()` bugfix, your development branch should be called 100-dataobject-get-one. If you decide to work on another issue mid-stream, create a new branch for that issue--don't work on both in one branch.
|
||||||
@ -172,15 +172,15 @@ After you have edited the file, GitHub will offer to create a pull request for y
|
|||||||
* When working on existing tickets, provide status updates through ticket comments
|
* When working on existing tickets, provide status updates through ticket comments
|
||||||
* Check your patches against the "master" branch, as well as the latest release branch
|
* Check your patches against the "master" branch, as well as the latest release branch
|
||||||
* Write [unit tests](../developer_guides/testing/unit_testing)
|
* Write [unit tests](../developer_guides/testing/unit_testing)
|
||||||
* Write [Behat integration tests](https://github.com/silverstripe-labs/silverstripe-behat-extension) for any interface changes
|
* Write [Behat integration tests](https://github.com/silverstripe/silverstripe-behat-extension) for any interface changes
|
||||||
* Describe specifics on how to test the effects of the patch
|
* Describe specifics on how to test the effects of the patch
|
||||||
* It's better to submit multiple patches with separate bits of functionality than a big patch containing lots of changes
|
* It's better to submit multiple patches with separate bits of functionality than a big patch containing lots of changes
|
||||||
* Only submit a pull request for work you expect to be ready to merge. Work in progress is best discussed in an issue, or on your own repository fork.
|
* Only submit a pull request for work you expect to be ready to merge. Work in progress is best discussed in an issue, or on your own repository fork.
|
||||||
* Document your code inline through [PHPDoc](http://en.wikipedia.org/wiki/PHPDoc) syntax. See our
|
* Document your code inline through [PHPDoc](https://en.wikipedia.org/wiki/PHPDoc) syntax. See our
|
||||||
[API documentation](http://api.silverstripe.org/3.1/) for good examples.
|
[API documentation](https://api.silverstripe.org/) for good examples.
|
||||||
* Check and update documentation on [docs.silverstripe.org](http://docs.silverstripe.org). Check for any references to functionality deprecated or extended through your patch. Documentation changes should be included in the patch.
|
* Check and update documentation on [docs.silverstripe.org](https://docs.silverstripe.org). Check for any references to functionality deprecated or extended through your patch. Documentation changes should be included in the patch.
|
||||||
* When introducing something "noteworthy" (new feature, API change), [update the release changelog](/changelogs) for the next release this commit will be included in.
|
* When introducing something "noteworthy" (new feature, API change), [update the release changelog](/changelogs) for the next release this commit will be included in.
|
||||||
* If you get stuck, please post to the [forum](http://silverstripe.org/forum) or for deeper core problems, to the [core mailinglist](https://groups.google.com/forum/#!forum/silverstripe-dev)
|
* If you get stuck, please post to the [forum](https://www.silverstripe.org/community/forums) or for deeper core problems, to the [core mailinglist](https://groups.google.com/forum/#!forum/silverstripe-dev)
|
||||||
* When working with the CMS, please read the ["CMS Architecture Guide"](/developer_guides/customising_the_admin_interface/cms_architecture) first
|
* When working with the CMS, please read the ["CMS Architecture Guide"](/developer_guides/customising_the_admin_interface/cms_architecture) first
|
||||||
|
|
||||||
## Commit Messages
|
## Commit Messages
|
||||||
@ -190,7 +190,7 @@ Most importantly: Keep the first line short, and add more detail below.
|
|||||||
This ensures commits are easy to browse, and look nice on github.com
|
This ensures commits are easy to browse, and look nice on github.com
|
||||||
(more info about [proper git commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)).
|
(more info about [proper git commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)).
|
||||||
|
|
||||||
As we automatically generate [changelogs](http://localhost/SpiritLevel/SS/doc.silverstripe.org/en/changelogs/) from them, we need a way to categorize and filter.
|
As we automatically generate [changelogs](https://docs.silverstripe.org/en/changelogs/) from them, we need a way to categorize and filter.
|
||||||
Please prefix **noteworthy** commit messages with one of the following tags:
|
Please prefix **noteworthy** commit messages with one of the following tags:
|
||||||
|
|
||||||
* `NEW` New feature or major enhancement (both for users and developers)
|
* `NEW` New feature or major enhancement (both for users and developers)
|
||||||
@ -205,7 +205,7 @@ Same goes for version control plumbing like merges, file renames or reverts.
|
|||||||
Further guidelines:
|
Further guidelines:
|
||||||
|
|
||||||
* Each commit should form a logical unit - if you fix two unrelated bugs, commit each one separately
|
* Each commit should form a logical unit - if you fix two unrelated bugs, commit each one separately
|
||||||
* If you are fixing a issue from our bugtracker ([cms](http://github.com/silverstripe/silverstripe-framework) and [framework](http://github.com/silverstripe/silverstripe-framework)), please append `(fixes #<ticketnumber>)`
|
* If you are fixing a issue from our bugtracker ([cms](https://github.com/silverstripe/silverstripe-framework) and [framework](https://github.com/silverstripe/silverstripe-framework)), please append `(fixes #<ticketnumber>)`
|
||||||
* When fixing issues across repos (e.g. a commit to `framework` fixes an issue raised in the `cms` bugtracker),
|
* When fixing issues across repos (e.g. a commit to `framework` fixes an issue raised in the `cms` bugtracker),
|
||||||
use `(fixes silverstripe/silverstripe-cms#<issue-number>)` ([details](https://github.com/blog/1439-closing-issues-across-repositories))
|
use `(fixes silverstripe/silverstripe-cms#<issue-number>)` ([details](https://github.com/blog/1439-closing-issues-across-repositories))
|
||||||
* If your change is related to another commit, reference it with its abbreviated commit hash.
|
* If your change is related to another commit, reference it with its abbreviated commit hash.
|
||||||
|
@ -1093,7 +1093,7 @@ class DataQuery
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select the given fields from the given table.
|
* Select the only given fields from the given table.
|
||||||
*
|
*
|
||||||
* @param string $table Unquoted table name (will be escaped automatically)
|
* @param string $table Unquoted table name (will be escaped automatically)
|
||||||
* @param array $fields Database column names (will be escaped automatically)
|
* @param array $fields Database column names (will be escaped automatically)
|
||||||
@ -1102,7 +1102,7 @@ class DataQuery
|
|||||||
public function selectFromTable($table, $fields)
|
public function selectFromTable($table, $fields)
|
||||||
{
|
{
|
||||||
$fieldExpressions = array_map(function ($item) use ($table) {
|
$fieldExpressions = array_map(function ($item) use ($table) {
|
||||||
return "\"{$table}\".\"{$item}\"";
|
return Convert::symbol2sql("{$table}.{$item}");
|
||||||
}, $fields);
|
}, $fields);
|
||||||
|
|
||||||
$this->query->setSelect($fieldExpressions);
|
$this->query->setSelect($fieldExpressions);
|
||||||
@ -1110,6 +1110,24 @@ class DataQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the given fields from the given table to the select statement.
|
||||||
|
*
|
||||||
|
* @param string $table Unquoted table name (will be escaped automatically)
|
||||||
|
* @param array $fields Database column names (will be escaped automatically)
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function addSelectFromTable($table, $fields)
|
||||||
|
{
|
||||||
|
$fieldExpressions = array_map(function ($item) use ($table) {
|
||||||
|
return Convert::symbol2sql("{$table}.{$item}");
|
||||||
|
}, $fields);
|
||||||
|
|
||||||
|
$this->query->addSelect($fieldExpressions);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query the given field column from the database and return as an array.
|
* Query the given field column from the database and return as an array.
|
||||||
*
|
*
|
||||||
|
@ -118,7 +118,7 @@ class ManyManyList extends RelationList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dataQuery->selectFromTable($this->joinTable, $finalized);
|
$this->dataQuery->addSelectFromTable($this->joinTable, $finalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,18 +4,31 @@ namespace SilverStripe\ORM\Tests;
|
|||||||
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\ORM\Tests\DataObjectTest\Team;
|
use SilverStripe\ORM\Tests\DataObjectTest\Team;
|
||||||
|
use SilverStripe\ORM\Tests\HasManyListTest\Company;
|
||||||
|
use SilverStripe\ORM\Tests\HasManyListTest\CompanyCar;
|
||||||
|
use SilverStripe\ORM\Tests\HasManyListTest\Employee;
|
||||||
|
|
||||||
class HasManyListTest extends SapphireTest
|
class HasManyListTest extends SapphireTest
|
||||||
{
|
{
|
||||||
|
|
||||||
// Borrow the model from DataObjectTest
|
// Borrow the model from DataObjectTest
|
||||||
protected static $fixture_file = 'DataObjectTest.yml';
|
protected static $fixture_file = [
|
||||||
|
'DataObjectTest.yml', // Borrow the model from DataObjectTest
|
||||||
|
'HasManyListTest.yml',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static $extra_data_objects = array(
|
||||||
|
Company::class,
|
||||||
|
Employee::class,
|
||||||
|
CompanyCar::class,
|
||||||
|
);
|
||||||
|
|
||||||
public static function getExtraDataObjects()
|
public static function getExtraDataObjects()
|
||||||
{
|
{
|
||||||
return array_merge(
|
return array_merge(
|
||||||
DataObjectTest::$extra_data_objects,
|
DataObjectTest::$extra_data_objects,
|
||||||
ManyManyListTest::$extra_data_objects
|
ManyManyListTest::$extra_data_objects,
|
||||||
|
static::$extra_data_objects
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
tests/php/ORM/HasManyListTest.yml
Normal file
26
tests/php/ORM/HasManyListTest.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
SilverStripe\ORM\Tests\DataObjectTest\Company:
|
||||||
|
silverstripe:
|
||||||
|
Name: 'SilverStripe Ltd'
|
||||||
|
SilverStripe\ORM\Tests\HasManyListTest\Employee:
|
||||||
|
john:
|
||||||
|
Name: 'John Smith'
|
||||||
|
Company: =>SilverStripe\ORM\Tests\DataObjectTest\Company.silverstripe
|
||||||
|
jenny:
|
||||||
|
Name: 'Jenny Smith'
|
||||||
|
Company: =>SilverStripe\ORM\Tests\DataObjectTest\Company.silverstripe
|
||||||
|
SilverStripe\ORM\Tests\HasManyListTest\CompanyCar:
|
||||||
|
jaguar:
|
||||||
|
Make: 'Jaguar'
|
||||||
|
Model: 'E Type'
|
||||||
|
User: =>SilverStripe\ORM\Tests\HasManyListTest\Employee.john
|
||||||
|
Company: =>SilverStripe\ORM\Tests\DataObjectTest\Company.silverstripe
|
||||||
|
ferrari:
|
||||||
|
Make: 'Ferrari'
|
||||||
|
Model: 'F40'
|
||||||
|
User: =>SilverStripe\ORM\Tests\HasManyListTest\Employee.jenny
|
||||||
|
Company: =>SilverStripe\ORM\Tests\DataObjectTest\Company.silverstripe
|
||||||
|
lamborghini:
|
||||||
|
Make: 'Lamborghini'
|
||||||
|
Model: 'Countach'
|
||||||
|
User: =>SilverStripe\ORM\Tests\HasManyListTest\Employee.jenny
|
||||||
|
Company: =>SilverStripe\ORM\Tests\DataObjectTest\Company.silverstripe
|
18
tests/php/ORM/HasManyListTest/Company.php
Normal file
18
tests/php/ORM/HasManyListTest/Company.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Tests\HasManyListTest;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class Company extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $db = array(
|
||||||
|
'Name' => 'Varchar(100)',
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $has_many = array(
|
||||||
|
'Employees' => Employee::class,
|
||||||
|
'CompanyCars' => CompanyCar::class,
|
||||||
|
);
|
||||||
|
}
|
19
tests/php/ORM/HasManyListTest/CompanyCar.php
Normal file
19
tests/php/ORM/HasManyListTest/CompanyCar.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Tests\HasManyListTest;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class CompanyCar extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $db = array(
|
||||||
|
'Make' => 'Varchar(100)',
|
||||||
|
'Model' => 'Varchar(100)',
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $has_one = array(
|
||||||
|
'User' => Employee::class,
|
||||||
|
'Company' => Company::class,
|
||||||
|
);
|
||||||
|
}
|
21
tests/php/ORM/HasManyListTest/Employee.php
Normal file
21
tests/php/ORM/HasManyListTest/Employee.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Tests\HasManyListTest;
|
||||||
|
|
||||||
|
use SilverStripe\Dev\TestOnly;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
class Employee extends DataObject implements TestOnly
|
||||||
|
{
|
||||||
|
private static $db = array(
|
||||||
|
'Name' => 'Varchar(100)',
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $has_one = array(
|
||||||
|
'Company' => Company::class,
|
||||||
|
);
|
||||||
|
|
||||||
|
private static $has_many = array(
|
||||||
|
'CompanyCars' => CompanyCar::class,
|
||||||
|
);
|
||||||
|
}
|
@ -8,6 +8,8 @@ use SilverStripe\Core\Convert;
|
|||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\ORM\Tests\DataObjectTest\Player;
|
use SilverStripe\ORM\Tests\DataObjectTest\Player;
|
||||||
use SilverStripe\ORM\Tests\DataObjectTest\Team;
|
use SilverStripe\ORM\Tests\DataObjectTest\Team;
|
||||||
|
use SilverStripe\ORM\Tests\ManyManyListTest\ExtraFieldsObject;
|
||||||
|
use SilverStripe\ORM\Tests\ManyManyListTest\Product;
|
||||||
|
|
||||||
class ManyManyListTest extends SapphireTest
|
class ManyManyListTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -53,6 +55,29 @@ class ManyManyListTest extends SapphireTest
|
|||||||
$this->assertEquals(100, $check->Worth->getAmount());
|
$this->assertEquals(100, $check->Worth->getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test targets a bug where appending many_many_extraFields to a query would
|
||||||
|
* result in erroneous queries for sort orders that rely on _SortColumn0
|
||||||
|
*/
|
||||||
|
public function testAddCompositedExtraFieldsWithSortColumn0()
|
||||||
|
{
|
||||||
|
$obj = new ExtraFieldsObject();
|
||||||
|
$obj->write();
|
||||||
|
|
||||||
|
$product = new Product();
|
||||||
|
$product->Title = 'Test Product';
|
||||||
|
$product->write();
|
||||||
|
|
||||||
|
// the actual test is that this does not generate an error in the sql.
|
||||||
|
$obj->Products()->add($product, array(
|
||||||
|
'Reference' => 'Foo'
|
||||||
|
));
|
||||||
|
|
||||||
|
$result = $obj->Products()->First();
|
||||||
|
$this->assertEquals('Foo', $result->Reference, 'Basic scalar fields should exist');
|
||||||
|
$this->assertEquals('Test Product', $result->Title);
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateList()
|
public function testCreateList()
|
||||||
{
|
{
|
||||||
$list = ManyManyList::create(
|
$list = ManyManyList::create(
|
||||||
|
@ -10,7 +10,8 @@ class ExtraFieldsObject extends DataObject implements TestOnly
|
|||||||
private static $table_name = 'ManyManyListTest_ExtraFields';
|
private static $table_name = 'ManyManyListTest_ExtraFields';
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'Clients' => ExtraFieldsObject::class
|
'Clients' => ExtraFieldsObject::class,
|
||||||
|
'Products' => Product::class,
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
@ -21,6 +22,9 @@ class ExtraFieldsObject extends DataObject implements TestOnly
|
|||||||
'Clients' => array(
|
'Clients' => array(
|
||||||
'Reference' => 'Varchar',
|
'Reference' => 'Varchar',
|
||||||
'Worth' => 'Money'
|
'Worth' => 'Money'
|
||||||
)
|
),
|
||||||
|
'Products' => array(
|
||||||
|
'Reference' => 'Varchar',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,4 +21,6 @@ class Product extends DataObject implements TestOnly
|
|||||||
'RelatedTo' => Product::class,
|
'RelatedTo' => Product::class,
|
||||||
'Categories' => Category::class
|
'Categories' => Category::class
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $default_sort = '"Title" IS NOT NULL ASC, "Title" ASC';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user