mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.3' into 4.4
This commit is contained in:
commit
14673ffd0a
@ -1621,9 +1621,11 @@ class FormField extends RequestHandler
|
|||||||
*/
|
*/
|
||||||
public function getSchemaValidation()
|
public function getSchemaValidation()
|
||||||
{
|
{
|
||||||
|
$validationList = [];
|
||||||
if ($this->Required()) {
|
if ($this->Required()) {
|
||||||
return [ 'required' => true ];
|
$validationList['required'] = true;
|
||||||
}
|
}
|
||||||
return [];
|
$this->extend('updateSchemaValidation', $validationList);
|
||||||
|
return $validationList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class HeaderField extends DatalessField
|
|||||||
* @param string $title
|
* @param string $title
|
||||||
* @param int $headingLevel
|
* @param int $headingLevel
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $title, $headingLevel = 2)
|
public function __construct($name, $title = null, $headingLevel = 2)
|
||||||
{
|
{
|
||||||
$this->setHeadingLevel($headingLevel);
|
$this->setHeadingLevel($headingLevel);
|
||||||
parent::__construct($name, $title);
|
parent::__construct($name, $title);
|
||||||
|
@ -354,7 +354,6 @@ class DataQuery
|
|||||||
{
|
{
|
||||||
if ($orderby = $query->getOrderBy()) {
|
if ($orderby = $query->getOrderBy()) {
|
||||||
$newOrderby = array();
|
$newOrderby = array();
|
||||||
$i = 0;
|
|
||||||
foreach ($orderby as $k => $dir) {
|
foreach ($orderby as $k => $dir) {
|
||||||
$newOrderby[$k] = $dir;
|
$newOrderby[$k] = $dir;
|
||||||
|
|
||||||
@ -372,7 +371,6 @@ class DataQuery
|
|||||||
if (isset($originalSelect[$col])) {
|
if (isset($originalSelect[$col])) {
|
||||||
$query->selectField($originalSelect[$col], $col);
|
$query->selectField($originalSelect[$col], $col);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,10 +400,15 @@ class DataQuery
|
|||||||
if (!in_array($qualCol, $query->getSelect())) {
|
if (!in_array($qualCol, $query->getSelect())) {
|
||||||
unset($newOrderby[$k]);
|
unset($newOrderby[$k]);
|
||||||
|
|
||||||
$newOrderby["\"_SortColumn$i\""] = $dir;
|
// Find the first free "_SortColumnX" slot
|
||||||
$query->selectField($qualCol, "_SortColumn$i");
|
// and assign it to $key
|
||||||
|
$i = 0;
|
||||||
|
while (isset($orderby[$key = "\"_SortColumn$i\""])) {
|
||||||
|
++$i;
|
||||||
|
}
|
||||||
|
|
||||||
$i++;
|
$newOrderby[$key] = $dir;
|
||||||
|
$query->selectField($qualCol, "_SortColumn$i");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,6 +296,32 @@ class DataQueryTest extends SapphireTest
|
|||||||
static::resetDBSchema(true);
|
static::resetDBSchema(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSurrogateFieldSort()
|
||||||
|
{
|
||||||
|
$query = new DataQuery(DataQueryTest\ObjectE::class);
|
||||||
|
$query->sort(
|
||||||
|
sprintf(
|
||||||
|
'(case when "Title" = %s then 1 else 0 end)',
|
||||||
|
DB::get_conn()->quoteString('Second')
|
||||||
|
),
|
||||||
|
'DESC',
|
||||||
|
true
|
||||||
|
);
|
||||||
|
$query->sort('SortOrder', 'ASC', false);
|
||||||
|
$query->sort(
|
||||||
|
sprintf(
|
||||||
|
'(case when "Title" = %s then 0 else 1 end)',
|
||||||
|
DB::get_conn()->quoteString('Fourth')
|
||||||
|
),
|
||||||
|
'DESC',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$query->execute()->column('Title'),
|
||||||
|
$query->column('Title')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testComparisonClauseDateStartsWith()
|
public function testComparisonClauseDateStartsWith()
|
||||||
{
|
{
|
||||||
DB::query("INSERT INTO \"DataQueryTest_F\" (\"MyDate\") VALUES ('1988-03-04 06:30')");
|
DB::query("INSERT INTO \"DataQueryTest_F\" (\"MyDate\") VALUES ('1988-03-04 06:30')");
|
||||||
|
Loading…
Reference in New Issue
Block a user