Skip to content

Commit

Permalink
Update bit type
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Jul 29, 2024
1 parent 15f0982 commit 7761107
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
10 changes: 1 addition & 9 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ final class Schema extends AbstractPdoSchema
*/
private const TYPE_MAP = [
'tinyint' => self::TYPE_TINYINT,
'bit' => self::TYPE_SMALLINT,
'bit' => self::TYPE_BIT,
'boolean' => self::TYPE_BOOLEAN,
'bool' => self::TYPE_BOOLEAN,
'smallint' => self::TYPE_SMALLINT,
Expand Down Expand Up @@ -518,14 +518,6 @@ private function getColumnType(string $dbType, array &$info): string
if (($dbType === 'tinyint' || $dbType === 'bit') && $info['size'] === 1) {
return self::TYPE_BOOLEAN;
}

if ($dbType === 'bit') {
return match (true) {
$info['size'] === 32 => self::TYPE_INTEGER,
$info['size'] > 32 => self::TYPE_BIGINT,
default => self::TYPE_SMALLINT,
};
}
}

return self::TYPE_MAP[$dbType] ?? self::TYPE_STRING;
Expand Down
10 changes: 5 additions & 5 deletions tests/Provider/SchemaProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static function columns(): array
'defaultValue' => new Expression('CURRENT_TIMESTAMP'),
],
'bit_col' => [
'type' => 'smallint',
'type' => 'bit',
'dbType' => 'bit(8)',
'phpType' => 'integer',
'primaryKey' => false,
Expand Down Expand Up @@ -361,7 +361,7 @@ public static function columnsTypeBit(): array
'defaultValue' => true,
],
'bit_col_3' => [
'type' => 'integer',
'type' => 'bit',
'dbType' => 'bit(32)',
'phpType' => 'integer',
'primaryKey' => false,
Expand All @@ -374,7 +374,7 @@ public static function columnsTypeBit(): array
'defaultValue' => null,
],
'bit_col_4' => [
'type' => 'integer',
'type' => 'bit',
'dbType' => 'bit(32)',
'phpType' => 'integer',
'primaryKey' => false,
Expand All @@ -387,7 +387,7 @@ public static function columnsTypeBit(): array
'defaultValue' => 1,
],
'bit_col_5' => [
'type' => 'bigint',
'type' => 'bit',
'dbType' => 'bit(64)',
'phpType' => 'integer',
'primaryKey' => false,
Expand All @@ -400,7 +400,7 @@ public static function columnsTypeBit(): array
'defaultValue' => null,
],
'bit_col_6' => [
'type' => 'bigint',
'type' => 'bit',
'dbType' => 'bit(64)',
'phpType' => 'integer',
'primaryKey' => false,
Expand Down

0 comments on commit 7761107

Please sign in to comment.