Compare commits

...

2 Commits

Author SHA1 Message Date
Steve Boyd
b8bdf23e1e
Merge 8ec068f3fd into ebbd6427b2 2024-10-17 03:06:12 +00:00
Steve Boyd
8ec068f3fd API Add deprecation 2024-10-17 16:06:06 +13:00
4 changed files with 10 additions and 6 deletions

View File

@ -13,7 +13,8 @@ class DBBoolean extends DBField
{
public function __construct($name = null, $defaultVal = 0)
{
$this->defaultVal = ($defaultVal) ? 1 : 0;
$defaultValue = $defaultVal ? 1 : 0;
$this->setDefaultValue($defaultValue);
parent::__construct($name);
}
@ -25,7 +26,7 @@ class DBBoolean extends DBField
'precision' => 1,
'sign' => 'unsigned',
'null' => 'not null',
'default' => $this->defaultVal,
'default' => $this->getDefaultValue(),
'arrayValue' => $this->arrayValue
];
$values = ['type' => 'boolean', 'parts' => $parts];

View File

@ -122,6 +122,7 @@ abstract class DBField extends ViewableData implements DBIndexable
* @var $default mixed Default-value in the database.
* Might be overridden on DataObject-level, but still useful for setting defaults on
* already existing records after a db-build.
* @deprecated 5.4.0 Use getDefaultValue() and setDefaultValue() instead
*/
protected $defaultVal;

View File

@ -13,7 +13,8 @@ class DBFloat extends DBField
public function __construct($name = null, $defaultVal = 0)
{
$this->defaultVal = is_float($defaultVal) ? $defaultVal : (float) 0;
$defaultValue = is_float($defaultVal) ? $defaultVal : (float) 0;
$this->setDefaultValue($defaultValue);
parent::__construct($name);
}
@ -23,7 +24,7 @@ class DBFloat extends DBField
$parts = [
'datatype' => 'float',
'null' => 'not null',
'default' => $this->defaultVal,
'default' => $this->getDefaultValue(),
'arrayValue' => $this->arrayValue
];
$values = ['type' => 'float', 'parts' => $parts];

View File

@ -15,7 +15,8 @@ class DBInt extends DBField
public function __construct($name = null, $defaultVal = 0)
{
$this->defaultVal = is_int($defaultVal) ? $defaultVal : 0;
$defaultValue = is_int($defaultVal) ? $defaultVal : 0;
$this->setDefaultValue($defaultValue);
parent::__construct($name);
}
@ -43,7 +44,7 @@ class DBInt extends DBField
'datatype' => 'int',
'precision' => 11,
'null' => 'not null',
'default' => $this->defaultVal,
'default' => $this->getDefaultValue(),
'arrayValue' => $this->arrayValue
];
$values = ['type' => 'int', 'parts' => $parts];