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 a default size to the mapping #150

Merged
merged 1 commit into from
Dec 20, 2023
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 src/Driver/MySQL/Schema/MySQLColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class MySQLColumn extends AbstractColumn
'binary' => 'blob',
'tinyBinary' => 'tinyblob',
'longBinary' => 'longblob',
'varbinary' => ['type' => 'varbinary', 'size' => 255],

//Additional types
'json' => 'json',
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Postgres/Schema/PostgresColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class PostgresColumn extends AbstractColumn
'bigInteger' => 'bigint',

//String with specified length (mapped via method)
'string' => 'character varying',
'string' => ['type' => 'character varying', 'size' => 255],

//Generic types
'text' => 'text',
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLServer/Schema/SQLServerColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SQLServerColumn extends AbstractColumn
'bigInteger' => 'bigint',

//String with specified length (mapped via method)
'string' => 'varchar',
'string' => ['type' => 'varchar', 'size' => 255],

//Generic types
'text' => ['type' => 'varchar', 'size' => 0],
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/SQLite/Schema/SQLiteColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SQLiteColumn extends AbstractColumn
'bigInteger' => 'bigint',

//String with specified length (mapped via method)
'string' => 'text',
'string' => ['type' => 'text', 'size' => 255],

//Generic types
'text' => 'text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ public function testStringDefaultSize(): void
$this->assertSame(255, $column->getSize());
}

public function testStringDefaultSizeViaMagicMethod(): void
{
$schema = $this->schema('table');

$column = $schema->column('column')->__call('string');
$schema->save();
$this->assertSameAsInDB($schema);

$this->assertSame(255, $column->getSize());
}

public function testStringSize(): void
{
$schema = $this->schema('table');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ public function testVarbinary(): void
$this->assertSame(255, $schema->column('binary_data')->getSize());
}

public function testVarbinaryDefaultSizeViaMagicMethod(): void
{
$schema = $this->schema('table');

$schema->primary('id');
$schema->column('binary_data')->__call('varbinary');
$schema->save(Handler::DO_ALL);

$this->assertSameAsInDB($schema);

$this->assertSame('varbinary', $schema->column('binary_data')->getInternalType());
$this->assertSame(255, $schema->column('binary_data')->getSize());
}

public function testVarbinaryWithSize(): void
{
$schema = $this->schema('table');
Expand Down
Loading