Skip to content

Commit

Permalink
Fix method alterCOlumn(), argument type accept `ColumnInterface::cl…
Browse files Browse the repository at this point in the history
…ass`.
  • Loading branch information
terabytesoftw committed Aug 14, 2023
1 parent c5aa0b1 commit 1eb17e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Yiisoft\Db\Query\Data\DataReaderInterface;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\Builder\ColumnInterface;

use function explode;
use function get_resource_type;
Expand Down Expand Up @@ -188,7 +189,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, string $type): static
public function alterColumn(string $table, string $column, string|ColumnInterface $type): static
{
$sql = $this->getQueryBuilder()->alterColumn($table, $column, $type);
return $this->setSql($sql)->requireTableSchemaRefresh($table);
Expand Down
9 changes: 5 additions & 4 deletions src/Command/CommandInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Query\Data\DataReaderInterface;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\Schema\Builder\ColumnInterface;

/**
* This interface represents a database command, such as a `SELECT`, `INSERT`, `UPDATE`, or `DELETE` statement.
Expand Down Expand Up @@ -138,13 +139,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 string $type The column type. {@see QueryBuilder::getColumnType()} 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`.
* @param string|ColumnInterface $type The column type. {@see QueryBuilder::getColumnType()} 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, string $type): static;
public function alterColumn(string $table, string $column, string|ColumnInterface $type): static;

/**
* Creates a batch INSERT command.
Expand Down

0 comments on commit 1eb17e5

Please sign in to comment.