mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Applying patch from 'BrendonCoz'. Model::deconstruct() now allows null for time column types. Closes #5659
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7782 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
2d1483e1e5
commit
b3a6a06f80
2 changed files with 25 additions and 0 deletions
|
@ -813,6 +813,9 @@ class Model extends Overloadable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$date = str_replace(array_keys($date), array_values($date), $format);
|
$date = str_replace(array_keys($date), array_values($date), $format);
|
||||||
|
if ($type == 'time' && $date == '00:00:00') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($useNewDate && (!empty($date))) {
|
if ($useNewDate && (!empty($date))) {
|
||||||
return $date;
|
return $date;
|
||||||
|
|
|
@ -5136,6 +5136,7 @@ class ModelTest extends CakeTestCase {
|
||||||
$this->loadFixtures('Apple');
|
$this->loadFixtures('Apple');
|
||||||
$TestModel =& new Apple();
|
$TestModel =& new Apple();
|
||||||
|
|
||||||
|
//test null/empty values first
|
||||||
$data['Apple']['created']['year'] = '';
|
$data['Apple']['created']['year'] = '';
|
||||||
$data['Apple']['created']['month'] = '';
|
$data['Apple']['created']['month'] = '';
|
||||||
$data['Apple']['created']['day'] = '';
|
$data['Apple']['created']['day'] = '';
|
||||||
|
@ -5148,6 +5149,27 @@ class ModelTest extends CakeTestCase {
|
||||||
$expected = array('Apple'=> array('created'=> ''));
|
$expected = array('Apple'=> array('created'=> ''));
|
||||||
$this->assertEqual($TestModel->data, $expected);
|
$this->assertEqual($TestModel->data, $expected);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['Apple']['date']['year'] = '';
|
||||||
|
$data['Apple']['date']['month'] = '';
|
||||||
|
$data['Apple']['date']['day'] = '';
|
||||||
|
|
||||||
|
$TestModel->data = null;
|
||||||
|
$TestModel->set($data);
|
||||||
|
$expected = array('Apple'=> array('date'=> ''));
|
||||||
|
$this->assertEqual($TestModel->data, $expected);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['Apple']['mytime']['hour'] = '';
|
||||||
|
$data['Apple']['mytime']['min'] = '';
|
||||||
|
$data['Apple']['mytime']['sec'] = '';
|
||||||
|
|
||||||
|
$TestModel->data = null;
|
||||||
|
$TestModel->set($data);
|
||||||
|
$expected = array('Apple'=> array('mytime'=> ''));
|
||||||
|
$this->assertEqual($TestModel->data, $expected);
|
||||||
|
|
||||||
|
//test other data variations
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['Apple']['created']['year'] = '2007';
|
$data['Apple']['created']['year'] = '2007';
|
||||||
$data['Apple']['created']['month'] = '08';
|
$data['Apple']['created']['month'] = '08';
|
||||||
|
|
Loading…
Reference in a new issue