diff --git a/src/Schema/Column/ColumnSchemaInterface.php b/src/Schema/Column/ColumnSchemaInterface.php index ef9a9de89..d979cf7fd 100644 --- a/src/Schema/Column/ColumnSchemaInterface.php +++ b/src/Schema/Column/ColumnSchemaInterface.php @@ -28,6 +28,7 @@ * table?: string|null, * type?: string, * unsigned?: bool|string, + * ... * } */ interface ColumnSchemaInterface diff --git a/tests/AbstractColumnFactoryTest.php b/tests/AbstractColumnFactoryTest.php index 54ea35893..8ade7dbe6 100644 --- a/tests/AbstractColumnFactoryTest.php +++ b/tests/AbstractColumnFactoryTest.php @@ -5,6 +5,7 @@ namespace Yiisoft\Db\Tests; use PHPUnit\Framework\TestCase; +use Yiisoft\Db\Schema\Column\StringColumnSchema; use Yiisoft\Db\Tests\Support\TestTrait; abstract class AbstractColumnFactoryTest extends TestCase @@ -56,4 +57,17 @@ public function testFromType(string $type, string $expectedType, string $expecte $this->assertInstanceOf($expectedInstanceOf, $column); $this->assertSame($expectedType, $column->getType()); } + + public function testFromDefinitionWithExtra(): void + { + $db = $this->getConnection(); + $factory = $db->getSchema()->getColumnFactory(); + + $column = $factory->fromDefinition('char(1) NOT NULL', ['extra' => 'UNIQUE']); + + $this->assertInstanceOf(StringColumnSchema::class, $column); + $this->assertSame('char', $column->getType()); + $this->assertSame(1, $column->getSize()); + $this->assertSame('NOT NULL UNIQUE', $column->getExtra()); + } } diff --git a/tests/Provider/ColumnSchemaProvider.php b/tests/Provider/ColumnSchemaProvider.php index cce582793..4ae2a12a2 100644 --- a/tests/Provider/ColumnSchemaProvider.php +++ b/tests/Provider/ColumnSchemaProvider.php @@ -274,6 +274,10 @@ public static function load(): array ['name', null, 'getName', null], ['precision', 10, 'getPrecision', 10], ['precision', null, 'getPrecision', null], + ['primary_key', true, 'isPrimaryKey', true], + ['primary_key', false, 'isPrimaryKey', false], + ['primary_key', '1', 'isPrimaryKey', true], + ['primary_key', '0', 'isPrimaryKey', false], ['scale', 2, 'getScale', 2], ['scale', null, 'getScale', null], ['size', 255, 'getSize', 255],