diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a5291a5..73991fbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Enh #321: Implement `SqlParser` and `ExpressionBuilder` driver classes (@Tigrov) - Chg #339: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov) - Enh #342: Add JSON overlaps condition builder (@Tigrov) +- Enh #344: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov) ## 1.2.0 March 21, 2024 diff --git a/src/Schema.php b/src/Schema.php index 619fe58a..a1673a0e 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -84,7 +84,7 @@ final class Schema extends AbstractPdoSchema */ private const TYPE_MAP = [ 'tinyint' => self::TYPE_TINYINT, - 'bit' => self::TYPE_INTEGER, + 'bit' => self::TYPE_BIT, 'smallint' => self::TYPE_SMALLINT, 'mediumint' => self::TYPE_INTEGER, 'int' => self::TYPE_INTEGER, @@ -523,12 +523,8 @@ private function getColumnType(string $dbType, array &$info): string $info['scale'] = (int) $values[1]; } - if ($dbType === 'bit') { - return match (true) { - $info['size'] === 1 => self::TYPE_BOOLEAN, - $info['size'] > 32 => self::TYPE_BIGINT, - default => self::TYPE_INTEGER, - }; + if ($dbType === 'bit' && $info['size'] === 1) { + return self::TYPE_BOOLEAN; } } } diff --git a/tests/Provider/SchemaProvider.php b/tests/Provider/SchemaProvider.php index 880f597e..e1f07354 100644 --- a/tests/Provider/SchemaProvider.php +++ b/tests/Provider/SchemaProvider.php @@ -239,7 +239,7 @@ public static function columns(): array 'defaultValue' => new Expression('CURRENT_TIMESTAMP'), ], 'bit_col' => [ - 'type' => 'integer', + 'type' => 'bit', 'dbType' => 'bit(8)', 'phpType' => 'integer', 'primaryKey' => false, @@ -333,7 +333,7 @@ public static function columnsTypeBit(): array 'defaultValue' => true, ], 'bit_col_3' => [ - 'type' => 'integer', + 'type' => 'bit', 'dbType' => 'bit(32)', 'phpType' => 'integer', 'primaryKey' => false, @@ -346,7 +346,7 @@ public static function columnsTypeBit(): array 'defaultValue' => null, ], 'bit_col_4' => [ - 'type' => 'integer', + 'type' => 'bit', 'dbType' => 'bit(32)', 'phpType' => 'integer', 'primaryKey' => false, @@ -359,7 +359,7 @@ public static function columnsTypeBit(): array 'defaultValue' => 130, ], 'bit_col_5' => [ - 'type' => 'bigint', + 'type' => 'bit', 'dbType' => 'bit(64)', 'phpType' => 'integer', 'primaryKey' => false, @@ -372,7 +372,7 @@ public static function columnsTypeBit(): array 'defaultValue' => null, ], 'bit_col_6' => [ - 'type' => 'bigint', + 'type' => 'bit', 'dbType' => 'bit(64)', 'phpType' => 'integer', 'primaryKey' => false,