Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ColumnInterface #379

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Chg #375: Update `QueryBuilder` constructor (@Tigrov)
- Enh #374: Use `ColumnDefinitionBuilder` to generate table column SQL representation (@Tigrov)
- Enh #378: Improve loading schemas of views (@Tigrov)
- Enh #379: Remove `ColumnInterface` (@Tigrov)

## 1.3.0 March 21, 2024

Expand Down
31 changes: 0 additions & 31 deletions src/Column.php

This file was deleted.

7 changes: 1 addition & 6 deletions src/DDLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Throwable;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder;
use Yiisoft\Db\Schema\Builder\ColumnInterface;
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;

use function array_diff;
Expand All @@ -28,15 +27,11 @@ public function addDefaultValue(string $table, string $name, string $column, mix
throw new NotSupportedException(__METHOD__ . ' is not supported by PostgreSQL.');
}

public function alterColumn(string $table, string $column, ColumnInterface|ColumnSchemaInterface|string $type): string
public function alterColumn(string $table, string $column, ColumnSchemaInterface|string $type): string
{
$columnName = $this->quoter->quoteColumnName($column);
$tableName = $this->quoter->quoteTableName($table);

if ($type instanceof ColumnInterface) {
$type = $type->asString();
}

/**
* @link /~https://github.com/yiisoft/yii2/issues/4492
* @link https://www.postgresql.org/docs/9.1/static/sql-altertable.html
Expand Down
34 changes: 0 additions & 34 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace Yiisoft\Db\Pgsql;

use Yiisoft\Db\Connection\ServerInfoInterface;
use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Constant\PseudoType;
use Yiisoft\Db\Pgsql\Column\ColumnDefinitionBuilder;
use Yiisoft\Db\QueryBuilder\AbstractQueryBuilder;
use Yiisoft\Db\Schema\QuoterInterface;
Expand All @@ -19,38 +17,6 @@
*/
final class QueryBuilder extends AbstractQueryBuilder
{
/**
* @var array Mapping from abstract column types (keys) to physical column types (values).
*
* @psalm-var string[]
*/
protected array $typeMap = [
PseudoType::PK => 'serial NOT NULL PRIMARY KEY',
PseudoType::UPK => 'serial NOT NULL PRIMARY KEY',
PseudoType::BIGPK => 'bigserial NOT NULL PRIMARY KEY',
PseudoType::UBIGPK => 'bigserial NOT NULL PRIMARY KEY',
ColumnType::CHAR => 'char(1)',
ColumnType::STRING => 'varchar(255)',
ColumnType::TEXT => 'text',
ColumnType::TINYINT => 'smallint',
ColumnType::SMALLINT => 'smallint',
ColumnType::INTEGER => 'integer',
ColumnType::BIGINT => 'bigint',
ColumnType::FLOAT => 'double precision',
ColumnType::DOUBLE => 'double precision',
ColumnType::DECIMAL => 'numeric(10,0)',
ColumnType::DATETIME => 'timestamp(0)',
ColumnType::TIMESTAMP => 'timestamp(0)',
ColumnType::TIME => 'time(0)',
ColumnType::DATE => 'date',
ColumnType::BINARY => 'bytea',
ColumnType::BOOLEAN => 'boolean',
ColumnType::MONEY => 'numeric(19,4)',
ColumnType::JSON => 'jsonb',
ColumnType::UUID => 'uuid',
PseudoType::UUID_PK => 'uuid PRIMARY KEY',
];

public function __construct(QuoterInterface $quoter, SchemaInterface $schema, ServerInfoInterface $serverInfo)
{
parent::__construct(
Expand Down
15 changes: 0 additions & 15 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Yiisoft\Db\Helper\DbArrayHelper;
use Yiisoft\Db\Pgsql\Column\ColumnFactory;
use Yiisoft\Db\Pgsql\Column\SequenceColumnSchemaInterface;
use Yiisoft\Db\Schema\Builder\ColumnInterface;
use Yiisoft\Db\Schema\Column\ColumnFactoryInterface;
use Yiisoft\Db\Schema\Column\ColumnSchemaInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;
Expand Down Expand Up @@ -93,20 +92,6 @@ final class Schema extends AbstractPdoSchema
*/
protected string|null $defaultSchema = 'public';

/**
* @var string|string[] Character used to quote schema, table, etc. names.
*
* An array of 2 characters can be used in case starting and ending characters are different.
*/
protected string|array $tableQuoteCharacter = '"';

/** @deprecated Use {@see ColumnBuilder} instead. Will be removed in 2.0. */
public function createColumn(string $type, array|int|string $length = null): ColumnInterface
{
/** @psalm-suppress DeprecatedClass */
return new Column($type, $length);
}

public function getColumnFactory(): ColumnFactoryInterface
{
return new ColumnFactory();
Expand Down