Skip to content

Commit

Permalink
Merge branch '5' into 6
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 12, 2024
2 parents 7ef5172 + b926834 commit 907cb17
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ORM/FieldType/DBClassNameTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\ORM\DataObject;
use RuntimeException;

trait DBClassNameTrait
{
Expand Down Expand Up @@ -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');
}
}

/**
Expand Down

0 comments on commit 907cb17

Please sign in to comment.