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

Medium and long text support for mysql #506

Closed
wants to merge 2 commits into from
Closed
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
20 changes: 20 additions & 0 deletions src/Migration/AbstractMigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,26 @@ public function text(): ColumnSchemaBuilderInterface
return $this->schema->createColumnSchemaBuilder(SchemaInterface::TYPE_TEXT);
}

/**
* Creates a medium text column.
*
* @return ColumnSchemaBuilderInterface The column instance which can be further customized.
*/
public function mediumtext(): ColumnSchemaBuilderInterface
{
return $this->schema->createColumnSchemaBuilder(SchemaInterface::TYPE_MEDIUMTEXT);
}

/**
* Creates a long text column.
*
* @return ColumnSchemaBuilderInterface The column instance which can be further customized.
*/
public function longtext(): ColumnSchemaBuilderInterface
{
return $this->schema->createColumnSchemaBuilder(SchemaInterface::TYPE_LONGTEXT);
}

/**
* Creates a time column.
*
Expand Down
2 changes: 2 additions & 0 deletions src/Schema/AbstractColumnSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ protected function typecast(mixed $value): mixed
$this->type,
[
SchemaInterface::TYPE_TEXT,
SchemaInterface::TYPE_MEDIUMTEXT,
SchemaInterface::TYPE_LONGTEXT,
SchemaInterface::TYPE_STRING,
SchemaInterface::TYPE_BINARY,
SchemaInterface::TYPE_CHAR,
Expand Down
2 changes: 2 additions & 0 deletions src/Schema/AbstractColumnSchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ abstract class AbstractColumnSchemaBuilder implements ColumnSchemaBuilderInterfa
SchemaInterface::TYPE_CHAR => self::CATEGORY_STRING,
SchemaInterface::TYPE_STRING => self::CATEGORY_STRING,
SchemaInterface::TYPE_TEXT => self::CATEGORY_STRING,
SchemaInterface::TYPE_MEDIUMTEXT => self::CATEGORY_STRING,
SchemaInterface::TYPE_LONGTEXT => self::CATEGORY_STRING,
SchemaInterface::TYPE_TINYINT => self::CATEGORY_NUMERIC,
SchemaInterface::TYPE_SMALLINT => self::CATEGORY_NUMERIC,
SchemaInterface::TYPE_INTEGER => self::CATEGORY_NUMERIC,
Expand Down
2 changes: 2 additions & 0 deletions src/Schema/SchemaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ interface SchemaInterface extends ConstraintSchemaInterface
public const TYPE_CHAR = 'char';
public const TYPE_STRING = 'string';
public const TYPE_TEXT = 'text';
public const TYPE_MEDIUMTEXT = 'mediumtext';
public const TYPE_LONGTEXT = 'longtext';
public const TYPE_TINYINT = 'tinyint';
public const TYPE_SMALLINT = 'smallint';
public const TYPE_INTEGER = 'integer';
Expand Down
2 changes: 2 additions & 0 deletions tests/AbstractQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,8 @@ public function testGetColumnType(): void
$this->assertSame('char', $qb->getColumnType(SchemaInterface::TYPE_CHAR));
$this->assertSame('string', $qb->getColumnType(SchemaInterface::TYPE_STRING));
$this->assertSame('text', $qb->getColumnType(SchemaInterface::TYPE_TEXT));
$this->assertSame('mediumtext', $qb->getColumnType(SchemaInterface::TYPE_MEDIUMTEXT));
$this->assertSame('longtext', $qb->getColumnType(SchemaInterface::TYPE_LONGTEXT));
$this->assertSame('tinyint', $qb->getColumnType(SchemaInterface::TYPE_TINYINT));
$this->assertSame('smallint', $qb->getColumnType(SchemaInterface::TYPE_SMALLINT));
$this->assertSame('integer', $qb->getColumnType(SchemaInterface::TYPE_INTEGER));
Expand Down
22 changes: 22 additions & 0 deletions tests/Provider/ColumnTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,28 @@ public function getColumnTypes(): array
'sqlsrv' => 'nvarchar(max)',
],
],
[
SchemaInterface::TYPE_MEDIUMTEXT,
$this->mediumtext(),
[
'mysql' => 'mediumtext',
'pgsql' => 'text',
'sqlite' => 'text',
'oci' => 'CLOB',
'sqlsrv' => 'nvarchar(max)',
],
],
[
SchemaInterface::TYPE_LONGTEXT,
$this->longtext(),
[
'mysql' => 'longtext',
'pgsql' => 'text',
'sqlite' => 'text',
'oci' => 'CLOB',
'sqlsrv' => 'nvarchar(max)',
],
],
[
SchemaInterface::TYPE_TIME . ' NOT NULL',
$this->time()->notNull(),
Expand Down
2 changes: 2 additions & 0 deletions tests/Schema/ColumnSchemaBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public function testGetCategoryMap(): void
'char' => 'string',
'string' => 'string',
'text' => 'string',
'mediumtext' => 'string',
'longtext' => 'string',
'tinyint' => 'numeric',
'smallint' => 'numeric',
'integer' => 'numeric',
Expand Down