diff --git a/src/ORM/FieldType/DBBoolean.php b/src/ORM/FieldType/DBBoolean.php index c4d4c1c48..c38ddcdfa 100644 --- a/src/ORM/FieldType/DBBoolean.php +++ b/src/ORM/FieldType/DBBoolean.php @@ -15,7 +15,8 @@ class DBBoolean extends DBField { public function __construct(?string $name = null, bool|int $defaultVal = 0) { - $this->defaultVal = ($defaultVal) ? 1 : 0; + $defaultValue = $defaultVal ? 1 : 0; + $this->setDefaultValue($defaultValue); parent::__construct($name); } @@ -27,7 +28,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]; diff --git a/src/ORM/FieldType/DBField.php b/src/ORM/FieldType/DBField.php index 38efb5758..2752c2ff9 100644 --- a/src/ORM/FieldType/DBField.php +++ b/src/ORM/FieldType/DBField.php @@ -103,6 +103,7 @@ abstract class DBField extends ModelData implements DBIndexable * 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 mixed $defaultVal = null; diff --git a/src/ORM/FieldType/DBFloat.php b/src/ORM/FieldType/DBFloat.php index 824ff9f0b..c4eadc78c 100644 --- a/src/ORM/FieldType/DBFloat.php +++ b/src/ORM/FieldType/DBFloat.php @@ -13,7 +13,8 @@ class DBFloat extends DBField { public function __construct(?string $name = null, float|int $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]; diff --git a/src/ORM/FieldType/DBInt.php b/src/ORM/FieldType/DBInt.php index 0f46ddf54..ca12b2ead 100644 --- a/src/ORM/FieldType/DBInt.php +++ b/src/ORM/FieldType/DBInt.php @@ -16,7 +16,8 @@ class DBInt extends DBField { public function __construct(?string $name = null, int $defaultVal = 0) { - $this->defaultVal = is_int($defaultVal) ? $defaultVal : 0; + $defaultValue = is_int($defaultVal) ? $defaultVal : 0; + $this->setDefaultValue($defaultValue); parent::__construct($name); } @@ -44,7 +45,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];