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

Update bit type #353

Merged
merged 2 commits into from
Aug 8, 2024
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 @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/Column/ArrayColumnSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 2 additions & 11 deletions src/Column/BitColumnSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 0 additions & 4 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*/
Expand Down