Skip to content

Commit 98eed39

Browse files
authored
Rename ColumnSchemaInterface to ColumnInterface (#917)
1 parent f9976c4 commit 98eed39

47 files changed

Lines changed: 463 additions & 464 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- New #906: Add `ServerInfoInterface` and its implementation (@Tigrov)
5353
- Enh #905: Use `AbstractColumnDefinitionBuilder` to generate table column SQL representation (@Tigrov)
5454
- Enh #915: Remove `ColumnInterface` (@Tigrov)
55+
- Enh #917: Rename `ColumnSchemaInterface` to `ColumnInterface` (@Tigrov)
5556

5657
## 1.3.0 March 21, 2024
5758

UPGRADE.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ application when you upgrade the package from one version to another.
1111

1212
### Remove `ColumnInterface`
1313

14-
Remove `ColumnInterface` and use `ColumnSchemaInterface` instead.
14+
- Remove `ColumnInterface` and use `ColumnSchemaInterface` instead;
15+
- Rename `ColumnSchemaInterface` to `ColumnInterface`.
1516

16-
### `ColumnSchemaInterface` as column type
17+
### `ColumnInterface` as column type
1718

18-
Add `ColumnSchemaInterface` support and change type of parameter `$type` to `ColumnSchemaInterface|string`
19+
Add `ColumnInterface` support and change type of parameter `$type` to `ColumnInterface|string`
1920
in the following methods:
2021
- `addColumn()`
2122
- `alterColumn()`
@@ -67,7 +68,9 @@ $db->createCommand()->insertBatch('user', $values)->execute();
6768

6869
### `ColumnSchemaInterface` changes
6970

70-
The interface and the abstract implementation `AbstractColumnSchema` were moved to `Yiisoft\Db\Schema\Column` namespace
71+
Rename `ColumnSchemaInterface` to `ColumnInterface`.
72+
73+
The interface and the abstract implementation `AbstractColumn` were moved to `Yiisoft\Db\Schema\Column` namespace
7174
and the following changes were made:
7275

7376
- `getName()` method can return `string` or `null`;
@@ -83,8 +86,8 @@ and the following changes were made:
8386
- `unique(bool $unique = true)` method is added;
8487
- `isUnique()` method is added;
8588
- `hasDefaultValue()` method is added;
86-
- all `AbstractColumnSchema` class properties except `$type` moved to constructor;
87-
- added `DEFAULT_TYPE` constant to `AbstractColumnSchema` class;
89+
- all `AbstractColumn` class properties except `$type` moved to constructor;
90+
- added `DEFAULT_TYPE` constant to `AbstractColumn` class;
8891
- added method chaining.
8992

9093
### New classes with constants
@@ -98,16 +101,16 @@ and the following changes were made:
98101

99102
Each table column has its own class in the `Yiisoft\Db\Schema\Column` namespace according to the data type:
100103

101-
- `BooleanColumnSchema` for columns with boolean type;
102-
- `BitColumnSchema` for columns with bit type;
103-
- `IntegerColumnSchema` for columns with integer type (tinyint, smallint, integer, bigint);
104-
- `BigIntColumnSchema` for columns with integer type with range outside `PHP_INT_MIN` and `PHP_INT_MAX`;
105-
- `DoubleColumnSchema` for columns with fractional number type (float, double, decimal, money);
106-
- `StringColumnSchema` for columns with string or datetime type (char, string, text, datetime, timestamp, date, time);
107-
- `BinaryColumnSchema` for columns with binary type;
108-
- `ArrayColumnSchema` for columns with array type;
109-
- `StructuredColumnSchema` for columns with structured type (composite type in PostgreSQL);
110-
- `JsonColumnSchema` for columns with json type.
104+
- `BooleanColumn` for columns with boolean type;
105+
- `BitColumn` for columns with bit type;
106+
- `IntegerColumn` for columns with integer type (tinyint, smallint, integer, bigint);
107+
- `BigIntColumn` for columns with integer type with range outside `PHP_INT_MIN` and `PHP_INT_MAX`;
108+
- `DoubleColumn` for columns with fractional number type (float, double, decimal, money);
109+
- `StringColumn` for columns with string or datetime type (char, string, text, datetime, timestamp, date, time);
110+
- `BinaryColumn` for columns with binary type;
111+
- `ArrayColumn` for columns with array type;
112+
- `StructuredColumn` for columns with structured type (composite type in PostgreSQL);
113+
- `JsonColumn` for columns with json type.
111114

112115
### New methods
113116

docs/guide/en/schema/usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ echo $tableSchema->getCreateSql();
7474
In the full name is a table name prefixed by database schema.
7575
If the schema name is the same as the default schema, the full name won't include the schema name.
7676

77-
### Retrieving column schemas
77+
### Retrieving table columns
7878

7979
You can retrieve the column metadata for a given table using either the `getColumns()` method or `getColumn()` method
8080
of `TableSchema` class:
@@ -95,5 +95,5 @@ $column = $tableSchema->getColumn('id');
9595
echo 'id (' . $column->getDbType() . ')';
9696
```
9797

98-
In either case you get instance or instances
99-
or `ColumnSchemaInterface` that you can use to get all the information about the column.
98+
In either case you get instance or instances of `ColumnInterface` that you can use to get available information about
99+
the column.

src/Command/AbstractCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Yiisoft\Db\Query\QueryInterface;
1212
use Yiisoft\Db\QueryBuilder\DMLQueryBuilderInterface;
1313
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
14-
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
14+
use Yiisoft\Db\Schema\Column\ColumnInterface;
1515

1616
use function explode;
1717
use function get_resource_type;
@@ -131,7 +131,7 @@ public function addCheck(string $table, string $name, string $expression): stati
131131
return $this->setSql($sql)->requireTableSchemaRefresh($table);
132132
}
133133

134-
public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): static
134+
public function addColumn(string $table, string $column, ColumnInterface|string $type): static
135135
{
136136
$sql = $this->getQueryBuilder()->addColumn($table, $column, $type);
137137
return $this->setSql($sql)->requireTableSchemaRefresh($table);
@@ -188,7 +188,7 @@ public function addUnique(string $table, string $name, array|string $columns): s
188188
return $this->setSql($sql)->requireTableSchemaRefresh($table);
189189
}
190190

191-
public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): static
191+
public function alterColumn(string $table, string $column, ColumnInterface|string $type): static
192192
{
193193
$sql = $this->getQueryBuilder()->alterColumn($table, $column, $type);
194194
return $this->setSql($sql)->requireTableSchemaRefresh($table);

src/Command/CommandInterface.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Yiisoft\Db\Query\Data\DataReaderInterface;
1919
use Yiisoft\Db\Query\QueryInterface;
2020
use Yiisoft\Db\QueryBuilder\DMLQueryBuilderInterface;
21-
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
21+
use Yiisoft\Db\Schema\Column\ColumnInterface;
2222

2323
/**
2424
* 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
4646
*
4747
* @param string $table The name of the table to add new column to.
4848
* @param string $column The name of the new column.
49-
* @param ColumnSchemaInterface|string $type The column type.
49+
* @param ColumnInterface|string $type The column type.
5050
* {@see QueryBuilder::buildColumnDefinition()} will be called to convert the given column type to the database one.
5151
* For example, `string` will be converted to `varchar(255)`, and `string not null` becomes `varchar(255) not null`.
5252
*
5353
* Note: The method will quote the `table` and `column` parameters before using them in the generated SQL.
5454
*/
55-
public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): static;
55+
public function addColumn(string $table, string $column, ColumnInterface|string $type): static;
5656

5757
/**
5858
* 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
146146
*
147147
* @param string $table The table whose column is to change.
148148
* @param string $column The name of the column to change.
149-
* @param ColumnSchemaInterface|string $type The column type.
149+
* @param ColumnInterface|string $type The column type.
150150
* {@see QueryBuilder::buildColumnDefinition()} will be called to convert the give column type to the physical one.
151151
* For example, `string` will be converted as `varchar(255)`, and `string not null` becomes `varchar(255) not null`.
152152
*
153153
* Note: The method will quote the `table` and `column` parameters before using them in the generated SQL.
154154
*/
155-
public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): static;
155+
public function alterColumn(string $table, string $column, ColumnInterface|string $type): static;
156156

157157
/**
158158
* Creates a batch INSERT command.
@@ -319,14 +319,14 @@ public function createIndex(
319319
* The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name
320320
* is the name of the column which will be properly quoted by the method, and definition is the type of the column
321321
* which can contain a native database column type, {@see ColumnType abstract} or {@see PseudoType pseudo} type,
322-
* or can be represented as instance of {@see ColumnSchemaInterface}.
322+
* or can be represented as instance of {@see ColumnInterface}.
323323
*
324324
* The {@see QueryBuilderInterface::buildColumnDefinition()} method will be invoked to convert column definitions
325325
* into SQL representation. For example, it will convert `string not null` to `varchar(255) not null`
326326
* and `pk` to `int PRIMARY KEY AUTO_INCREMENT` (for MySQL).
327327
*
328328
* The preferred way is to use {@see ColumnBuilder} to generate column definitions as instances of
329-
* {@see ColumnSchemaInterface}.
329+
* {@see ColumnInterface}.
330330
*
331331
* ```php
332332
* $this->createTable(
@@ -348,8 +348,8 @@ public function createIndex(
348348
* generated SQL.
349349
*
350350
* @param string $table The name of the table to create.
351-
* @param (ColumnSchemaInterface|string)[] $columns The columns (name => definition) in the new table.
352-
* The definition can be `string` or {@see ColumnSchemaInterface} instance.
351+
* @param (ColumnInterface|string)[] $columns The columns (name => definition) in the new table.
352+
* The definition can be `string` or {@see ColumnInterface} instance.
353353
* @param string|null $options More SQL fragments to append to the generated SQL.
354354
*
355355
* @throws Exception
@@ -358,7 +358,7 @@ public function createIndex(
358358
*
359359
* Note: The method will quote the `table` and `columns` parameter before using it in the generated SQL.
360360
*
361-
* @psalm-param array<string, ColumnSchemaInterface>|string[] $columns
361+
* @psalm-param array<string, ColumnInterface>|string[] $columns
362362
*/
363363
public function createTable(string $table, array $columns, string $options = null): static;
364364

src/Constant/PhpType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace Yiisoft\Db\Constant;
66

7-
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
7+
use Yiisoft\Db\Schema\Column\ColumnInterface;
88

99
/**
1010
* Defines the available PHP types.
1111
* Used to generate properties of a related model class.
1212
*
13-
* @see ColumnSchemaInterface::getPhpType()
13+
* @see ColumnInterface::getPhpType()
1414
* @see https://www.php.net/manual/en/language.types.type-system.php
1515
*/
1616
final class PhpType

src/Debug/CommandInterfaceProxy.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Yiisoft\Db\Command\CommandInterface;
1010
use Yiisoft\Db\Query\Data\DataReaderInterface;
1111
use Yiisoft\Db\Query\QueryInterface;
12-
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
12+
use Yiisoft\Db\Schema\Column\ColumnInterface;
1313

1414
final class CommandInterfaceProxy implements CommandInterface
1515
{
@@ -30,7 +30,7 @@ public function addCheck(string $table, string $name, string $expression): stati
3030
/**
3131
* @psalm-suppress MixedArgument
3232
*/
33-
public function addColumn(string $table, string $column, ColumnSchemaInterface|string $type): static
33+
public function addColumn(string $table, string $column, ColumnInterface|string $type): static
3434
{
3535
return new self($this->decorated->{__FUNCTION__}(...func_get_args()), $this->collector);
3636
}
@@ -93,7 +93,7 @@ public function addUnique(string $table, string $name, array|string $columns): s
9393
/**
9494
* @psalm-suppress MixedArgument
9595
*/
96-
public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): static
96+
public function alterColumn(string $table, string $column, ColumnInterface|string $type): static
9797
{
9898
return new self($this->decorated->{__FUNCTION__}(...func_get_args()), $this->collector);
9999
}

src/Expression/StructuredExpression.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Yiisoft\Db\Expression;
66

77
use Traversable;
8-
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
8+
use Yiisoft\Db\Schema\Column\ColumnInterface;
99

1010
use function array_key_exists;
1111
use function array_keys;
@@ -38,10 +38,10 @@ final class StructuredExpression implements ExpressionInterface
3838
* @param string|null $type The structured database type name. Defaults to `null` which means the type is not
3939
* explicitly specified. Note that in the case where a type is not specified explicitly and DBMS cannot guess it
4040
* from the context, SQL error will be raised.
41-
* @param ColumnSchemaInterface[] $columns The structured type columns that are used for value normalization and type
41+
* @param ColumnInterface[] $columns The structured type columns that are used for value normalization and type
4242
* casting.
4343
*
44-
* @psalm-param array<string, ColumnSchemaInterface> $columns
44+
* @psalm-param array<string, ColumnInterface> $columns
4545
*/
4646
public function __construct(
4747
private array|object $value,
@@ -66,7 +66,7 @@ public function getType(): string|null
6666
/**
6767
* The structured type columns that are used for value normalization and type casting.
6868
*
69-
* @return ColumnSchemaInterface[]
69+
* @return ColumnInterface[]
7070
*/
7171
public function getColumns(): array
7272
{

0 commit comments

Comments
 (0)