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`. (#741)
  • Loading branch information
terabytesoftw authored Aug 15, 2023
1 parent c5aa0b1 commit b047dae
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/active-record.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
name: PHP ${{ matrix.php }}-active-record-${{ matrix.os }}

env:
COMPOSER_ROOT_VERSION: 1.0.0
COMPOSER_ROOT_VERSION: 1.1.0
EXTENSIONS: pdo, pdo_mysql, pdo_oci, pdo_pgsql, pdo_sqlite, pdo_sqlsrv-5.10.1

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2']
['8.1', '8.2']
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.1.1 under development

- Bug #741: Fix `alterColumn()` method to accept `ColumnInterface::class` in argument `$type` (@terabytesoftw)
- New #617: Add debug collector for `yiisoft/yii-debug` (@xepozz)
- Enh #617, #733: Add specific psalm annotation of `$closure` parameter in `ConnectionInterface::transaction()`
method (@xepozz, @vjik)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"rector/rector": "^0.17",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.12.0",
"vimeo/psalm": "^4.30|^5.12",
"yiisoft/aliases": "^3.0",
"yiisoft/cache-file": "^2.0",
"yiisoft/di": "^1.0",
Expand Down
38 changes: 1 addition & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,9 @@
</include>
<exclude>
<directory>./src/TestSupport</directory>
<directory>./src/Debug</directory>
<directory>./tests</directory>
<directory>./vendor</directory>
<file>./src/Command/CommandInterface.php</file>
<file>./src/Command/ParamInterface.php</file>
<file>./src/Connection/ConnectionInterface.php</file>
<file>./src/Connection/ConnectionPoolInterface.php</file>
<file>./src/Constraint/ConstraintSchemaInterface.php</file>
<file>./src/Driver/DriverInterface.php</file>
<file>./src/Driver/PDO/CommandPDOInterface.php</file>
<file>./src/Driver/PDO/ConnectionPDOInterface.php</file>
<file>./src/Driver/PDO/ConnectionPDOPoolInterface.php</file>
<file>./src/Driver/PDO/PDODriverInterface.php</file>
<file>./src/Expression/ExpressionBuilderInterface.php</file>
<file>./src/Expression/ExpressionInterface.php</file>
<file>./src/Profiler/ProfilerInterface.php</file>
<file>./src/Query/BatchQueryResultInterface.php</file>
<file>./src/Query/Data/DataReaderInterface.php</file>
<file>./src/Query/QueryFunctionsInterface.php</file>
<file>./src/Query/QueryInterface.php</file>
<file>./src/Query/QueryPartsInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/BetweenColumnsConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/BetweenConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/ConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/ConjunctionConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/ExistConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/HashConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/InConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/LikeConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/NotConditionInterface.php</file>
<file>./src/QueryBuilder/Condition/Interface/SimpleConditionInterface.php</file>
<file>./src/QueryBuilder/DDLQueryBuilderInterface.php</file>
<file>./src/QueryBuilder/DMLQueryBuilderInterface.php</file>
<file>./src/QueryBuilder/DQLQueryBuilderInterface.php</file>
<file>./src/QueryBuilder/QueryBuilderInterface.php</file>
<file>./src/Schema/ColumnSchemaInterface.php</file>
<file>./src/Schema/QuoterInterface.php</file>
<file>./src/Schema/SchemaInterface.php</file>
<file>./src/Schema/TableSchemaInterface.php</file>
<file>./src/Transaction/TransactionInterface.php</file>
</exclude>
</source>
<php>
Expand Down
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, ColumnInterface|string $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 ColumnInterface|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`.
*
* 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, ColumnInterface|string $type): static;

/**
* Creates a batch INSERT command.
Expand Down
3 changes: 2 additions & 1 deletion src/Debug/CommandInterfaceProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yiisoft\Db\Command\CommandInterface;
use Yiisoft\Db\Query\Data\DataReaderInterface;
use Yiisoft\Db\Query\QueryInterface;
use Yiisoft\Db\Schema\Builder\ColumnInterface;

final class CommandInterfaceProxy implements CommandInterface
{
Expand Down Expand Up @@ -92,7 +93,7 @@ public function addUnique(string $table, string $name, array|string $columns): s
/**
* @psalm-suppress MixedArgument
*/
public function alterColumn(string $table, string $column, 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);
}
Expand Down

0 comments on commit b047dae

Please sign in to comment.