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

Add typeChar as well #158

Merged
merged 10 commits into from
Dec 14, 2023
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# v6.2.0 (Not Released Yet)

Added
- `json` `mediumText` `longText` support for `Schema\Builder` (#155)
- `json` `mediumText` `longText` `char` support for `Schema\Builder` (#155) (#158)

Changed
- `Query\Builder::lock()` no longer throw an error and will be ignored instead (#156)
Expand Down
11 changes: 11 additions & 0 deletions src/Schema/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,17 @@ protected function typeString(Fluent $column)
return "string({$column->length})";
}

/**
* Create the column definition for a char type.
*
* @param Fluent<string, mixed> $column
* @return string
*/
protected function typeChar(Fluent $column)
{
return $this->typeString($column);
}

/**
* Create the column definition for a text type.
*
Expand Down
4 changes: 4 additions & 0 deletions tests/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function testCreateTable(): void
$table->float('float');
$table->decimal('decimal');
$table->string('name');
$table->char('char');
$table->text('text');
$table->mediumText('medium_text');
$table->longText('long_text');
Expand All @@ -58,6 +59,7 @@ public function testCreateTable(): void
'`float` float64 not null',
'`decimal` numeric not null',
'`name` string(255) not null',
'`char` string(255) not null',
'`text` string(max) not null',
'`medium_text` string(max) not null',
'`long_text` string(max) not null',
Expand Down Expand Up @@ -419,6 +421,7 @@ public function test_default_values(): void
$table->boolean('bool')->default(true);
$table->string('string')->default('a');
$table->text('string_max')->default('a');
$table->char('char')->default('a');
$table->mediumText('medium_text')->default('a');
$table->longText('long_text')->default('a');
$table->float('raw')->default(DB::raw('1.1'));
Expand Down Expand Up @@ -454,6 +457,7 @@ public function test_default_values(): void
'`bool` bool not null default (true)',
'`string` string(255) not null default ("a")',
'`string_max` string(max) not null default ("a")',
'`char` string(255) not null default ("a")',
'`medium_text` string(max) not null default ("a")',
'`long_text` string(max) not null default ("a")',
'`raw` float64 not null default (1.1)',
Expand Down