From 4045443aea4beb919809ce98d7856710807fb8a7 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 12 Sep 2024 13:12:26 +1200 Subject: [PATCH] FIX Use correct constructors arguments --- src/ORM/FieldType/DBClassNameTrait.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ORM/FieldType/DBClassNameTrait.php b/src/ORM/FieldType/DBClassNameTrait.php index b2d6aac1d..3e48732e2 100644 --- a/src/ORM/FieldType/DBClassNameTrait.php +++ b/src/ORM/FieldType/DBClassNameTrait.php @@ -5,6 +5,7 @@ namespace SilverStripe\ORM\FieldType; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Config\Config; use SilverStripe\ORM\DataObject; +use RuntimeException; trait DBClassNameTrait { @@ -36,7 +37,13 @@ trait DBClassNameTrait public function __construct($name = null, $baseClass = null, $options = []) { $this->setBaseClass($baseClass); - parent::__construct($name, null, null, $options); + if (is_a($this, DBVarchar::class)) { + parent::__construct($name, 255, $options); + } elseif (is_a($this, DBEnum::class)) { + parent::__construct($name, null, null, $options); + } else { + throw new RuntimeException('DBClassNameTrait can only be used with DBVarchar or DBEnum'); + } } /**