From 56becb5cb0fd332e03be1f8c25ba7a0c62585b8e Mon Sep 17 00:00:00 2001 From: Sergei Tigrov Date: Thu, 8 Aug 2024 11:40:06 +0700 Subject: [PATCH] Update `bit` type (#353) --- CHANGELOG.md | 1 + src/Column/ArrayColumnSchema.php | 2 +- src/Column/BitColumnSchema.php | 13 ++----------- src/Schema.php | 4 ---- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a1b2ccb..f24370fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Chg #348: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov) - Enh #349: Add method chaining for column classes (@Tigrov) - Enh #350: Add array overlaps and JSON overlaps condition builders (@Tigrov) +- Enh #353: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov) ## 1.3.0 March 21, 2024 diff --git a/src/Column/ArrayColumnSchema.php b/src/Column/ArrayColumnSchema.php index 43e2a299..789dbf8b 100644 --- a/src/Column/ArrayColumnSchema.php +++ b/src/Column/ArrayColumnSchema.php @@ -61,7 +61,7 @@ public function getColumn(): ColumnSchemaInterface $phpType = $this->getPhpType(); $this->column = match ($type) { - Schema::TYPE_BIT => new BitColumnSchema($type, $phpType), + SchemaInterface::TYPE_BIT => new BitColumnSchema($type, $phpType), Schema::TYPE_STRUCTURED => new StructuredColumnSchema($type, $phpType), SchemaInterface::TYPE_BIGINT => PHP_INT_SIZE !== 8 ? new BigIntColumnSchema($type, $phpType) diff --git a/src/Column/BitColumnSchema.php b/src/Column/BitColumnSchema.php index b0f65f3a..02ea6c28 100644 --- a/src/Column/BitColumnSchema.php +++ b/src/Column/BitColumnSchema.php @@ -5,24 +5,15 @@ namespace Yiisoft\Db\Pgsql\Column; use Yiisoft\Db\Expression\ExpressionInterface; -use Yiisoft\Db\Pgsql\Schema; -use Yiisoft\Db\Schema\Column\AbstractColumnSchema; -use Yiisoft\Db\Schema\SchemaInterface; +use Yiisoft\Db\Schema\Column\BitColumnSchema as BaseBitColumnSchema; use function bindec; use function decbin; use function gettype; use function str_pad; -final class BitColumnSchema extends AbstractColumnSchema +final class BitColumnSchema extends BaseBitColumnSchema { - public function __construct( - string $type = Schema::TYPE_BIT, - string|null $phpType = SchemaInterface::PHP_TYPE_INTEGER, - ) { - parent::__construct($type, $phpType); - } - /** @psalm-suppress RedundantCast */ public function dbTypecast(mixed $value): string|ExpressionInterface|null { diff --git a/src/Schema.php b/src/Schema.php index d6829405..ae8c1a42 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -97,10 +97,6 @@ */ final class Schema extends AbstractPdoSchema { - /** - * Define the abstract column type as `bit`. - */ - public const TYPE_BIT = 'bit'; /** * Define the abstract column type as `array`. */