diff --git a/CHANGELOG.md b/CHANGELOG.md index b1aad06aa..f0fe8660f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - New #906: Add `ServerInfoInterface` and its implementation (@Tigrov) - Enh #905: Use `AbstractColumnDefinitionBuilder` to generate table column SQL representation (@Tigrov) - Enh #915: Remove `ColumnInterface` (@Tigrov) +- Enh #917: Rename `ColumnSchemaInterface` to `ColumnInterface` (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/UPGRADE.md b/UPGRADE.md index b9dcdb764..2856ed75d 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -11,11 +11,12 @@ application when you upgrade the package from one version to another. ### Remove `ColumnInterface` -Remove `ColumnInterface` and use `ColumnSchemaInterface` instead. +- Remove `ColumnInterface` and use `ColumnSchemaInterface` instead; +- Rename `ColumnSchemaInterface` to `ColumnInterface`. -### `ColumnSchemaInterface` as column type +### `ColumnInterface` as column type -Add `ColumnSchemaInterface` support and change type of parameter `$type` to `ColumnSchemaInterface|string` +Add `ColumnInterface` support and change type of parameter `$type` to `ColumnInterface|string` in the following methods: - `addColumn()` - `alterColumn()` @@ -67,7 +68,9 @@ $db->createCommand()->insertBatch('user', $values)->execute(); ### `ColumnSchemaInterface` changes -The interface and the abstract implementation `AbstractColumnSchema` were moved to `Yiisoft\Db\Schema\Column` namespace +Rename `ColumnSchemaInterface` to `ColumnInterface`. + +The interface and the abstract implementation `AbstractColumn` were moved to `Yiisoft\Db\Schema\Column` namespace and the following changes were made: - `getName()` method can return `string` or `null`; @@ -83,8 +86,8 @@ and the following changes were made: - `unique(bool $unique = true)` method is added; - `isUnique()` method is added; - `hasDefaultValue()` method is added; -- all `AbstractColumnSchema` class properties except `$type` moved to constructor; -- added `DEFAULT_TYPE` constant to `AbstractColumnSchema` class; +- all `AbstractColumn` class properties except `$type` moved to constructor; +- added `DEFAULT_TYPE` constant to `AbstractColumn` class; - added method chaining. ### New classes with constants @@ -98,16 +101,16 @@ and the following changes were made: Each table column has its own class in the `Yiisoft\Db\Schema\Column` namespace according to the data type: -- `BooleanColumnSchema` for columns with boolean type; -- `BitColumnSchema` for columns with bit type; -- `IntegerColumnSchema` for columns with integer type (tinyint, smallint, integer, bigint); -- `BigIntColumnSchema` for columns with integer type with range outside `PHP_INT_MIN` and `PHP_INT_MAX`; -- `DoubleColumnSchema` for columns with fractional number type (float, double, decimal, money); -- `StringColumnSchema` for columns with string or datetime type (char, string, text, datetime, timestamp, date, time); -- `BinaryColumnSchema` for columns with binary type; -- `ArrayColumnSchema` for columns with array type; -- `StructuredColumnSchema` for columns with structured type (composite type in PostgreSQL); -- `JsonColumnSchema` for columns with json type. +- `BooleanColumn` for columns with boolean type; +- `BitColumn` for columns with bit type; +- `IntegerColumn` for columns with integer type (tinyint, smallint, integer, bigint); +- `BigIntColumn` for columns with integer type with range outside `PHP_INT_MIN` and `PHP_INT_MAX`; +- `DoubleColumn` for columns with fractional number type (float, double, decimal, money); +- `StringColumn` for columns with string or datetime type (char, string, text, datetime, timestamp, date, time); +- `BinaryColumn` for columns with binary type; +- `ArrayColumn` for columns with array type; +- `StructuredColumn` for columns with structured type (composite type in PostgreSQL); +- `JsonColumn` for columns with json type. ### New methods diff --git a/docs/guide/en/schema/usage.md b/docs/guide/en/schema/usage.md index 9ce193641..668105767 100644 --- a/docs/guide/en/schema/usage.md +++ b/docs/guide/en/schema/usage.md @@ -74,7 +74,7 @@ echo $tableSchema->getCreateSql(); In the full name is a table name prefixed by database schema. If the schema name is the same as the default schema, the full name won't include the schema name. -### Retrieving column schemas +### Retrieving table columns You can retrieve the column metadata for a given table using either the `getColumns()` method or `getColumn()` method of `TableSchema` class: @@ -95,5 +95,5 @@ $column = $tableSchema->getColumn('id'); echo 'id (' . $column->getDbType() . ')'; ``` -In either case you get instance or instances -or `ColumnSchemaInterface` that you can use to get all the information about the column. +In either case you get instance or instances of `ColumnInterface` that you can use to get available information about +the column. diff --git a/src/Command/AbstractCommand.php b/src/Command/AbstractCommand.php index 959f526f7..a010b5b43 100644 --- a/src/Command/AbstractCommand.php +++ b/src/Command/AbstractCommand.php @@ -11,7 +11,7 @@ use Yiisoft\Db\Query\QueryInterface; use Yiisoft\Db\QueryBuilder\DMLQueryBuilderInterface; use Yiisoft\Db\QueryBuilder\QueryBuilderInterface; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use function explode; use function get_resource_type; @@ -131,7 +131,7 @@ public function addCheck(string $table, string $name, string $expression): stati return $this->setSql($sql)->requireTableSchemaRefresh($table); } - public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): static + public function addColumn(string $table, string $column, ColumnInterface|string $type): static { $sql = $this->getQueryBuilder()->addColumn($table, $column, $type); return $this->setSql($sql)->requireTableSchemaRefresh($table); @@ -188,7 +188,7 @@ public function addUnique(string $table, string $name, array|string $columns): s return $this->setSql($sql)->requireTableSchemaRefresh($table); } - public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): static + public function alterColumn(string $table, string $column, ColumnInterface|string $type): static { $sql = $this->getQueryBuilder()->alterColumn($table, $column, $type); return $this->setSql($sql)->requireTableSchemaRefresh($table); diff --git a/src/Command/CommandInterface.php b/src/Command/CommandInterface.php index faf0530e4..975cb9abf 100644 --- a/src/Command/CommandInterface.php +++ b/src/Command/CommandInterface.php @@ -18,7 +18,7 @@ use Yiisoft\Db\Query\Data\DataReaderInterface; use Yiisoft\Db\Query\QueryInterface; use Yiisoft\Db\QueryBuilder\DMLQueryBuilderInterface; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; /** * This interface represents a database command, such as a `SELECT`, `INSERT`, `UPDATE`, or `DELETE` statement. @@ -46,13 +46,13 @@ public function addCheck(string $table, string $name, string $expression): stati * * @param string $table The name of the table to add new column to. * @param string $column The name of the new column. - * @param ColumnSchemaInterface|string $type The column type. + * @param ColumnInterface|string $type The column type. * {@see QueryBuilder::buildColumnDefinition()} will be called to convert the given column type to the database one. * For example, `string` will be converted to `varchar(255)`, and `string not null` becomes `varchar(255) not null`. * * Note: The method will quote the `table` and `column` parameters before using them in the generated SQL. */ - public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): static; + public function addColumn(string $table, string $column, ColumnInterface|string $type): static; /** * Builds an SQL command for adding a comment to a column. @@ -146,13 +146,13 @@ public function addPrimaryKey(string $table, string $name, array|string $columns * * @param string $table The table whose column is to change. * @param string $column The name of the column to change. - * @param ColumnSchemaInterface|string $type The column type. + * @param ColumnInterface|string $type The column type. * {@see QueryBuilder::buildColumnDefinition()} will be called to convert the give column type to the physical one. * For example, `string` will be converted as `varchar(255)`, and `string not null` becomes `varchar(255) not null`. * * Note: The method will quote the `table` and `column` parameters before using them in the generated SQL. */ - public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): static; + public function alterColumn(string $table, string $column, ColumnInterface|string $type): static; /** * Creates a batch INSERT command. @@ -319,14 +319,14 @@ public function createIndex( * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name * is the name of the column which will be properly quoted by the method, and definition is the type of the column * which can contain a native database column type, {@see ColumnType abstract} or {@see PseudoType pseudo} type, - * or can be represented as instance of {@see ColumnSchemaInterface}. + * or can be represented as instance of {@see ColumnInterface}. * * The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions * into SQL representation. For example, it will convert `string not null` to `varchar(255) not null` * and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL). * * The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * ```php * $this->createTable( @@ -348,8 +348,8 @@ public function createIndex( * generated SQL. * * @param string $table The name of the table to create. - * @param (ColumnSchemaInterface|string)[] $columns The columns (name => definition) in the new table. - * The definition can be `string` or {@see ColumnSchemaInterface} instance. + * @param (ColumnInterface|string)[] $columns The columns (name => definition) in the new table. + * The definition can be `string` or {@see ColumnInterface} instance. * @param string|null $options More SQL fragments to append to the generated SQL. * * @throws Exception @@ -358,7 +358,7 @@ public function createIndex( * * Note: The method will quote the `table` and `columns` parameter before using it in the generated SQL. * - * @psalm-param array|string[] $columns + * @psalm-param array|string[] $columns */ public function createTable(string $table, array $columns, string $options = null): static; diff --git a/src/Constant/PhpType.php b/src/Constant/PhpType.php index 3825d2c7a..e9b2691f0 100644 --- a/src/Constant/PhpType.php +++ b/src/Constant/PhpType.php @@ -4,13 +4,13 @@ namespace Yiisoft\Db\Constant; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; /** * Defines the available PHP types. * Used to generate properties of a related model class. * - * @see ColumnSchemaInterface::getPhpType() + * @see ColumnInterface::getPhpType() * @see https://www.php.net/manual/en/language.types.type-system.php */ final class PhpType diff --git a/src/Debug/CommandInterfaceProxy.php b/src/Debug/CommandInterfaceProxy.php index eceb0b796..ee4725d67 100644 --- a/src/Debug/CommandInterfaceProxy.php +++ b/src/Debug/CommandInterfaceProxy.php @@ -9,7 +9,7 @@ use Yiisoft\Db\Command\CommandInterface; use Yiisoft\Db\Query\Data\DataReaderInterface; use Yiisoft\Db\Query\QueryInterface; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; final class CommandInterfaceProxy implements CommandInterface { @@ -30,7 +30,7 @@ public function addCheck(string $table, string $name, string $expression): stati /** * @psalm-suppress MixedArgument */ - public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): static + public function addColumn(string $table, string $column, ColumnInterface|string $type): static { return new self($this->decorated->{__FUNCTION__}(...func_get_args()), $this->collector); } @@ -93,7 +93,7 @@ public function addUnique(string $table, string $name, array|string $columns): s /** * @psalm-suppress MixedArgument */ - public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): static + public function alterColumn(string $table, string $column, ColumnInterface|string $type): static { return new self($this->decorated->{__FUNCTION__}(...func_get_args()), $this->collector); } diff --git a/src/Expression/StructuredExpression.php b/src/Expression/StructuredExpression.php index ffbc6efc6..847bebbfe 100644 --- a/src/Expression/StructuredExpression.php +++ b/src/Expression/StructuredExpression.php @@ -5,7 +5,7 @@ namespace Yiisoft\Db\Expression; use Traversable; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use function array_key_exists; use function array_keys; @@ -38,10 +38,10 @@ final class StructuredExpression implements ExpressionInterface * @param string|null $type The structured database type name. Defaults to `null` which means the type is not * explicitly specified. Note that in the case where a type is not specified explicitly and DBMS cannot guess it * from the context, SQL error will be raised. - * @param ColumnSchemaInterface[] $columns The structured type columns that are used for value normalization and type + * @param ColumnInterface[] $columns The structured type columns that are used for value normalization and type * casting. * - * @psalm-param array $columns + * @psalm-param array $columns */ public function __construct( private array|object $value, @@ -66,7 +66,7 @@ public function getType(): string|null /** * The structured type columns that are used for value normalization and type casting. * - * @return ColumnSchemaInterface[] + * @return ColumnInterface[] */ public function getColumns(): array { diff --git a/src/QueryBuilder/AbstractColumnDefinitionBuilder.php b/src/QueryBuilder/AbstractColumnDefinitionBuilder.php index b614a2e6c..b0894c30f 100644 --- a/src/QueryBuilder/AbstractColumnDefinitionBuilder.php +++ b/src/QueryBuilder/AbstractColumnDefinitionBuilder.php @@ -5,13 +5,13 @@ namespace Yiisoft\Db\QueryBuilder; use Yiisoft\Db\Constant\ColumnType; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use function in_array; use function strtolower; /** - * Builds column definition from {@see ColumnSchemaInterface} object. Column definition is a string that represents + * Builds column definition from {@see ColumnInterface} object. Column definition is a string that represents * the column type and all constraints associated with the column. For example: `VARCHAR(128) NOT NULL DEFAULT 'foo'`. */ abstract class AbstractColumnDefinitionBuilder implements ColumnDefinitionBuilderInterface @@ -34,18 +34,18 @@ abstract class AbstractColumnDefinitionBuilder implements ColumnDefinitionBuilde /** * Get the database column type for the given column. * - * @param ColumnSchemaInterface $column The column object. + * @param ColumnInterface $column The column object. * * @return string The database column type. */ - abstract protected function getDbType(ColumnSchemaInterface $column): string; + abstract protected function getDbType(ColumnInterface $column): string; public function __construct( protected QueryBuilderInterface $queryBuilder, ) { } - public function build(ColumnSchemaInterface $column): string + public function build(ColumnInterface $column): string { return $this->buildType($column) . $this->buildUnsigned($column) @@ -60,7 +60,7 @@ public function build(ColumnSchemaInterface $column): string . $this->buildExtra($column); } - public function buildAlter(ColumnSchemaInterface $column): string + public function buildAlter(ColumnInterface $column): string { return $this->build($column); } @@ -70,7 +70,7 @@ public function buildAlter(ColumnSchemaInterface $column): string * * @return string A string containing the {@see AUTO_INCREMENT_KEYWORD} keyword. */ - protected function buildAutoIncrement(ColumnSchemaInterface $column): string + protected function buildAutoIncrement(ColumnInterface $column): string { if (empty(static::AUTO_INCREMENT_KEYWORD) || !$column->isAutoIncrement()) { return ''; @@ -90,7 +90,7 @@ protected function buildAutoIncrement(ColumnSchemaInterface $column): string * * @return string A string containing the CHECK constraint. */ - protected function buildCheck(ColumnSchemaInterface $column): string + protected function buildCheck(ColumnInterface $column): string { $check = $column->getCheck(); @@ -102,7 +102,7 @@ protected function buildCheck(ColumnSchemaInterface $column): string * * @return string A string containing the COMMENT keyword and the comment itself. */ - protected function buildComment(ColumnSchemaInterface $column): string + protected function buildComment(ColumnInterface $column): string { return ''; } @@ -112,7 +112,7 @@ protected function buildComment(ColumnSchemaInterface $column): string * * @return string A string containing the DEFAULT keyword and the default value. */ - protected function buildDefault(ColumnSchemaInterface $column): string + protected function buildDefault(ColumnInterface $column): string { $uuidExpression = $this->getDefaultUuidExpression(); @@ -145,7 +145,7 @@ protected function buildDefault(ColumnSchemaInterface $column): string * * @return string A string containing the custom SQL fragment appended to column definition. */ - protected function buildExtra(ColumnSchemaInterface $column): string + protected function buildExtra(ColumnInterface $column): string { $extra = $column->getExtra(); @@ -155,10 +155,10 @@ protected function buildExtra(ColumnSchemaInterface $column): string /** * Builds the not null constraint for the column. * - * @return string A string 'NOT NULL' if {@see ColumnSchemaInterface::isNotNull()} is `true` + * @return string A string 'NOT NULL' if {@see ColumnInterface::isNotNull()} is `true` * or an empty string otherwise. */ - protected function buildNotNull(ColumnSchemaInterface $column): string + protected function buildNotNull(ColumnInterface $column): string { return match ($column->isNotNull()) { true => ' NOT NULL', @@ -172,7 +172,7 @@ protected function buildNotNull(ColumnSchemaInterface $column): string * * @return string A string containing the PRIMARY KEY keyword. */ - protected function buildPrimaryKey(ColumnSchemaInterface $column): string + protected function buildPrimaryKey(ColumnInterface $column): string { return $column->isPrimaryKey() ? ' PRIMARY KEY' : ''; } @@ -180,7 +180,7 @@ protected function buildPrimaryKey(ColumnSchemaInterface $column): string /** * Builds the references clause for the column. */ - protected function buildReferences(ColumnSchemaInterface $column): string + protected function buildReferences(ColumnInterface $column): string { $reference = $this->buildReferenceDefinition($column); @@ -194,7 +194,7 @@ protected function buildReferences(ColumnSchemaInterface $column): string /** * Builds the reference definition for the column. */ - protected function buildReferenceDefinition(ColumnSchemaInterface $column): string|null + protected function buildReferenceDefinition(ColumnInterface $column): string|null { $reference = $column->getReference(); $table = $reference?->getForeignTableName(); @@ -250,7 +250,7 @@ protected function buildOnUpdate(string $onUpdate): string * * @return string A string containing the column type definition. */ - protected function buildType(ColumnSchemaInterface $column): string + protected function buildType(ColumnInterface $column): string { $dbType = $this->getDbType($column); @@ -279,10 +279,10 @@ protected function buildType(ColumnSchemaInterface $column): string /** * Builds the unique constraint for the column. * - * @return string A string 'UNIQUE' if {@see ColumnSchemaInterface::isUnique()} is true + * @return string A string 'UNIQUE' if {@see ColumnInterface::isUnique()} is true * or an empty string otherwise. */ - protected function buildUnique(ColumnSchemaInterface $column): string + protected function buildUnique(ColumnInterface $column): string { if ($column->isPrimaryKey()) { return ''; @@ -296,7 +296,7 @@ protected function buildUnique(ColumnSchemaInterface $column): string * * @return string A string containing the UNSIGNED keyword. */ - protected function buildUnsigned(ColumnSchemaInterface $column): string + protected function buildUnsigned(ColumnInterface $column): string { return $column->isUnsigned() ? ' UNSIGNED' : ''; } diff --git a/src/QueryBuilder/AbstractDDLQueryBuilder.php b/src/QueryBuilder/AbstractDDLQueryBuilder.php index 4afd7f830..57892c681 100644 --- a/src/QueryBuilder/AbstractDDLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDDLQueryBuilder.php @@ -6,7 +6,7 @@ use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Query\QueryInterface; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Schema\QuoterInterface; use Yiisoft\Db\Schema\SchemaInterface; @@ -39,7 +39,7 @@ public function addCheck(string $table, string $name, string $expression): strin . ' CHECK (' . $this->quoter->quoteSql($expression) . ')'; } - public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): string + public function addColumn(string $table, string $column, ColumnInterface|string $type): string { return 'ALTER TABLE ' . $this->quoter->quoteTableName($table) @@ -133,7 +133,7 @@ public function addUnique(string $table, string $name, array|string $columns): s . ' UNIQUE (' . implode(', ', $columns) . ')'; } - public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): string + public function alterColumn(string $table, string $column, ColumnInterface|string $type): string { return 'ALTER TABLE ' . $this->quoter->quoteTableName($table) diff --git a/src/QueryBuilder/AbstractDMLQueryBuilder.php b/src/QueryBuilder/AbstractDMLQueryBuilder.php index 3b3905ec1..c28368ed4 100644 --- a/src/QueryBuilder/AbstractDMLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDMLQueryBuilder.php @@ -173,31 +173,31 @@ final protected function prepareTraversable(Traversable $rows): Iterator|array * * @param string $table The table name. * @param iterable $rows The rows to be batch inserted into the table. - * @param string[] $columns The column names. + * @param string[] $columnNames The column names. * @param array $params The binding parameters that will be generated by this method. * * @return string[] The values. * * @psalm-param ParamsType $params */ - protected function prepareBatchInsertValues(string $table, iterable $rows, array $columns, array &$params): array + protected function prepareBatchInsertValues(string $table, iterable $rows, array $columnNames, array &$params): array { $values = []; - /** @var string[] $columnNames */ - $columnNames = array_values($columns); - $columnKeys = array_fill_keys($columnNames, false); - $columnSchemas = $this->schema->getTableSchema($table)?->getColumns() ?? []; + /** @var string[] $names */ + $names = array_values($columnNames); + $keys = array_fill_keys($names, false); + $columns = $this->schema->getTableSchema($table)?->getColumns() ?? []; foreach ($rows as $row) { $i = 0; - $placeholders = $columnKeys; + $placeholders = $keys; /** @var int|string $key */ foreach ($row as $key => $value) { - $columnName = $columns[$key] ?? (isset($columnKeys[$key]) ? $key : $columnNames[$i] ?? $i); + $columnName = $columnNames[$key] ?? (isset($keys[$key]) ? $key : $names[$i] ?? $i); - if (isset($columnSchemas[$columnName])) { - $value = $columnSchemas[$columnName]->dbTypecast($value); + if (isset($columns[$columnName])) { + $value = $columns[$columnName]->dbTypecast($value); } if ($value instanceof ExpressionInterface) { @@ -309,6 +309,12 @@ protected function prepareInsertSelectSubQuery(QueryInterface $columns, array $p /** * Prepare column names and placeholders for `INSERT` SQL statement. * + * @param string $table The table to insert new rows into. + * @param array|QueryInterface $columns The column data (name => value) to insert into the table or instance of + * {@see Query} to perform `INSERT INTO ... SELECT` SQL statement. + * @param array $params The binding parameters that will be generated by this method. + * They should be bound to the DB command later. + * * @throws Exception * @throws InvalidConfigException * @throws InvalidArgumentException @@ -333,13 +339,13 @@ protected function prepareInsertValues(string $table, array|QueryInterface $colu $names = []; $placeholders = []; $columns = $this->normalizeColumnNames($columns); - $columnSchemas = $this->schema->getTableSchema($table)?->getColumns() ?? []; + $tableColumns = $this->schema->getTableSchema($table)?->getColumns() ?? []; foreach ($columns as $name => $value) { $names[] = $this->quoter->quoteColumnName($name); - if (isset($columnSchemas[$name])) { - $value = $columnSchemas[$name]->dbTypecast($value); + if (isset($tableColumns[$name])) { + $value = $tableColumns[$name]->dbTypecast($value); } if ($value instanceof ExpressionInterface) { @@ -367,11 +373,11 @@ protected function prepareUpdateSets(string $table, array $columns, array $param { $sets = []; $columns = $this->normalizeColumnNames($columns); - $columnSchemas = $this->schema->getTableSchema($table)?->getColumns() ?? []; + $tableColumns = $this->schema->getTableSchema($table)?->getColumns() ?? []; foreach ($columns as $name => $value) { - if (isset($columnSchemas[$name])) { - $value = $columnSchemas[$name]->dbTypecast($value); + if (isset($tableColumns[$name])) { + $value = $tableColumns[$name]->dbTypecast($value); } if ($value instanceof ExpressionInterface) { diff --git a/src/QueryBuilder/AbstractQueryBuilder.php b/src/QueryBuilder/AbstractQueryBuilder.php index 440b0d068..a8f2c54bb 100644 --- a/src/QueryBuilder/AbstractQueryBuilder.php +++ b/src/QueryBuilder/AbstractQueryBuilder.php @@ -15,7 +15,7 @@ use Yiisoft\Db\Expression\ExpressionInterface; use Yiisoft\Db\Query\QueryInterface; use Yiisoft\Db\QueryBuilder\Condition\Interface\ConditionInterface; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Schema\QuoterInterface; use Yiisoft\Db\Schema\SchemaInterface; @@ -78,7 +78,7 @@ public function addCheck(string $table, string $name, string $expression): strin return $this->ddlBuilder->addCheck($table, $name, $expression); } - public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): string + public function addColumn(string $table, string $column, ColumnInterface|string $type): string { return $this->ddlBuilder->addColumn($table, $column, $type); } @@ -128,7 +128,7 @@ public function addUnique(string $table, string $name, array|string $columns): s return $this->ddlBuilder->addUnique($table, $name, $columns); } - public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): string + public function alterColumn(string $table, string $column, ColumnInterface|string $type): string { return $this->ddlBuilder->alterColumn($table, $column, $type); } @@ -172,7 +172,7 @@ public function build(QueryInterface $query, array $params = []): array return $this->dqlBuilder->build($query, $params); } - public function buildColumnDefinition(ColumnSchemaInterface|string $column): string + public function buildColumnDefinition(ColumnInterface|string $column): string { if (is_string($column)) { $column = $this->schema->getColumnFactory()->fromDefinition($column); diff --git a/src/QueryBuilder/ColumnDefinitionBuilderInterface.php b/src/QueryBuilder/ColumnDefinitionBuilderInterface.php index b548051ba..3ee271cb9 100644 --- a/src/QueryBuilder/ColumnDefinitionBuilderInterface.php +++ b/src/QueryBuilder/ColumnDefinitionBuilderInterface.php @@ -4,21 +4,21 @@ namespace Yiisoft\Db\QueryBuilder; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; interface ColumnDefinitionBuilderInterface { /** * Builds column definition based on given column instance. * - * @param ColumnSchemaInterface $column the column instance which should be converted into a string representation. + * @param ColumnInterface $column the column instance which should be converted into a string representation. * * @return string the column SQL definition. */ - public function build(ColumnSchemaInterface $column): string; + public function build(ColumnInterface $column): string; /** * Builds column definition for `ALTER` operation based on given column instance. */ - public function buildAlter(ColumnSchemaInterface $column): string; + public function buildAlter(ColumnInterface $column): string; } diff --git a/src/QueryBuilder/DDLQueryBuilderInterface.php b/src/QueryBuilder/DDLQueryBuilderInterface.php index e3af883ed..00b474262 100644 --- a/src/QueryBuilder/DDLQueryBuilderInterface.php +++ b/src/QueryBuilder/DDLQueryBuilderInterface.php @@ -9,7 +9,7 @@ use Yiisoft\Db\Exception\InvalidConfigException; use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Query\QueryInterface; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; /** * Defines methods for building SQL statements for DDL (data definition language). @@ -36,22 +36,22 @@ public function addCheck(string $table, string $name, string $expression): strin * * @param string $table The table to add the new column will to. * @param string $column The name of the new column. - * @param ColumnSchemaInterface|string $type The column type which can contain a native database column type, + * @param ColumnInterface|string $type The column type which can contain a native database column type, * {@see ColumnType abstract} or {@see PseudoType pseudo} type, or can be represented as instance of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions * into SQL representation. For example, it will convert `string not null` to `varchar(255) not null` * and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL). * * The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * @return string The SQL statement for adding a new column. * * Note: The method will quote the `table` and `column` parameters before using them in the generated SQL. */ - public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): string; + public function addColumn(string $table, string $column, ColumnInterface|string $type): string; /** * Builds an SQL command for adding comment to column. @@ -164,22 +164,22 @@ public function addUnique(string $table, string $name, array|string $columns): s * * @param string $table The table whose column is to change. * @param string $column The name of the column to change. - * @param ColumnSchemaInterface|string $type The column type which can contain a native database column type, + * @param ColumnInterface|string $type The column type which can contain a native database column type, * {@see ColumnType abstract} or {@see PseudoType pseudo} type, or can be represented as instance of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions * into SQL representation. For example, it will convert `string not null` to `varchar(255) not null` * and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL). * * The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * @return string The SQL statement for changing the definition of a column. * * Note: The method will quote the `table` and `column` parameters before using them in the generated SQL. */ - public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): string; + public function alterColumn(string $table, string $column, ColumnInterface|string $type): string; /** * Builds an SQL statement for enabling or disabling integrity check. @@ -229,14 +229,14 @@ public function createIndex( * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name * is the name of the column which will be properly quoted by the method, and definition is the type of the column * which can contain a native database column type, {@see ColumnType abstract} or {@see PseudoType pseudo} type, - * or can be represented as instance of {@see ColumnSchemaInterface}. + * or can be represented as instance of {@see ColumnInterface}. * * The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions * into SQL representation. For example, it will convert `string not null` to `varchar(255) not null` * and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL). * * The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of - * {@see ColumnSchemaInterface}. + * {@see ColumnInterface}. * * ```php * $this->createTable( @@ -259,14 +259,14 @@ public function createIndex( * * @param string $table The name of the table to create. * @param array $columns The columns (name => definition) in the new table. - * The definition can be `string` or {@see ColumnSchemaInterface} instance. + * The definition can be `string` or {@see ColumnInterface} instance. * @param string|null $options More SQL fragments to append to the generated SQL. * * @return string The SQL statement for creating a new DB table. * * Note: The method will quote the `table` and `columns` parameter before using it in the generated SQL. * - * @psalm-param array|string[] $columns + * @psalm-param array|string[] $columns */ public function createTable(string $table, array $columns, string $options = null): string; diff --git a/src/QueryBuilder/QueryBuilderInterface.php b/src/QueryBuilder/QueryBuilderInterface.php index 9de77b6ac..c2b9f6014 100644 --- a/src/QueryBuilder/QueryBuilderInterface.php +++ b/src/QueryBuilder/QueryBuilderInterface.php @@ -10,7 +10,7 @@ use Yiisoft\Db\Exception\InvalidArgumentException; use Yiisoft\Db\Expression\ExpressionBuilderInterface; use Yiisoft\Db\Expression\ExpressionInterface; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Schema\QuoterInterface; /** @@ -41,12 +41,12 @@ public function bindParam(mixed $value, array &$params = []): string; /** * Builds column definition based on given column instance. * - * @param ColumnSchemaInterface|string $column the column instance or string column definition which should be + * @param ColumnInterface|string $column the column instance or string column definition which should be * converted into a database string representation. * * @return string the SQL column definition. */ - public function buildColumnDefinition(ColumnSchemaInterface|string $column): string; + public function buildColumnDefinition(ColumnInterface|string $column): string; /** * Returns the column definition builder for the current DBMS. diff --git a/src/Schema/AbstractTableSchema.php b/src/Schema/AbstractTableSchema.php index d4740f2a9..ad52b58fc 100644 --- a/src/Schema/AbstractTableSchema.php +++ b/src/Schema/AbstractTableSchema.php @@ -4,7 +4,7 @@ namespace Yiisoft\Db\Schema; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use function array_keys; @@ -20,7 +20,7 @@ abstract class AbstractTableSchema implements TableSchemaInterface private string|null $sequenceName = null; /** @psalm-var string[] */ private array $primaryKey = []; - /** @psalm-var array */ + /** @psalm-var array */ private array $columns = []; /** @psalm-var array */ protected array $foreignKeys = []; @@ -28,7 +28,7 @@ abstract class AbstractTableSchema implements TableSchemaInterface private string|null $catalogName = null; private string|null $serverName = null; - public function getColumn(string $name): ColumnSchemaInterface|null + public function getColumn(string $name): ColumnInterface|null { return $this->columns[$name] ?? null; } @@ -103,7 +103,7 @@ public function primaryKey(string $value): void $this->primaryKey[] = $value; } - public function column(string $name, ColumnSchemaInterface $value): void + public function column(string $name, ColumnInterface $value): void { $this->columns[$name] = $value; } diff --git a/src/Schema/Column/AbstractColumnSchema.php b/src/Schema/Column/AbstractColumn.php similarity index 96% rename from src/Schema/Column/AbstractColumnSchema.php rename to src/Schema/Column/AbstractColumn.php index 626063a36..c873ebd23 100644 --- a/src/Schema/Column/AbstractColumnSchema.php +++ b/src/Schema/Column/AbstractColumn.php @@ -16,17 +16,17 @@ * * It provides information about the column's type, size, scale, and other details. * - * The `ColumnSchema` class is used to store and retrieve metadata about a column in a database table. + * The `Column` class is used to store and retrieve metadata about a column in a database table. * * It's typically used in conjunction with the TableSchema class, which represents the metadata of a database table as a * whole. * - * Here is an example of how to use the `ColumnSchema` class: + * Here is an example of how to use the `Column` class: * * ```php - * use Yiisoft\Db\Schema\ColumnSchema; + * use Yiisoft\Db\Schema\IntegerColumn; * - * $column = (new IntegerColumnSchema()) + * $column = (new IntegerColumn()) * ->notNull() * ->dbType('int') * ->size(11) @@ -35,7 +35,7 @@ * ->primaryKey(); * ``` */ -abstract class AbstractColumnSchema implements ColumnSchemaInterface +abstract class AbstractColumn implements ColumnInterface { /** * @var string The default column abstract type diff --git a/src/Schema/Column/AbstractColumnFactory.php b/src/Schema/Column/AbstractColumnFactory.php index 05fa0b537..52bf661c5 100644 --- a/src/Schema/Column/AbstractColumnFactory.php +++ b/src/Schema/Column/AbstractColumnFactory.php @@ -33,7 +33,7 @@ abstract class AbstractColumnFactory implements ColumnFactoryInterface */ protected const TYPE_MAP = []; - public function fromDbType(string $dbType, array $info = []): ColumnSchemaInterface + public function fromDbType(string $dbType, array $info = []): ColumnInterface { $info['dbType'] = $dbType; $type = $info['type'] ?? $this->getType($dbType, $info); @@ -41,7 +41,7 @@ public function fromDbType(string $dbType, array $info = []): ColumnSchemaInterf return $this->fromType($type, $info); } - public function fromDefinition(string $definition, array $info = []): ColumnSchemaInterface + public function fromDefinition(string $definition, array $info = []): ColumnInterface { $definitionInfo = $this->columnDefinitionParser()->parse($definition); @@ -70,7 +70,7 @@ public function fromDefinition(string $definition, array $info = []): ColumnSche return $this->fromDbType($type, $info); } - public function fromPseudoType(string $pseudoType, array $info = []): ColumnSchemaInterface + public function fromPseudoType(string $pseudoType, array $info = []): ColumnInterface { $info['primaryKey'] = true; $info['autoIncrement'] = true; @@ -91,7 +91,7 @@ public function fromPseudoType(string $pseudoType, array $info = []): ColumnSche return $this->fromType($type, $info); } - public function fromType(string $type, array $info = []): ColumnSchemaInterface + public function fromType(string $type, array $info = []): ColumnInterface { unset($info['type']); @@ -126,29 +126,29 @@ protected function columnDefinitionParser(): ColumnDefinitionParser * @psalm-param ColumnType::* $type * @param ColumnInfo $info * - * @psalm-return class-string + * @psalm-return class-string */ protected function getColumnClass(string $type, array $info = []): string { return match ($type) { - ColumnType::BOOLEAN => BooleanColumnSchema::class, - ColumnType::BIT => BitColumnSchema::class, - ColumnType::TINYINT => IntegerColumnSchema::class, - ColumnType::SMALLINT => IntegerColumnSchema::class, + ColumnType::BOOLEAN => BooleanColumn::class, + ColumnType::BIT => BitColumn::class, + ColumnType::TINYINT => IntegerColumn::class, + ColumnType::SMALLINT => IntegerColumn::class, ColumnType::INTEGER => PHP_INT_SIZE !== 8 && !empty($info['unsigned']) - ? BigIntColumnSchema::class - : IntegerColumnSchema::class, + ? BigIntColumn::class + : IntegerColumn::class, ColumnType::BIGINT => PHP_INT_SIZE !== 8 || !empty($info['unsigned']) - ? BigIntColumnSchema::class - : IntegerColumnSchema::class, - ColumnType::DECIMAL => DoubleColumnSchema::class, - ColumnType::FLOAT => DoubleColumnSchema::class, - ColumnType::DOUBLE => DoubleColumnSchema::class, - ColumnType::BINARY => BinaryColumnSchema::class, - ColumnType::ARRAY => ArrayColumnSchema::class, - ColumnType::STRUCTURED => StructuredColumnSchema::class, - ColumnType::JSON => JsonColumnSchema::class, - default => StringColumnSchema::class, + ? BigIntColumn::class + : IntegerColumn::class, + ColumnType::DECIMAL => DoubleColumn::class, + ColumnType::FLOAT => DoubleColumn::class, + ColumnType::DOUBLE => DoubleColumn::class, + ColumnType::BINARY => BinaryColumn::class, + ColumnType::ARRAY => ArrayColumn::class, + ColumnType::STRUCTURED => StructuredColumn::class, + ColumnType::JSON => JsonColumn::class, + default => StringColumn::class, }; } @@ -229,15 +229,15 @@ protected function isType(string $type): bool } /** - * Converts column's default value according to {@see ColumnSchemaInterface::getPhpType()} after retrieval from the + * Converts column's default value according to {@see ColumnInterface::getPhpType()} after retrieval from the * database. * * @param string|null $defaultValue The default value retrieved from the database. - * @param ColumnSchemaInterface $column The column schema object. + * @param ColumnInterface $column The column object. * * @return mixed The normalized default value. */ - protected function normalizeDefaultValue(string|null $defaultValue, ColumnSchemaInterface $column): mixed + protected function normalizeDefaultValue(string|null $defaultValue, ColumnInterface $column): mixed { if ( $defaultValue === null @@ -253,9 +253,9 @@ protected function normalizeDefaultValue(string|null $defaultValue, ColumnSchema } /** - * Converts a not null default value according to {@see ColumnSchemaInterface::getPhpType()}. + * Converts a not null default value according to {@see ColumnInterface::getPhpType()}. */ - protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnSchemaInterface $column): mixed + protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInterface $column): mixed { $value = $defaultValue; diff --git a/src/Schema/Column/ArrayColumnSchema.php b/src/Schema/Column/ArrayColumn.php similarity index 91% rename from src/Schema/Column/ArrayColumnSchema.php rename to src/Schema/Column/ArrayColumn.php index 0d3e24149..6efb83e3c 100644 --- a/src/Schema/Column/ArrayColumnSchema.php +++ b/src/Schema/Column/ArrayColumn.php @@ -22,14 +22,14 @@ /** * Represents the schema for an array column. */ -class ArrayColumnSchema extends AbstractColumnSchema +class ArrayColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::ARRAY; /** - * @var ColumnSchemaInterface|null The column of an array item. + * @var ColumnInterface|null The column of an array item. */ - protected ColumnSchemaInterface|null $column = null; + protected ColumnInterface|null $column = null; /** * @var int The dimension of array, must be greater than 0. @@ -48,19 +48,19 @@ protected function getParser(): ParserToArrayInterface /** * Set column of an array item. */ - public function column(ColumnSchemaInterface|null $column): static + public function column(ColumnInterface|null $column): static { $this->column = $column; return $this; } /** - * @return ColumnSchemaInterface the column of an array item. + * @return ColumnInterface The column of an array item. */ - public function getColumn(): ColumnSchemaInterface + public function getColumn(): ColumnInterface { if ($this->column === null) { - $this->column = new StringColumnSchema(); + $this->column = new StringColumn(); $this->column->dbType($this->getDbType()); $this->column->enumValues($this->getEnumValues()); $this->column->scale($this->getScale()); diff --git a/src/Schema/Column/BigIntColumnSchema.php b/src/Schema/Column/BigIntColumn.php similarity index 96% rename from src/Schema/Column/BigIntColumnSchema.php rename to src/Schema/Column/BigIntColumn.php index b082f2f83..772d7a897 100644 --- a/src/Schema/Column/BigIntColumnSchema.php +++ b/src/Schema/Column/BigIntColumn.php @@ -17,7 +17,7 @@ /** * Represents the metadata for a bigint column. */ -class BigIntColumnSchema extends AbstractColumnSchema +class BigIntColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::BIGINT; diff --git a/src/Schema/Column/BinaryColumnSchema.php b/src/Schema/Column/BinaryColumn.php similarity index 94% rename from src/Schema/Column/BinaryColumnSchema.php rename to src/Schema/Column/BinaryColumn.php index b3fc33e9a..6bc1e4e8c 100644 --- a/src/Schema/Column/BinaryColumnSchema.php +++ b/src/Schema/Column/BinaryColumn.php @@ -15,7 +15,7 @@ /** * Represents the metadata for a binary column. */ -class BinaryColumnSchema extends AbstractColumnSchema +class BinaryColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::BINARY; diff --git a/src/Schema/Column/BitColumnSchema.php b/src/Schema/Column/BitColumn.php similarity index 94% rename from src/Schema/Column/BitColumnSchema.php rename to src/Schema/Column/BitColumn.php index 9979afbac..9c25c2dc7 100644 --- a/src/Schema/Column/BitColumnSchema.php +++ b/src/Schema/Column/BitColumn.php @@ -11,7 +11,7 @@ /** * Represents the metadata for a bit column. */ -class BitColumnSchema extends AbstractColumnSchema +class BitColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::BIT; diff --git a/src/Schema/Column/BooleanColumnSchema.php b/src/Schema/Column/BooleanColumn.php similarity index 94% rename from src/Schema/Column/BooleanColumnSchema.php rename to src/Schema/Column/BooleanColumn.php index c20e4484f..9e8658a19 100644 --- a/src/Schema/Column/BooleanColumnSchema.php +++ b/src/Schema/Column/BooleanColumn.php @@ -11,7 +11,7 @@ /** * Represents the metadata for a boolean column. */ -class BooleanColumnSchema extends AbstractColumnSchema +class BooleanColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::BOOLEAN; diff --git a/src/Schema/Column/ColumnBuilder.php b/src/Schema/Column/ColumnBuilder.php index 9602f673c..04c6cf973 100644 --- a/src/Schema/Column/ColumnBuilder.php +++ b/src/Schema/Column/ColumnBuilder.php @@ -7,7 +7,7 @@ use Yiisoft\Db\Constant\ColumnType; /** - * Column builder for database {@see ColumnSchemaInterface} instances. + * Column builder for database {@see ColumnInterface} instances. * * @psalm-import-type ColumnInfo from ColumnFactoryInterface */ @@ -17,7 +17,7 @@ class ColumnBuilder /** * Builds a column as an `integer` primary key. */ - public static function primaryKey(bool $autoIncrement = true): ColumnSchemaInterface + public static function primaryKey(bool $autoIncrement = true): ColumnInterface { return static::integer() ->primaryKey() @@ -27,7 +27,7 @@ public static function primaryKey(bool $autoIncrement = true): ColumnSchemaInter /** * Builds a column as a `smallint` primary key. */ - public static function smallPrimaryKey(bool $autoIncrement = true): ColumnSchemaInterface + public static function smallPrimaryKey(bool $autoIncrement = true): ColumnInterface { return static::smallint() ->primaryKey() @@ -37,7 +37,7 @@ public static function smallPrimaryKey(bool $autoIncrement = true): ColumnSchema /** * Builds a column as a `bigint` primary key. */ - public static function bigPrimaryKey(bool $autoIncrement = true): ColumnSchemaInterface + public static function bigPrimaryKey(bool $autoIncrement = true): ColumnInterface { return static::bigint() ->primaryKey() @@ -47,7 +47,7 @@ public static function bigPrimaryKey(bool $autoIncrement = true): ColumnSchemaIn /** * Builds a column as an `uuid` primary key. */ - public static function uuidPrimaryKey(bool $autoIncrement = true): ColumnSchemaInterface + public static function uuidPrimaryKey(bool $autoIncrement = true): ColumnInterface { return static::uuid() ->primaryKey() @@ -58,9 +58,9 @@ public static function uuidPrimaryKey(bool $autoIncrement = true): ColumnSchemaI /** * Builds a column with the abstract type `boolean`. */ - public static function boolean(): ColumnSchemaInterface + public static function boolean(): ColumnInterface { - return new BooleanColumnSchema(ColumnType::BOOLEAN); + return new BooleanColumn(ColumnType::BOOLEAN); } /** @@ -68,89 +68,89 @@ public static function boolean(): ColumnSchemaInterface * * @param int|null $size The number of bits that the column can store. */ - public static function bit(int|null $size = null): ColumnSchemaInterface + public static function bit(int|null $size = null): ColumnInterface { - return new BitColumnSchema(ColumnType::BIT, size: $size); + return new BitColumn(ColumnType::BIT, size: $size); } /** * Builds a column with the abstract type `tinyint`. */ - public static function tinyint(int|null $size = null): ColumnSchemaInterface + public static function tinyint(int|null $size = null): ColumnInterface { - return new IntegerColumnSchema(ColumnType::TINYINT, size: $size); + return new IntegerColumn(ColumnType::TINYINT, size: $size); } /** * Builds a column with the abstract type `smallint`. */ - public static function smallint(int|null $size = null): ColumnSchemaInterface + public static function smallint(int|null $size = null): ColumnInterface { - return new IntegerColumnSchema(ColumnType::SMALLINT, size: $size); + return new IntegerColumn(ColumnType::SMALLINT, size: $size); } /** * Builds a column with the abstract type `integer`. */ - public static function integer(int|null $size = null): ColumnSchemaInterface + public static function integer(int|null $size = null): ColumnInterface { - return new IntegerColumnSchema(ColumnType::INTEGER, size: $size); + return new IntegerColumn(ColumnType::INTEGER, size: $size); } /** * Builds a column with the abstract type `bigint`. */ - public static function bigint(int|null $size = null): ColumnSchemaInterface + public static function bigint(int|null $size = null): ColumnInterface { - return new IntegerColumnSchema(ColumnType::BIGINT, size: $size); + return new IntegerColumn(ColumnType::BIGINT, size: $size); } /** * Builds a column with the abstract type `float`. */ - public static function float(int|null $size = null, int|null $scale = null): ColumnSchemaInterface + public static function float(int|null $size = null, int|null $scale = null): ColumnInterface { - return new DoubleColumnSchema(ColumnType::FLOAT, scale: $scale, size: $size); + return new DoubleColumn(ColumnType::FLOAT, scale: $scale, size: $size); } /** * Builds a column with the abstract type `double`. */ - public static function double(int|null $size = null, int|null $scale = null): ColumnSchemaInterface + public static function double(int|null $size = null, int|null $scale = null): ColumnInterface { - return new DoubleColumnSchema(ColumnType::DOUBLE, scale: $scale, size: $size); + return new DoubleColumn(ColumnType::DOUBLE, scale: $scale, size: $size); } /** * Builds a column with the abstract type `decimal`. */ - public static function decimal(int|null $size = 10, int|null $scale = 0): ColumnSchemaInterface + public static function decimal(int|null $size = 10, int|null $scale = 0): ColumnInterface { - return new DoubleColumnSchema(ColumnType::DECIMAL, scale: $scale, size: $size); + return new DoubleColumn(ColumnType::DECIMAL, scale: $scale, size: $size); } /** * Builds a column with the abstract type `money`. */ - public static function money(int|null $size = 19, int|null $scale = 4): ColumnSchemaInterface + public static function money(int|null $size = 19, int|null $scale = 4): ColumnInterface { - return new DoubleColumnSchema(ColumnType::MONEY, scale: $scale, size: $size); + return new DoubleColumn(ColumnType::MONEY, scale: $scale, size: $size); } /** * Builds a column with the abstract type `char`. */ - public static function char(int|null $size = 1): ColumnSchemaInterface + public static function char(int|null $size = 1): ColumnInterface { - return new StringColumnSchema(ColumnType::CHAR, size: $size); + return new StringColumn(ColumnType::CHAR, size: $size); } /** * Builds a column with the abstract type `string`. */ - public static function string(int|null $size = 255): ColumnSchemaInterface + public static function string(int|null $size = 255): ColumnInterface { - return new StringColumnSchema(ColumnType::STRING, size: $size); + return new StringColumn(ColumnType::STRING, size: $size); } /** @@ -170,87 +170,87 @@ public static function string(int|null $size = 255): ColumnSchemaInterface * | MEDIUMTEXT | 16,777,215 | 5,592,405 | 4,194,303 * | LONGTEXT | 4,294,967,295 | 4,294,967,295 | 4,294,967,295 */ - public static function text(int|null $size = null): ColumnSchemaInterface + public static function text(int|null $size = null): ColumnInterface { - return new StringColumnSchema(ColumnType::TEXT, size: $size); + return new StringColumn(ColumnType::TEXT, size: $size); } /** * Builds a column with the abstract type `binary`. */ - public static function binary(int|null $size = null): ColumnSchemaInterface + public static function binary(int|null $size = null): ColumnInterface { - return new BinaryColumnSchema(ColumnType::BINARY, size: $size); + return new BinaryColumn(ColumnType::BINARY, size: $size); } /** * Builds a column with the abstract type `uuid`. */ - public static function uuid(): ColumnSchemaInterface + public static function uuid(): ColumnInterface { - return new StringColumnSchema(ColumnType::UUID); + return new StringColumn(ColumnType::UUID); } /** * Builds a column with the abstract type `datetime`. */ - public static function datetime(int|null $size = 0): ColumnSchemaInterface + public static function datetime(int|null $size = 0): ColumnInterface { - return new StringColumnSchema(ColumnType::DATETIME, size: $size); + return new StringColumn(ColumnType::DATETIME, size: $size); } /** * Builds a column with the abstract type `timestamp`. */ - public static function timestamp(int|null $size = 0): ColumnSchemaInterface + public static function timestamp(int|null $size = 0): ColumnInterface { - return new StringColumnSchema(ColumnType::TIMESTAMP, size: $size); + return new StringColumn(ColumnType::TIMESTAMP, size: $size); } /** * Builds a column with the abstract type `date`. */ - public static function date(): ColumnSchemaInterface + public static function date(): ColumnInterface { - return new StringColumnSchema(ColumnType::DATE); + return new StringColumn(ColumnType::DATE); } /** * Builds a column with the abstract type `time`. */ - public static function time(int|null $size = 0): ColumnSchemaInterface + public static function time(int|null $size = 0): ColumnInterface { - return new StringColumnSchema(ColumnType::TIME, size: $size); + return new StringColumn(ColumnType::TIME, size: $size); } /** * Builds a column with the abstract type `array`. * - * @param ColumnSchemaInterface|null $column The column schema of the array elements. + * @param ColumnInterface|null $column The instance of {@see ColumnInterface} of the array elements. */ - public static function array(ColumnSchemaInterface|null $column = null): ColumnSchemaInterface + public static function array(ColumnInterface|null $column = null): ColumnInterface { - return new ArrayColumnSchema(ColumnType::ARRAY, column: $column); + return new ArrayColumn(ColumnType::ARRAY, column: $column); } /** * Builds a column with the abstract type `structured`. * * @param string|null $dbType The DB type of the column. - * @param ColumnSchemaInterface[] $columns The columns (name -> instance) that the structured column should contain. + * @param ColumnInterface[] $columns The columns (name -> instance) that the structured column should contain. * - * @psalm-param array $columns + * @psalm-param array $columns */ - public static function structured(string|null $dbType = null, array $columns = []): ColumnSchemaInterface + public static function structured(string|null $dbType = null, array $columns = []): ColumnInterface { - return new StructuredColumnSchema(ColumnType::STRUCTURED, dbType: $dbType, columns: $columns); + return new StructuredColumn(ColumnType::STRUCTURED, dbType: $dbType, columns: $columns); } /** * Builds a column with the abstract type `json`. */ - public static function json(): ColumnSchemaInterface + public static function json(): ColumnInterface { - return new JsonColumnSchema(ColumnType::JSON); + return new JsonColumn(ColumnType::JSON); } } diff --git a/src/Schema/Column/ColumnFactoryInterface.php b/src/Schema/Column/ColumnFactoryInterface.php index 4a30ee5a3..69b3b67ab 100644 --- a/src/Schema/Column/ColumnFactoryInterface.php +++ b/src/Schema/Column/ColumnFactoryInterface.php @@ -9,14 +9,14 @@ use Yiisoft\Db\Constraint\ForeignKeyConstraint; /** - * The interface must be implemented by a column factory class. It should create a column schema for a database column - * type and initialize column information. + * The interface must be implemented by a column factory class. It should create an instance of {@see ColumnInterface} + * for a database column type and initialize column information. * * @psalm-type ColumnInfo = array{ * autoIncrement?: bool, * check?: string|null, - * column?: ColumnSchemaInterface|null, - * columns?: array, + * column?: ColumnInterface|null, + * columns?: array, * comment?: string|null, * computed?: bool, * dbType?: string|null, @@ -41,43 +41,42 @@ interface ColumnFactoryInterface { /** - * Creates a column schema for a database column type and initializes column information. + * Creates an instance of {@see ColumnInterface} for a database column type and initializes column information. * * @param string $dbType The database column type. * @param array $info The column information. The set of parameters may be different for a specific DBMS. * * @psalm-param ColumnInfo $info */ - public function fromDbType(string $dbType, array $info = []): ColumnSchemaInterface; + public function fromDbType(string $dbType, array $info = []): ColumnInterface; /** - * Creates a column schema for a database column definition and initializes column information. - * The definition string can contain the database type of the column, its size, default value, etc. + * Creates an instance of {@see ColumnInterface} for a database column definition and initializes column information. + * The definition string can contain a native database column type or {@see ColumnType abstract} type + * or {@see PseudoType pseudo} type, its size, default value, etc. * - * For example, `varchar(255) NOT NULL` is a database type with a size and a NOT NULL constraint. + * For example, `varchar(255) NOT NULL` is `varchar` database type with `255` size and a `NOT NULL` constraint. * * @param string $definition The database column definition. * @param array $info The column information. The set of parameters may be different for a specific DBMS. * * @psalm-param ColumnInfo $info */ - public function fromDefinition(string $definition, array $info = []): ColumnSchemaInterface; + public function fromDefinition(string $definition, array $info = []): ColumnInterface; /** - * Creates a column schema for a pseudo-type and initializes column information. + * Creates an instance of {@see ColumnInterface} for a pseudo-type and initializes column information. * * @param string $pseudoType The pseudo-type. * @param array $info The column information. The set of parameters may be different for a specific DBMS. * - * @return ColumnSchemaInterface The column schema. - * * @psalm-param PseudoType::* $pseudoType * @psalm-param ColumnInfo $info */ - public function fromPseudoType(string $pseudoType, array $info = []): ColumnSchemaInterface; + public function fromPseudoType(string $pseudoType, array $info = []): ColumnInterface; /** - * Creates a column schema for an abstract database type and initializes column information. + * Creates an instance of {@see ColumnInterface} for an abstract database type and initializes column information. * * @param string $type The abstract database type. * @param array $info The column information. The set of parameters may be different for a specific DBMS. @@ -85,5 +84,5 @@ public function fromPseudoType(string $pseudoType, array $info = []): ColumnSche * @psalm-param ColumnType::* $type * @psalm-param ColumnInfo $info */ - public function fromType(string $type, array $info = []): ColumnSchemaInterface; + public function fromType(string $type, array $info = []): ColumnInterface; } diff --git a/src/Schema/Column/ColumnSchemaInterface.php b/src/Schema/Column/ColumnInterface.php similarity index 99% rename from src/Schema/Column/ColumnSchemaInterface.php rename to src/Schema/Column/ColumnInterface.php index 22843e824..7bee7cd00 100644 --- a/src/Schema/Column/ColumnSchemaInterface.php +++ b/src/Schema/Column/ColumnInterface.php @@ -9,10 +9,9 @@ use Yiisoft\Db\Constraint\ForeignKeyConstraint; /** - * This interface defines a set of methods that must be implemented by a class that represents the column schema of a - * database table column. + * This interface defines a set of methods that must be implemented by a class that represents a database table column. */ -interface ColumnSchemaInterface +interface ColumnInterface { /** * Whether to allow `null` values. diff --git a/src/Schema/Column/DoubleColumnSchema.php b/src/Schema/Column/DoubleColumn.php similarity index 94% rename from src/Schema/Column/DoubleColumnSchema.php rename to src/Schema/Column/DoubleColumn.php index 932b5294a..479004e6f 100644 --- a/src/Schema/Column/DoubleColumnSchema.php +++ b/src/Schema/Column/DoubleColumn.php @@ -13,7 +13,7 @@ /** * Represents the metadata for a double column. */ -class DoubleColumnSchema extends AbstractColumnSchema +class DoubleColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::DOUBLE; diff --git a/src/Schema/Column/IntegerColumnSchema.php b/src/Schema/Column/IntegerColumn.php similarity index 94% rename from src/Schema/Column/IntegerColumnSchema.php rename to src/Schema/Column/IntegerColumn.php index e4710452a..3606d7689 100644 --- a/src/Schema/Column/IntegerColumnSchema.php +++ b/src/Schema/Column/IntegerColumn.php @@ -13,7 +13,7 @@ /** * Represents the schema for an integer column. */ -class IntegerColumnSchema extends AbstractColumnSchema +class IntegerColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::INTEGER; diff --git a/src/Schema/Column/JsonColumnSchema.php b/src/Schema/Column/JsonColumn.php similarity index 94% rename from src/Schema/Column/JsonColumnSchema.php rename to src/Schema/Column/JsonColumn.php index 9ddf626f3..b0ba21bc2 100644 --- a/src/Schema/Column/JsonColumnSchema.php +++ b/src/Schema/Column/JsonColumn.php @@ -14,7 +14,7 @@ /** * Represents the schema for a json column. */ -class JsonColumnSchema extends AbstractColumnSchema +class JsonColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::JSON; diff --git a/src/Schema/Column/StringColumnSchema.php b/src/Schema/Column/StringColumn.php similarity index 94% rename from src/Schema/Column/StringColumnSchema.php rename to src/Schema/Column/StringColumn.php index 855bc3bd0..bd491ab55 100644 --- a/src/Schema/Column/StringColumnSchema.php +++ b/src/Schema/Column/StringColumn.php @@ -14,7 +14,7 @@ /** * Represents the metadata for a string column. */ -class StringColumnSchema extends AbstractColumnSchema +class StringColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::STRING; diff --git a/src/Schema/Column/StructuredColumnSchema.php b/src/Schema/Column/StructuredColumn.php similarity index 86% rename from src/Schema/Column/StructuredColumnSchema.php rename to src/Schema/Column/StructuredColumn.php index be08a0b27..701088ce8 100644 --- a/src/Schema/Column/StructuredColumnSchema.php +++ b/src/Schema/Column/StructuredColumn.php @@ -18,13 +18,13 @@ /** * Represents the schema for a structured column. */ -class StructuredColumnSchema extends AbstractColumnSchema +class StructuredColumn extends AbstractColumn { protected const DEFAULT_TYPE = ColumnType::STRUCTURED; /** - * @var ColumnSchemaInterface[] Columns metadata of the structured type. - * @psalm-var array + * @var ColumnInterface[] Columns metadata of the structured type. + * @psalm-var array */ protected array $columns = []; @@ -39,8 +39,8 @@ protected function getParser(): ParserToArrayInterface /** * Set columns of the structured type. * - * @param ColumnSchemaInterface[] $columns The metadata of the structured type columns. - * @psalm-param array $columns + * @param ColumnInterface[] $columns The metadata of the structured type columns. + * @psalm-param array $columns */ public function columns(array $columns): static { @@ -51,7 +51,7 @@ public function columns(array $columns): static /** * Get the metadata of the structured type columns. * - * @return ColumnSchemaInterface[] + * @return ColumnInterface[] * @psalm-mutation-free */ public function getColumns(): array diff --git a/src/Schema/TableSchemaInterface.php b/src/Schema/TableSchemaInterface.php index 7b2431b5c..78aad57d7 100644 --- a/src/Schema/TableSchemaInterface.php +++ b/src/Schema/TableSchemaInterface.php @@ -4,7 +4,7 @@ namespace Yiisoft\Db\Schema; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; /** * Represents the metadata of a database table. @@ -22,9 +22,9 @@ interface TableSchemaInterface * * @param string $name The column name. * - * @return ColumnSchemaInterface|null The named column metadata. Null if the named column doesn't exist. + * @return ColumnInterface|null The named column metadata. Null if the named column doesn't exist. */ - public function getColumn(string $name): ColumnSchemaInterface|null; + public function getColumn(string $name): ColumnInterface|null; /** * @return array The names of all columns in this table. @@ -66,10 +66,10 @@ public function getSequenceName(): string|null; public function getPrimaryKey(): array; /** - * @return ColumnSchemaInterface[] The column metadata of this table. - * Array of {@see ColumnSchemaInterface} objects indexed by column names. + * @return ColumnInterface[] The column metadata of this table. + * Array of {@see ColumnInterface} objects indexed by column names. * - * @psalm-return array + * @psalm-return array */ public function getColumns(): array; @@ -125,7 +125,7 @@ public function primaryKey(string $value): void; * * @param string $name The column name. */ - public function column(string $name, ColumnSchemaInterface $value): void; + public function column(string $name, ColumnInterface $value): void; /** * @return string|null The name of the catalog (database) that this table belongs to. Defaults to null, meaning no diff --git a/tests/AbstractColumnFactoryTest.php b/tests/AbstractColumnFactoryTest.php index 53489c0ca..30d9922bf 100644 --- a/tests/AbstractColumnFactoryTest.php +++ b/tests/AbstractColumnFactoryTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\Attributes\DataProviderExternal; use PHPUnit\Framework\TestCase; use Yiisoft\Db\Constant\ColumnType; -use Yiisoft\Db\Schema\Column\StringColumnSchema; +use Yiisoft\Db\Schema\Column\StringColumn; use Yiisoft\Db\Tests\Provider\ColumnBuilderProvider; use Yiisoft\Db\Tests\Provider\ColumnFactoryProvider; use Yiisoft\Db\Tests\Support\TestTrait; @@ -106,7 +106,7 @@ public function testFromDefinitionWithExtra(): void $column = $columnFactory->fromDefinition('char(1) INVISIBLE', ['extra' => 'COLLATE utf8mb4']); - $this->assertInstanceOf(StringColumnSchema::class, $column); + $this->assertInstanceOf(StringColumn::class, $column); $this->assertSame('char', $column->getType()); $this->assertSame(1, $column->getSize()); $this->assertSame('INVISIBLE COLLATE utf8mb4', $column->getExtra()); diff --git a/tests/AbstractQueryBuilderTest.php b/tests/AbstractQueryBuilderTest.php index dd6004d24..49e1f940a 100644 --- a/tests/AbstractQueryBuilderTest.php +++ b/tests/AbstractQueryBuilderTest.php @@ -24,7 +24,7 @@ use Yiisoft\Db\QueryBuilder\Condition\ArrayOverlapsCondition; use Yiisoft\Db\QueryBuilder\Condition\JsonOverlapsCondition; use Yiisoft\Db\QueryBuilder\Condition\SimpleCondition; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Schema\QuoterInterface; use Yiisoft\Db\Tests\Provider\QueryBuilderProvider; use Yiisoft\Db\Tests\Support\Assert; @@ -57,7 +57,7 @@ public function testAddCheck(): void } /** @dataProvider \Yiisoft\Db\Tests\Provider\QueryBuilderProvider::columnTypes */ - public function testAddColumn(ColumnSchemaInterface|string $type): void + public function testAddColumn(ColumnInterface|string $type): void { $db = $this->getConnection(); @@ -190,7 +190,7 @@ public function testAddUnique(string $name, string $table, array|string $columns } #[DataProviderExternal(QueryBuilderProvider::class, 'alterColumn')] - public function testAlterColumn(string|ColumnSchemaInterface $type, string $expected): void + public function testAlterColumn(string|ColumnInterface $type, string $expected): void { $qb = $this->getConnection()->getQueryBuilder(); @@ -2364,7 +2364,7 @@ public function testOverrideParameters2(): void } #[DataProviderExternal(QueryBuilderProvider::class, 'buildColumnDefinition')] - public function testBuildColumnDefinition(string $expected, ColumnSchemaInterface|string $column): void + public function testBuildColumnDefinition(string $expected, ColumnInterface|string $column): void { $db = $this->getConnection(); $qb = $db->getQueryBuilder(); diff --git a/tests/AbstractTableSchemaTest.php b/tests/AbstractTableSchemaTest.php index 5a4fd3ba2..e7eb40dea 100644 --- a/tests/AbstractTableSchemaTest.php +++ b/tests/AbstractTableSchemaTest.php @@ -5,7 +5,7 @@ namespace Yiisoft\Db\Tests; use PHPUnit\Framework\TestCase; -use Yiisoft\Db\Tests\Support\Stub\ColumnSchema; +use Yiisoft\Db\Tests\Support\Stub\Column; use Yiisoft\Db\Tests\Support\Stub\TableSchema; use Yiisoft\Db\Tests\Support\TestTrait; @@ -37,45 +37,36 @@ public function testGetComment(): void public function testGetColumn(): void { - // Defined column schema. - $columnSchema = new ColumnSchema('id'); - - // Create table schema. + $column = new Column('id'); $tableSchema = new TableSchema(); $this->assertNull($tableSchema->getColumn('id')); - $tableSchema->column('id', $columnSchema); + $tableSchema->column('id', $column); - $this->assertSame($columnSchema, $tableSchema->getColumn('id')); + $this->assertSame($column, $tableSchema->getColumn('id')); } public function testGetColumns(): void { - // Defined column schema. - $columnSchema = new ColumnSchema('id'); - - // Create table schema. + $column = new Column('id'); $tableSchema = new TableSchema(); $this->assertSame([], $tableSchema->getColumns()); - $tableSchema->column('id', $columnSchema); + $tableSchema->column('id', $column); - $this->assertSame(['id' => $columnSchema], $tableSchema->getColumns()); + $this->assertSame(['id' => $column], $tableSchema->getColumns()); } public function testGetColumnName(): void { - // Defined column schema. - $columnSchema = new ColumnSchema('id'); - - // Create table schema. + $column = new Column('id'); $tableSchema = new TableSchema(); $this->assertNull($tableSchema->getColumn('id')); - $tableSchema->column('id', $columnSchema); + $tableSchema->column('id', $column); $this->assertSame(['id'], $tableSchema->getColumnNames()); } diff --git a/tests/Common/CommonColumnSchemaTest.php b/tests/Common/CommonColumnTest.php similarity index 77% rename from tests/Common/CommonColumnSchemaTest.php rename to tests/Common/CommonColumnTest.php index 274f1b66b..de655c634 100644 --- a/tests/Common/CommonColumnSchemaTest.php +++ b/tests/Common/CommonColumnTest.php @@ -8,9 +8,9 @@ use function is_object; -abstract class CommonColumnSchemaTest extends TestCase +abstract class CommonColumnTest extends TestCase { - /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnSchemaProvider::predefinedTypes */ + /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnProvider::predefinedTypes */ public function testPredefinedType(string $className, string $type, string $phpType) { $column = new $className(); @@ -19,7 +19,7 @@ public function testPredefinedType(string $className, string $type, string $phpT $this->assertSame($phpType, $column->getPhpType()); } - /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnSchemaProvider::dbTypecastColumns */ + /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnProvider::dbTypecastColumns */ public function testDbTypecastColumns(string $className, array $values) { $column = new $className(); @@ -33,7 +33,7 @@ public function testDbTypecastColumns(string $className, array $values) } } - /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnSchemaProvider::phpTypecastColumns */ + /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnProvider::phpTypecastColumns */ public function testPhpTypecastColumns(string $className, array $values) { $column = new $className(); diff --git a/tests/Common/CommonCommandTest.php b/tests/Common/CommonCommandTest.php index 988d64d16..6e1deef94 100644 --- a/tests/Common/CommonCommandTest.php +++ b/tests/Common/CommonCommandTest.php @@ -2032,8 +2032,8 @@ public function testDecimalValue(): void ['id' => $inserted['id']] )->queryOne(); - $columnSchema = $db->getTableSchema('{{%order}}')->getColumn('total'); - $phpTypecastValue = $columnSchema->phpTypecast($result['total']); + $column = $db->getTableSchema('{{%order}}')->getColumn('total'); + $phpTypecastValue = $column->phpTypecast($result['total']); $this->assertSame($decimalValue, $phpTypecastValue); } diff --git a/tests/Common/CommonQueryBuilderTest.php b/tests/Common/CommonQueryBuilderTest.php index 1d00d94a4..07baa72db 100644 --- a/tests/Common/CommonQueryBuilderTest.php +++ b/tests/Common/CommonQueryBuilderTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use Yiisoft\Db\Command\CommandInterface; use Yiisoft\Db\Exception\Exception; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Tests\AbstractQueryBuilderTest; use Yiisoft\Db\Tests\Provider\QueryBuilderProvider; @@ -34,7 +34,7 @@ public function testCreateTableWithBuildColumnDefinition(): void foreach ($provider as $data) { $column = $data[1]; - if ($column instanceof ColumnSchemaInterface) { + if ($column instanceof ColumnInterface) { if ($column->isPrimaryKey()) { $this->createTebleWithColumn($command, $column); continue; @@ -59,7 +59,7 @@ public function testCreateTableWithBuildColumnDefinition(): void $command->createTable('build_column_definition', $columns)->execute(); } - private function createTebleWithColumn(CommandInterface $command, string|ColumnSchemaInterface $column) + private function createTebleWithColumn(CommandInterface $command, string|ColumnInterface $column) { try { $command->dropTable('build_column_definition_primary_key')->execute(); diff --git a/tests/Common/CommonSchemaTest.php b/tests/Common/CommonSchemaTest.php index bbf5447da..ac58fed79 100644 --- a/tests/Common/CommonSchemaTest.php +++ b/tests/Common/CommonSchemaTest.php @@ -69,9 +69,9 @@ public function testColumnComment(): void /** * @dataProvider \Yiisoft\Db\Tests\Provider\SchemaProvider::columns */ - public function testColumnSchema(array $columns, string $tableName): void + public function testColumns(array $columns, string $tableName): void { - $this->columnSchema($columns, $tableName); + $this->assertTableColumns($columns, $tableName); } public function testCompositeFk(): void @@ -790,7 +790,7 @@ protected function assertMetadataEquals($expected, $actual): void $this->assertEquals($expected, $actual); } - protected function columnSchema(array $columns, string $table): void + protected function assertTableColumns(array $columns, string $table): void { $db = $this->getConnection(true); diff --git a/tests/Db/Command/CommandTest.php b/tests/Db/Command/CommandTest.php index 8ad8370ed..d5a3f1797 100644 --- a/tests/Db/Command/CommandTest.php +++ b/tests/Db/Command/CommandTest.php @@ -7,7 +7,7 @@ use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\Constant\PseudoType; use Yiisoft\Db\Exception\NotSupportedException; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Tests\AbstractCommandTest; use Yiisoft\Db\Tests\Support\Assert; use Yiisoft\Db\Tests\Support\DbHelper; @@ -42,7 +42,7 @@ public function testAddCheck(): void } /** @dataProvider \Yiisoft\Db\Tests\Provider\CommandProvider::columnTypes */ - public function testAddColumn(ColumnSchemaInterface|string $type): void + public function testAddColumn(ColumnInterface|string $type): void { $db = $this->getConnection(); diff --git a/tests/Db/QueryBuilder/ColumnDefinitionBuilderTest.php b/tests/Db/QueryBuilder/ColumnDefinitionBuilderTest.php index e240940ca..587ee4c00 100644 --- a/tests/Db/QueryBuilder/ColumnDefinitionBuilderTest.php +++ b/tests/Db/QueryBuilder/ColumnDefinitionBuilderTest.php @@ -8,7 +8,7 @@ use Yiisoft\Db\Exception\Exception; use Yiisoft\Db\QueryBuilder\AbstractColumnDefinitionBuilder; use Yiisoft\Db\Schema\Column\ColumnBuilder; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Tests\Support\Stub\ColumnDefinitionBuilder; use Yiisoft\Db\Tests\Support\TestTrait; @@ -40,7 +40,7 @@ public function testBuildEmptyDefaultForUuid(): void $qb = $db->getQueryBuilder(); $cdb = new class ($qb) extends AbstractColumnDefinitionBuilder { - protected function getDbType(ColumnSchemaInterface $column): string + protected function getDbType(ColumnInterface $column): string { return 'uuid'; } diff --git a/tests/Db/Schema/ColumnSchemaTest.php b/tests/Db/Schema/Column/ColumnTest.php similarity index 83% rename from tests/Db/Schema/ColumnSchemaTest.php rename to tests/Db/Schema/Column/ColumnTest.php index 591f1bc8c..4c89c73eb 100644 --- a/tests/Db/Schema/ColumnSchemaTest.php +++ b/tests/Db/Schema/Column/ColumnTest.php @@ -11,24 +11,24 @@ use Yiisoft\Db\Expression\ArrayExpression; use Yiisoft\Db\Expression\Expression; use Yiisoft\Db\Expression\StructuredExpression; -use Yiisoft\Db\Schema\Column\ArrayColumnSchema; +use Yiisoft\Db\Schema\Column\ArrayColumn; use Yiisoft\Db\Schema\Column\ColumnBuilder; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; -use Yiisoft\Db\Schema\Column\IntegerColumnSchema; -use Yiisoft\Db\Schema\Column\StringColumnSchema; -use Yiisoft\Db\Schema\Column\StructuredColumnSchema; -use Yiisoft\Db\Tests\Support\Stub\ColumnSchema; +use Yiisoft\Db\Schema\Column\ColumnInterface; +use Yiisoft\Db\Schema\Column\IntegerColumn; +use Yiisoft\Db\Schema\Column\StringColumn; +use Yiisoft\Db\Schema\Column\StructuredColumn; +use Yiisoft\Db\Tests\Support\Stub\Column; /** * @group db * * @psalm-suppress PropertyNotSetInConstructor */ -final class ColumnSchemaTest extends TestCase +final class ColumnTest extends TestCase { public function testAllowNull(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertTrue($column->isAllowNull()); $this->assertSame($column, $column->allowNull()); @@ -45,7 +45,7 @@ public function testAllowNull(): void public function testAutoIncrement(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertFalse($column->isAutoIncrement()); $this->assertSame($column, $column->autoIncrement()); @@ -62,7 +62,7 @@ public function testAutoIncrement(): void public function testCheck(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getCheck()); $this->assertSame($column, $column->check('age > 0')); @@ -75,7 +75,7 @@ public function testCheck(): void public function testComment(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getComment()); $this->assertSame($column, $column->comment('test')); @@ -88,7 +88,7 @@ public function testComment(): void public function testComputed(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertFalse($column->isComputed()); $this->assertSame($column, $column->computed()); @@ -105,7 +105,7 @@ public function testComputed(): void public function testDbType(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getDbType()); $this->assertSame($column, $column->dbType('test')); @@ -118,7 +118,7 @@ public function testDbType(): void public function testDefaultValue(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertFalse($column->hasDefaultValue()); $this->assertNull($column->getDefaultValue()); @@ -134,7 +134,7 @@ public function testDefaultValue(): void public function testEnumValues(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getEnumValues()); $this->assertSame($column, $column->enumValues(['positive', 'negative'])); @@ -147,7 +147,7 @@ public function testEnumValues(): void public function testExtra(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getExtra()); $this->assertSame($column, $column->extra('test')); @@ -158,17 +158,17 @@ public function testExtra(): void $this->assertSame('', $column->getExtra()); } - /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnSchemaProvider::construct */ + /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnProvider::construct */ public function testConstruct(string $parameter, mixed $value, string $method, mixed $expected): void { - $column = new ColumnSchema(...[$parameter => $value]); + $column = new Column(...[$parameter => $value]); $this->assertSame($expected, $column->$method()); } public function testName(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getName()); $this->assertSame($column, $column->name('test')); @@ -181,7 +181,7 @@ public function testName(): void public function testNotNull(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->isNotNull()); $this->assertSame($column, $column->notNull()); @@ -202,7 +202,7 @@ public function testNotNull(): void public function testPrecision(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getPrecision()); $this->assertSame($column, $column->precision(10)); @@ -215,7 +215,7 @@ public function testPrecision(): void public function testPrimaryKey(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertFalse($column->isPrimaryKey()); $this->assertSame($column, $column->primaryKey()); @@ -232,7 +232,7 @@ public function testPrimaryKey(): void public function testReference(): void { - $column = new ColumnSchema(); + $column = new Column(); $fk = new ForeignKeyConstraint(); $this->assertNull($column->getReference()); @@ -246,7 +246,7 @@ public function testReference(): void public function testScale(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getScale()); $this->assertSame($column, $column->scale(10)); @@ -259,7 +259,7 @@ public function testScale(): void public function testSize(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertNull($column->getSize()); $this->assertSame($column, $column->size(10)); @@ -272,7 +272,7 @@ public function testSize(): void public function testType(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertSame('', $column->getType()); $this->assertSame($column, $column->type('test')); @@ -285,7 +285,7 @@ public function testType(): void public function testUnique(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertFalse($column->isUnique()); $this->assertSame($column, $column->unique()); @@ -302,7 +302,7 @@ public function testUnique(): void public function testUnsigned(): void { - $column = new ColumnSchema(); + $column = new Column(); $this->assertFalse($column->isUnsigned()); $this->assertSame($column, $column->unsigned()); @@ -319,21 +319,21 @@ public function testUnsigned(): void public function testArrayColumnGetColumn(): void { - $arrayCol = new ArrayColumnSchema(); - $intCol = new IntegerColumnSchema(); + $arrayCol = new ArrayColumn(); + $intCol = new IntegerColumn(); - $this->assertInstanceOf(StringColumnSchema::class, $arrayCol->getColumn()); + $this->assertInstanceOf(StringColumn::class, $arrayCol->getColumn()); $this->assertSame($arrayCol, $arrayCol->column($intCol)); $this->assertSame($intCol, $arrayCol->getColumn()); $arrayCol->column(null); - $this->assertInstanceOf(StringColumnSchema::class, $arrayCol->getColumn()); + $this->assertInstanceOf(StringColumn::class, $arrayCol->getColumn()); } public function testArrayColumnGetDimension(): void { - $arrayCol = new ArrayColumnSchema(); + $arrayCol = new ArrayColumn(); $this->assertSame(1, $arrayCol->getDimension()); @@ -341,8 +341,8 @@ public function testArrayColumnGetDimension(): void $this->assertSame(2, $arrayCol->getDimension()); } - /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnSchemaProvider::dbTypecastArrayColumns */ - public function testArrayColumnDbTypecast(ColumnSchemaInterface $column, array $values): void + /** @dataProvider \Yiisoft\Db\Tests\Provider\ColumnProvider::dbTypecastArrayColumns */ + public function testArrayColumnDbTypecast(ColumnInterface $column, array $values): void { $arrayCol = ColumnBuilder::array($column); @@ -359,7 +359,7 @@ public function testArrayColumnDbTypecast(ColumnSchemaInterface $column, array $ public function testArrayColumnDbTypecastSimple() { - $arrayCol = new ArrayColumnSchema(); + $arrayCol = new ArrayColumn(); $this->assertNull($arrayCol->dbTypecast(null)); $this->assertEquals(new ArrayExpression([]), $arrayCol->dbTypecast('')); @@ -369,7 +369,7 @@ public function testArrayColumnDbTypecastSimple() public function testArrayColumnPhpTypecast() { - $arrayCol = new ArrayColumnSchema(); + $arrayCol = new ArrayColumn(); $this->assertNull($arrayCol->phpTypecast(null)); $this->assertNull($arrayCol->phpTypecast(1)); @@ -378,7 +378,7 @@ public function testArrayColumnPhpTypecast() $this->expectException(NotSupportedException::class); $this->expectExceptionMessage( - 'Yiisoft\Db\Schema\Column\ArrayColumnSchema::getParser() is not supported. Use concrete DBMS implementation.' + 'Yiisoft\Db\Schema\Column\ArrayColumn::getParser() is not supported. Use concrete DBMS implementation.' ); $arrayCol->phpTypecast('{1,2,3}'); @@ -386,7 +386,7 @@ public function testArrayColumnPhpTypecast() public function testStructuredColumnGetColumns(): void { - $structuredCol = new StructuredColumnSchema(); + $structuredCol = new StructuredColumn(); $columns = [ 'value' => ColumnBuilder::money(), 'currency_code' => ColumnBuilder::char(3), @@ -399,7 +399,7 @@ public function testStructuredColumnGetColumns(): void public function testStructuredColumnDbTypecast(): void { - $structuredCol = new StructuredColumnSchema(); + $structuredCol = new StructuredColumn(); $expression = new Expression('expression'); $structuredExpression = new StructuredExpression(['value' => 1, 'currency_code' => 'USD']); @@ -411,7 +411,7 @@ public function testStructuredColumnDbTypecast(): void public function testStructuredColumnPhpTypecast(): void { - $structuredCol = new StructuredColumnSchema(); + $structuredCol = new StructuredColumn(); $columns = [ 'int' => ColumnBuilder::integer(), 'bool' => ColumnBuilder::boolean(), @@ -432,7 +432,7 @@ public function testStructuredColumnPhpTypecast(): void $this->expectException(NotSupportedException::class); $this->expectExceptionMessage( - 'Yiisoft\Db\Schema\Column\StructuredColumnSchema::getParser() is not supported. Use concrete DBMS implementation.' + 'Yiisoft\Db\Schema\Column\StructuredColumn::getParser() is not supported. Use concrete DBMS implementation.' ); $structuredCol->phpTypecast('(1,true)'); diff --git a/tests/Provider/ColumnBuilderProvider.php b/tests/Provider/ColumnBuilderProvider.php index ea783d70c..fd5054f0a 100644 --- a/tests/Provider/ColumnBuilderProvider.php +++ b/tests/Provider/ColumnBuilderProvider.php @@ -5,16 +5,16 @@ namespace Yiisoft\Db\Tests\Provider; use Yiisoft\Db\Constant\ColumnType; -use Yiisoft\Db\Schema\Column\ArrayColumnSchema; -use Yiisoft\Db\Schema\Column\BinaryColumnSchema; -use Yiisoft\Db\Schema\Column\BitColumnSchema; -use Yiisoft\Db\Schema\Column\BooleanColumnSchema; +use Yiisoft\Db\Schema\Column\ArrayColumn; +use Yiisoft\Db\Schema\Column\BinaryColumn; +use Yiisoft\Db\Schema\Column\BitColumn; +use Yiisoft\Db\Schema\Column\BooleanColumn; use Yiisoft\Db\Schema\Column\ColumnBuilder; -use Yiisoft\Db\Schema\Column\DoubleColumnSchema; -use Yiisoft\Db\Schema\Column\IntegerColumnSchema; -use Yiisoft\Db\Schema\Column\JsonColumnSchema; -use Yiisoft\Db\Schema\Column\StringColumnSchema; -use Yiisoft\Db\Schema\Column\StructuredColumnSchema; +use Yiisoft\Db\Schema\Column\DoubleColumn; +use Yiisoft\Db\Schema\Column\IntegerColumn; +use Yiisoft\Db\Schema\Column\JsonColumn; +use Yiisoft\Db\Schema\Column\StringColumn; +use Yiisoft\Db\Schema\Column\StructuredColumn; class ColumnBuilderProvider { @@ -40,71 +40,71 @@ public static function buildingMethods(): array return [ // building method, args, expected instance of, expected type, expected column method results - 'primaryKey()' => ['primaryKey', [], IntegerColumnSchema::class, ColumnType::INTEGER, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], - 'primaryKey(false)' => ['primaryKey', [false], IntegerColumnSchema::class, ColumnType::INTEGER, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], - 'smallPrimaryKey()' => ['smallPrimaryKey', [], IntegerColumnSchema::class, ColumnType::SMALLINT, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], - 'smallPrimaryKey(false)' => ['smallPrimaryKey', [false], IntegerColumnSchema::class, ColumnType::SMALLINT, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], - 'bigPrimaryKey()' => ['bigPrimaryKey', [], IntegerColumnSchema::class, ColumnType::BIGINT, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], - 'bigPrimaryKey(false)' => ['bigPrimaryKey', [false], IntegerColumnSchema::class, ColumnType::BIGINT, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], - 'uuidPrimaryKey()' => ['uuidPrimaryKey', [], StringColumnSchema::class, ColumnType::UUID, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], - 'uuidPrimaryKey(false)' => ['uuidPrimaryKey', [false], StringColumnSchema::class, ColumnType::UUID, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], - 'boolean()' => ['boolean', [], BooleanColumnSchema::class, ColumnType::BOOLEAN], - 'bit()' => ['bit', [], BitColumnSchema::class, ColumnType::BIT], - 'bit(1)' => ['bit', [1], BitColumnSchema::class, ColumnType::BIT, ['getSize' => 1]], - 'tinyint()' => ['tinyint', [], IntegerColumnSchema::class, ColumnType::TINYINT], - 'tinyint(1)' => ['tinyint', [1], IntegerColumnSchema::class, ColumnType::TINYINT, ['getSize' => 1]], - 'smallint()' => ['smallint', [], IntegerColumnSchema::class, ColumnType::SMALLINT], - 'smallint(1)' => ['smallint', [1], IntegerColumnSchema::class, ColumnType::SMALLINT, ['getSize' => 1]], - 'integer()' => ['integer', [], IntegerColumnSchema::class, ColumnType::INTEGER], - 'integer(1)' => ['integer', [1], IntegerColumnSchema::class, ColumnType::INTEGER, ['getSize' => 1]], - 'bigint()' => ['bigint', [], IntegerColumnSchema::class, ColumnType::BIGINT], - 'bigint(1)' => ['bigint', [1], IntegerColumnSchema::class, ColumnType::BIGINT, ['getSize' => 1]], - 'float()' => ['float', [], DoubleColumnSchema::class, ColumnType::FLOAT], - 'float(8)' => ['float', [8], DoubleColumnSchema::class, ColumnType::FLOAT, ['getSize' => 8]], - 'float(8,2)' => ['float', [8, 2], DoubleColumnSchema::class, ColumnType::FLOAT, ['getSize' => 8, 'getScale' => 2]], - 'double()' => ['double', [], DoubleColumnSchema::class, ColumnType::DOUBLE], - 'double(8)' => ['double', [8], DoubleColumnSchema::class, ColumnType::DOUBLE, ['getSize' => 8]], - 'double(8,2)' => ['double', [8, 2], DoubleColumnSchema::class, ColumnType::DOUBLE, ['getSize' => 8, 'getScale' => 2]], - 'decimal()' => ['decimal', [], DoubleColumnSchema::class, ColumnType::DECIMAL, ['getSize' => 10, 'getScale' => 0]], - 'decimal(8)' => ['decimal', [8], DoubleColumnSchema::class, ColumnType::DECIMAL, ['getSize' => 8, 'getScale' => 0]], - 'decimal(8,2)' => ['decimal', [8, 2], DoubleColumnSchema::class, ColumnType::DECIMAL, ['getSize' => 8, 'getScale' => 2]], - 'money()' => ['money', [], DoubleColumnSchema::class, ColumnType::MONEY, ['getSize' => 19, 'getScale' => 4]], - 'money(8)' => ['money', [8], DoubleColumnSchema::class, ColumnType::MONEY, ['getSize' => 8, 'getScale' => 4]], - 'money(8,2)' => ['money', [8, 2], DoubleColumnSchema::class, ColumnType::MONEY, ['getSize' => 8, 'getScale' => 2]], - 'char()' => ['char', [], StringColumnSchema::class, ColumnType::CHAR, ['getSize' => 1]], - 'char(100)' => ['char', [100], StringColumnSchema::class, ColumnType::CHAR, ['getSize' => 100]], - 'string()' => ['string', [], StringColumnSchema::class, ColumnType::STRING, ['getSize' => 255]], - 'string(100)' => ['string', [100], StringColumnSchema::class, ColumnType::STRING, ['getSize' => 100]], - 'text()' => ['text', [], StringColumnSchema::class, ColumnType::TEXT], - 'text(5000)' => ['text', [5000], StringColumnSchema::class, ColumnType::TEXT, ['getSize' => 5000]], - 'binary()' => ['binary', [], BinaryColumnSchema::class, ColumnType::BINARY], - 'binary(8)' => ['binary', [8], BinaryColumnSchema::class, ColumnType::BINARY, ['getSize' => 8]], - 'uuid()' => ['uuid', [], StringColumnSchema::class, ColumnType::UUID], - 'datetime()' => ['datetime', [], StringColumnSchema::class, ColumnType::DATETIME, ['getSize' => 0]], - 'datetime(3)' => ['datetime', [3], StringColumnSchema::class, ColumnType::DATETIME, ['getSize' => 3]], - 'timestamp()' => ['timestamp', [], StringColumnSchema::class, ColumnType::TIMESTAMP, ['getSize' => 0]], - 'timestamp(3)' => ['timestamp', [3], StringColumnSchema::class, ColumnType::TIMESTAMP, ['getSize' => 3]], - 'date()' => ['date', [], StringColumnSchema::class, ColumnType::DATE], - 'time()' => ['time', [], StringColumnSchema::class, ColumnType::TIME, ['getSize' => 0]], - 'time(3)' => ['time', [3], StringColumnSchema::class, ColumnType::TIME, ['getSize' => 3]], - 'array()' => ['array', [], ArrayColumnSchema::class, ColumnType::ARRAY], - 'array($column)' => ['array', [$column], ArrayColumnSchema::class, ColumnType::ARRAY, ['getColumn' => $column]], - 'structured()' => ['structured', [], StructuredColumnSchema::class, ColumnType::STRUCTURED], + 'primaryKey()' => ['primaryKey', [], IntegerColumn::class, ColumnType::INTEGER, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'primaryKey(false)' => ['primaryKey', [false], IntegerColumn::class, ColumnType::INTEGER, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], + 'smallPrimaryKey()' => ['smallPrimaryKey', [], IntegerColumn::class, ColumnType::SMALLINT, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'smallPrimaryKey(false)' => ['smallPrimaryKey', [false], IntegerColumn::class, ColumnType::SMALLINT, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], + 'bigPrimaryKey()' => ['bigPrimaryKey', [], IntegerColumn::class, ColumnType::BIGINT, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'bigPrimaryKey(false)' => ['bigPrimaryKey', [false], IntegerColumn::class, ColumnType::BIGINT, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], + 'uuidPrimaryKey()' => ['uuidPrimaryKey', [], StringColumn::class, ColumnType::UUID, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'uuidPrimaryKey(false)' => ['uuidPrimaryKey', [false], StringColumn::class, ColumnType::UUID, ['isPrimaryKey' => true, 'isAutoIncrement' => false]], + 'boolean()' => ['boolean', [], BooleanColumn::class, ColumnType::BOOLEAN], + 'bit()' => ['bit', [], BitColumn::class, ColumnType::BIT], + 'bit(1)' => ['bit', [1], BitColumn::class, ColumnType::BIT, ['getSize' => 1]], + 'tinyint()' => ['tinyint', [], IntegerColumn::class, ColumnType::TINYINT], + 'tinyint(1)' => ['tinyint', [1], IntegerColumn::class, ColumnType::TINYINT, ['getSize' => 1]], + 'smallint()' => ['smallint', [], IntegerColumn::class, ColumnType::SMALLINT], + 'smallint(1)' => ['smallint', [1], IntegerColumn::class, ColumnType::SMALLINT, ['getSize' => 1]], + 'integer()' => ['integer', [], IntegerColumn::class, ColumnType::INTEGER], + 'integer(1)' => ['integer', [1], IntegerColumn::class, ColumnType::INTEGER, ['getSize' => 1]], + 'bigint()' => ['bigint', [], IntegerColumn::class, ColumnType::BIGINT], + 'bigint(1)' => ['bigint', [1], IntegerColumn::class, ColumnType::BIGINT, ['getSize' => 1]], + 'float()' => ['float', [], DoubleColumn::class, ColumnType::FLOAT], + 'float(8)' => ['float', [8], DoubleColumn::class, ColumnType::FLOAT, ['getSize' => 8]], + 'float(8,2)' => ['float', [8, 2], DoubleColumn::class, ColumnType::FLOAT, ['getSize' => 8, 'getScale' => 2]], + 'double()' => ['double', [], DoubleColumn::class, ColumnType::DOUBLE], + 'double(8)' => ['double', [8], DoubleColumn::class, ColumnType::DOUBLE, ['getSize' => 8]], + 'double(8,2)' => ['double', [8, 2], DoubleColumn::class, ColumnType::DOUBLE, ['getSize' => 8, 'getScale' => 2]], + 'decimal()' => ['decimal', [], DoubleColumn::class, ColumnType::DECIMAL, ['getSize' => 10, 'getScale' => 0]], + 'decimal(8)' => ['decimal', [8], DoubleColumn::class, ColumnType::DECIMAL, ['getSize' => 8, 'getScale' => 0]], + 'decimal(8,2)' => ['decimal', [8, 2], DoubleColumn::class, ColumnType::DECIMAL, ['getSize' => 8, 'getScale' => 2]], + 'money()' => ['money', [], DoubleColumn::class, ColumnType::MONEY, ['getSize' => 19, 'getScale' => 4]], + 'money(8)' => ['money', [8], DoubleColumn::class, ColumnType::MONEY, ['getSize' => 8, 'getScale' => 4]], + 'money(8,2)' => ['money', [8, 2], DoubleColumn::class, ColumnType::MONEY, ['getSize' => 8, 'getScale' => 2]], + 'char()' => ['char', [], StringColumn::class, ColumnType::CHAR, ['getSize' => 1]], + 'char(100)' => ['char', [100], StringColumn::class, ColumnType::CHAR, ['getSize' => 100]], + 'string()' => ['string', [], StringColumn::class, ColumnType::STRING, ['getSize' => 255]], + 'string(100)' => ['string', [100], StringColumn::class, ColumnType::STRING, ['getSize' => 100]], + 'text()' => ['text', [], StringColumn::class, ColumnType::TEXT], + 'text(5000)' => ['text', [5000], StringColumn::class, ColumnType::TEXT, ['getSize' => 5000]], + 'binary()' => ['binary', [], BinaryColumn::class, ColumnType::BINARY], + 'binary(8)' => ['binary', [8], BinaryColumn::class, ColumnType::BINARY, ['getSize' => 8]], + 'uuid()' => ['uuid', [], StringColumn::class, ColumnType::UUID], + 'datetime()' => ['datetime', [], StringColumn::class, ColumnType::DATETIME, ['getSize' => 0]], + 'datetime(3)' => ['datetime', [3], StringColumn::class, ColumnType::DATETIME, ['getSize' => 3]], + 'timestamp()' => ['timestamp', [], StringColumn::class, ColumnType::TIMESTAMP, ['getSize' => 0]], + 'timestamp(3)' => ['timestamp', [3], StringColumn::class, ColumnType::TIMESTAMP, ['getSize' => 3]], + 'date()' => ['date', [], StringColumn::class, ColumnType::DATE], + 'time()' => ['time', [], StringColumn::class, ColumnType::TIME, ['getSize' => 0]], + 'time(3)' => ['time', [3], StringColumn::class, ColumnType::TIME, ['getSize' => 3]], + 'array()' => ['array', [], ArrayColumn::class, ColumnType::ARRAY], + 'array($column)' => ['array', [$column], ArrayColumn::class, ColumnType::ARRAY, ['getColumn' => $column]], + 'structured()' => ['structured', [], StructuredColumn::class, ColumnType::STRUCTURED], "structured('money_currency')" => [ 'structured', ['money_currency'], - StructuredColumnSchema::class, + StructuredColumn::class, ColumnType::STRUCTURED, ['getDbType' => 'money_currency'], ], "structured('money_currency',\$columns)" => [ 'structured', ['money_currency', $columns], - StructuredColumnSchema::class, + StructuredColumn::class, ColumnType::STRUCTURED, ['getDbType' => 'money_currency', 'getColumns' => $columns], ], - 'json()' => ['json', [], JsonColumnSchema::class, ColumnType::JSON], + 'json()' => ['json', [], JsonColumn::class, ColumnType::JSON], ]; } } diff --git a/tests/Provider/ColumnFactoryProvider.php b/tests/Provider/ColumnFactoryProvider.php index 71bc2f18d..23e064e8a 100644 --- a/tests/Provider/ColumnFactoryProvider.php +++ b/tests/Provider/ColumnFactoryProvider.php @@ -7,14 +7,14 @@ use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\Constant\PseudoType; use Yiisoft\Db\Expression\Expression; -use Yiisoft\Db\Schema\Column\BigIntColumnSchema; -use Yiisoft\Db\Schema\Column\BinaryColumnSchema; -use Yiisoft\Db\Schema\Column\BooleanColumnSchema; -use Yiisoft\Db\Schema\Column\DoubleColumnSchema; -use Yiisoft\Db\Schema\Column\IntegerColumnSchema; -use Yiisoft\Db\Schema\Column\JsonColumnSchema; -use Yiisoft\Db\Schema\Column\StringColumnSchema; -use Yiisoft\Db\Schema\Column\StructuredColumnSchema; +use Yiisoft\Db\Schema\Column\BigIntColumn; +use Yiisoft\Db\Schema\Column\BinaryColumn; +use Yiisoft\Db\Schema\Column\BooleanColumn; +use Yiisoft\Db\Schema\Column\DoubleColumn; +use Yiisoft\Db\Schema\Column\IntegerColumn; +use Yiisoft\Db\Schema\Column\JsonColumn; +use Yiisoft\Db\Schema\Column\StringColumn; +use Yiisoft\Db\Schema\Column\StructuredColumn; class ColumnFactoryProvider { @@ -22,12 +22,12 @@ public static function definitions(): array { return [ // definition, expected type, expected instance of, expected column method results - '' => ['', ColumnType::STRING, StringColumnSchema::class, ['getDbType' => '']], - 'text' => ['text', ColumnType::TEXT, StringColumnSchema::class, ['getDbType' => 'text']], - 'text NOT NULL' => ['text NOT NULL', ColumnType::TEXT, StringColumnSchema::class, ['getDbType' => 'text', 'isNotNull' => true]], - 'char(1)' => ['char(1)', ColumnType::CHAR, StringColumnSchema::class, ['getDbType' => 'char', 'getSize' => 1]], - 'decimal(10,2)' => ['decimal(10,2)', ColumnType::DECIMAL, DoubleColumnSchema::class, ['getDbType' => 'decimal', 'getSize' => 10, 'getScale' => 2]], - 'bigint UNSIGNED' => ['bigint UNSIGNED', ColumnType::BIGINT, BigIntColumnSchema::class, ['getDbType' => 'bigint', 'isUnsigned' => true]], + '' => ['', ColumnType::STRING, StringColumn::class, ['getDbType' => '']], + 'text' => ['text', ColumnType::TEXT, StringColumn::class, ['getDbType' => 'text']], + 'text NOT NULL' => ['text NOT NULL', ColumnType::TEXT, StringColumn::class, ['getDbType' => 'text', 'isNotNull' => true]], + 'char(1)' => ['char(1)', ColumnType::CHAR, StringColumn::class, ['getDbType' => 'char', 'getSize' => 1]], + 'decimal(10,2)' => ['decimal(10,2)', ColumnType::DECIMAL, DoubleColumn::class, ['getDbType' => 'decimal', 'getSize' => 10, 'getScale' => 2]], + 'bigint UNSIGNED' => ['bigint UNSIGNED', ColumnType::BIGINT, BigIntColumn::class, ['getDbType' => 'bigint', 'isUnsigned' => true]], ]; } @@ -35,12 +35,12 @@ public static function pseudoTypes(): array { return [ // pseudo-type, expected type, expected instance of, expected column method results - 'pk' => [PseudoType::PK, ColumnType::INTEGER, IntegerColumnSchema::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], - 'upk' => [PseudoType::UPK, ColumnType::INTEGER, IntegerColumnSchema::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true, 'isUnsigned' => true]], - 'bigpk' => [PseudoType::BIGPK, ColumnType::BIGINT, IntegerColumnSchema::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], - 'ubigpk' => [PseudoType::UBIGPK, ColumnType::BIGINT, BigIntColumnSchema::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true, 'isUnsigned' => true]], - 'uuid_pk' => [PseudoType::UUID_PK, ColumnType::UUID, StringColumnSchema::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], - 'uuid_pk_seq' => [PseudoType::UUID_PK_SEQ, ColumnType::UUID, StringColumnSchema::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'pk' => [PseudoType::PK, ColumnType::INTEGER, IntegerColumn::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'upk' => [PseudoType::UPK, ColumnType::INTEGER, IntegerColumn::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true, 'isUnsigned' => true]], + 'bigpk' => [PseudoType::BIGPK, ColumnType::BIGINT, IntegerColumn::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'ubigpk' => [PseudoType::UBIGPK, ColumnType::BIGINT, BigIntColumn::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true, 'isUnsigned' => true]], + 'uuid_pk' => [PseudoType::UUID_PK, ColumnType::UUID, StringColumn::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], + 'uuid_pk_seq' => [PseudoType::UUID_PK_SEQ, ColumnType::UUID, StringColumn::class, ['isPrimaryKey' => true, 'isAutoIncrement' => true]], ]; } @@ -48,26 +48,26 @@ public static function types(): array { return [ // type, expected type, expected instance of - 'uuid' => [ColumnType::UUID, ColumnType::UUID, StringColumnSchema::class], - 'char' => [ColumnType::CHAR, ColumnType::CHAR, StringColumnSchema::class], - 'string' => [ColumnType::STRING, ColumnType::STRING, StringColumnSchema::class], - 'text' => [ColumnType::TEXT, ColumnType::TEXT, StringColumnSchema::class], - 'binary' => [ColumnType::BINARY, ColumnType::BINARY, BinaryColumnSchema::class], - 'boolean' => [ColumnType::BOOLEAN, ColumnType::BOOLEAN, BooleanColumnSchema::class], - 'tinyint' => [ColumnType::TINYINT, ColumnType::TINYINT, IntegerColumnSchema::class], - 'smallint' => [ColumnType::SMALLINT, ColumnType::SMALLINT, IntegerColumnSchema::class], - 'integer' => [ColumnType::INTEGER, ColumnType::INTEGER, IntegerColumnSchema::class], - 'bigint' => [ColumnType::BIGINT, ColumnType::BIGINT, IntegerColumnSchema::class], - 'float' => [ColumnType::FLOAT, ColumnType::FLOAT, DoubleColumnSchema::class], - 'double' => [ColumnType::DOUBLE, ColumnType::DOUBLE, DoubleColumnSchema::class], - 'decimal' => [ColumnType::DECIMAL, ColumnType::DECIMAL, DoubleColumnSchema::class], - 'money' => [ColumnType::MONEY, ColumnType::MONEY, StringColumnSchema::class], - 'datetime' => [ColumnType::DATETIME, ColumnType::DATETIME, StringColumnSchema::class], - 'timestamp' => [ColumnType::TIMESTAMP, ColumnType::TIMESTAMP, StringColumnSchema::class], - 'time' => [ColumnType::TIME, ColumnType::TIME, StringColumnSchema::class], - 'date' => [ColumnType::DATE, ColumnType::DATE, StringColumnSchema::class], - 'structured' => [ColumnType::STRUCTURED, ColumnType::STRUCTURED, StructuredColumnSchema::class], - 'json' => [ColumnType::JSON, ColumnType::JSON, JsonColumnSchema::class], + 'uuid' => [ColumnType::UUID, ColumnType::UUID, StringColumn::class], + 'char' => [ColumnType::CHAR, ColumnType::CHAR, StringColumn::class], + 'string' => [ColumnType::STRING, ColumnType::STRING, StringColumn::class], + 'text' => [ColumnType::TEXT, ColumnType::TEXT, StringColumn::class], + 'binary' => [ColumnType::BINARY, ColumnType::BINARY, BinaryColumn::class], + 'boolean' => [ColumnType::BOOLEAN, ColumnType::BOOLEAN, BooleanColumn::class], + 'tinyint' => [ColumnType::TINYINT, ColumnType::TINYINT, IntegerColumn::class], + 'smallint' => [ColumnType::SMALLINT, ColumnType::SMALLINT, IntegerColumn::class], + 'integer' => [ColumnType::INTEGER, ColumnType::INTEGER, IntegerColumn::class], + 'bigint' => [ColumnType::BIGINT, ColumnType::BIGINT, IntegerColumn::class], + 'float' => [ColumnType::FLOAT, ColumnType::FLOAT, DoubleColumn::class], + 'double' => [ColumnType::DOUBLE, ColumnType::DOUBLE, DoubleColumn::class], + 'decimal' => [ColumnType::DECIMAL, ColumnType::DECIMAL, DoubleColumn::class], + 'money' => [ColumnType::MONEY, ColumnType::MONEY, StringColumn::class], + 'datetime' => [ColumnType::DATETIME, ColumnType::DATETIME, StringColumn::class], + 'timestamp' => [ColumnType::TIMESTAMP, ColumnType::TIMESTAMP, StringColumn::class], + 'time' => [ColumnType::TIME, ColumnType::TIME, StringColumn::class], + 'date' => [ColumnType::DATE, ColumnType::DATE, StringColumn::class], + 'structured' => [ColumnType::STRUCTURED, ColumnType::STRUCTURED, StructuredColumn::class], + 'json' => [ColumnType::JSON, ColumnType::JSON, JsonColumn::class], ]; } diff --git a/tests/Provider/ColumnSchemaProvider.php b/tests/Provider/ColumnProvider.php similarity index 86% rename from tests/Provider/ColumnSchemaProvider.php rename to tests/Provider/ColumnProvider.php index 806f03457..00e1b38d4 100644 --- a/tests/Provider/ColumnSchemaProvider.php +++ b/tests/Provider/ColumnProvider.php @@ -13,36 +13,36 @@ use Yiisoft\Db\Expression\JsonExpression; use Yiisoft\Db\Constant\PhpType; use Yiisoft\Db\Expression\StructuredExpression; -use Yiisoft\Db\Schema\Column\ArrayColumnSchema; -use Yiisoft\Db\Schema\Column\BigIntColumnSchema; -use Yiisoft\Db\Schema\Column\BinaryColumnSchema; -use Yiisoft\Db\Schema\Column\BitColumnSchema; -use Yiisoft\Db\Schema\Column\BooleanColumnSchema; +use Yiisoft\Db\Schema\Column\ArrayColumn; +use Yiisoft\Db\Schema\Column\BigIntColumn; +use Yiisoft\Db\Schema\Column\BinaryColumn; +use Yiisoft\Db\Schema\Column\BitColumn; +use Yiisoft\Db\Schema\Column\BooleanColumn; use Yiisoft\Db\Schema\Column\ColumnBuilder; -use Yiisoft\Db\Schema\Column\DoubleColumnSchema; -use Yiisoft\Db\Schema\Column\IntegerColumnSchema; -use Yiisoft\Db\Schema\Column\JsonColumnSchema; -use Yiisoft\Db\Schema\Column\StringColumnSchema; -use Yiisoft\Db\Schema\Column\StructuredColumnSchema; +use Yiisoft\Db\Schema\Column\DoubleColumn; +use Yiisoft\Db\Schema\Column\IntegerColumn; +use Yiisoft\Db\Schema\Column\JsonColumn; +use Yiisoft\Db\Schema\Column\StringColumn; +use Yiisoft\Db\Schema\Column\StructuredColumn; use function fopen; -class ColumnSchemaProvider +class ColumnProvider { public static function predefinedTypes(): array { return [ // [class, type, phpType] - 'integer' => [IntegerColumnSchema::class, ColumnType::INTEGER, PhpType::INT], - 'bigint' => [BigIntColumnSchema::class, ColumnType::BIGINT, PhpType::STRING], - 'double' => [DoubleColumnSchema::class, ColumnType::DOUBLE, PhpType::FLOAT], - 'string' => [StringColumnSchema::class, ColumnType::STRING, PhpType::STRING], - 'binary' => [BinaryColumnSchema::class, ColumnType::BINARY, PhpType::MIXED], - 'bit' => [BitColumnSchema::class, ColumnType::BIT, PhpType::INT], - 'boolean' => [BooleanColumnSchema::class, ColumnType::BOOLEAN, PhpType::BOOL], - 'array' => [ArrayColumnSchema::class, ColumnType::ARRAY, PhpType::ARRAY], - 'structured' => [StructuredColumnSchema::class, ColumnType::STRUCTURED, PhpType::ARRAY], - 'json' => [JsonColumnSchema::class, ColumnType::JSON, PhpType::MIXED], + 'integer' => [IntegerColumn::class, ColumnType::INTEGER, PhpType::INT], + 'bigint' => [BigIntColumn::class, ColumnType::BIGINT, PhpType::STRING], + 'double' => [DoubleColumn::class, ColumnType::DOUBLE, PhpType::FLOAT], + 'string' => [StringColumn::class, ColumnType::STRING, PhpType::STRING], + 'binary' => [BinaryColumn::class, ColumnType::BINARY, PhpType::MIXED], + 'bit' => [BitColumn::class, ColumnType::BIT, PhpType::INT], + 'boolean' => [BooleanColumn::class, ColumnType::BOOLEAN, PhpType::BOOL], + 'array' => [ArrayColumn::class, ColumnType::ARRAY, PhpType::ARRAY], + 'structured' => [StructuredColumn::class, ColumnType::STRUCTURED, PhpType::ARRAY], + 'json' => [JsonColumn::class, ColumnType::JSON, PhpType::MIXED], ]; } @@ -50,7 +50,7 @@ public static function dbTypecastColumns(): array { return [ 'integer' => [ - IntegerColumnSchema::class, + IntegerColumn::class, [ // [expected, typecast value] [null, null], @@ -64,7 +64,7 @@ public static function dbTypecastColumns(): array ], ], 'bigint' => [ - BigIntColumnSchema::class, + BigIntColumn::class, [ [null, null], [null, ''], @@ -78,7 +78,7 @@ public static function dbTypecastColumns(): array ], ], 'double' => [ - DoubleColumnSchema::class, + DoubleColumn::class, [ [null, null], [null, ''], @@ -91,7 +91,7 @@ public static function dbTypecastColumns(): array ], ], 'string' => [ - StringColumnSchema::class, + StringColumn::class, [ [null, null], ['', ''], @@ -104,7 +104,7 @@ public static function dbTypecastColumns(): array ], ], 'binary' => [ - BinaryColumnSchema::class, + BinaryColumn::class, [ [null, null], ['1', 1], @@ -116,7 +116,7 @@ public static function dbTypecastColumns(): array ], ], 'bit' => [ - BitColumnSchema::class, + BitColumn::class, [ [null, null], [null, ''], @@ -131,7 +131,7 @@ public static function dbTypecastColumns(): array ], ], 'boolean' => [ - BooleanColumnSchema::class, + BooleanColumn::class, [ [null, null], [null, ''], @@ -147,7 +147,7 @@ public static function dbTypecastColumns(): array ], ], 'json' => [ - JsonColumnSchema::class, + JsonColumn::class, [ [null, null], [new JsonExpression(''), ''], @@ -169,7 +169,7 @@ public static function phpTypecastColumns(): array { return [ 'integer' => [ - IntegerColumnSchema::class, + IntegerColumn::class, [ // [expected, typecast value] [null, null], @@ -178,7 +178,7 @@ public static function phpTypecastColumns(): array ], ], 'bigint' => [ - BigIntColumnSchema::class, + BigIntColumn::class, [ [null, null], ['1', 1], @@ -187,7 +187,7 @@ public static function phpTypecastColumns(): array ], ], 'double' => [ - DoubleColumnSchema::class, + DoubleColumn::class, [ [null, null], [1.0, 1.0], @@ -195,7 +195,7 @@ public static function phpTypecastColumns(): array ], ], 'string' => [ - StringColumnSchema::class, + StringColumn::class, [ [null, null], ['', ''], @@ -203,7 +203,7 @@ public static function phpTypecastColumns(): array ], ], 'binary' => [ - BinaryColumnSchema::class, + BinaryColumn::class, [ [null, null], ['', ''], @@ -212,7 +212,7 @@ public static function phpTypecastColumns(): array ], ], 'bit' => [ - BitColumnSchema::class, + BitColumn::class, [ [null, null], [1, 1], @@ -222,7 +222,7 @@ public static function phpTypecastColumns(): array ], ], 'boolean' => [ - BooleanColumnSchema::class, + BooleanColumn::class, [ [null, null], [true, true], @@ -233,7 +233,7 @@ public static function phpTypecastColumns(): array ], ], 'json' => [ - JsonColumnSchema::class, + JsonColumn::class, [ [null, null], [null, 'null'], @@ -279,7 +279,7 @@ public static function dbTypecastArrayColumns() ], ], ColumnType::BIGINT => [ - new BigIntColumnSchema(), + new BigIntColumn(), [ [1, ['1', '2', '3', '9223372036854775807'], [1, 2.0, '3', '9223372036854775807']], [2, [['1', '2'], ['3'], ['9223372036854775807']], [[1, 2.0], ['3'], ['9223372036854775807']]], diff --git a/tests/Support/Stub/ColumnSchema.php b/tests/Support/Stub/Column.php similarity index 73% rename from tests/Support/Stub/ColumnSchema.php rename to tests/Support/Stub/Column.php index 2d5ab86ee..75314bc21 100644 --- a/tests/Support/Stub/ColumnSchema.php +++ b/tests/Support/Stub/Column.php @@ -4,9 +4,9 @@ namespace Yiisoft\Db\Tests\Support\Stub; -use Yiisoft\Db\Schema\Column\AbstractColumnSchema; +use Yiisoft\Db\Schema\Column\AbstractColumn; -final class ColumnSchema extends AbstractColumnSchema +final class Column extends AbstractColumn { protected const DEFAULT_TYPE = ''; diff --git a/tests/Support/Stub/ColumnDefinitionBuilder.php b/tests/Support/Stub/ColumnDefinitionBuilder.php index bb79f985c..7cbe3c53d 100644 --- a/tests/Support/Stub/ColumnDefinitionBuilder.php +++ b/tests/Support/Stub/ColumnDefinitionBuilder.php @@ -6,7 +6,7 @@ use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\QueryBuilder\AbstractColumnDefinitionBuilder; -use Yiisoft\Db\Schema\Column\ColumnSchemaInterface; +use Yiisoft\Db\Schema\Column\ColumnInterface; final class ColumnDefinitionBuilder extends AbstractColumnDefinitionBuilder { @@ -36,7 +36,7 @@ final class ColumnDefinitionBuilder extends AbstractColumnDefinitionBuilder 'decimal', ]; - protected function getDbType(ColumnSchemaInterface $column): string + protected function getDbType(ColumnInterface $column): string { return $column->getDbType() ?? match ($column->getType()) { ColumnType::BOOLEAN => 'boolean',