Skip to content
Open
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
13 changes: 13 additions & 0 deletions src/Db/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ abstract class AbstractAdapter implements AdapterInterface, DirectActionInterfac

protected ?Connection $connection = null;

protected static array $specificColumnTypes = [];

/**
* Class Constructor.
*
Expand Down Expand Up @@ -424,6 +426,17 @@ public function isValidColumnType(Column $column): bool
return in_array($column->getType(), $this->getColumnTypes(), true);
}

/**
* Add specific column type to adapter.
*
* @param string $type Adapter column type name.
* @return void
*/
public static function addSpecificColumnType(string $type): void
{
static::$specificColumnTypes[] = $type;
}

/**
* @inheritDoc
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/Db/Table/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ public function testAddColumnWithNoAdapterSpecified(): void
}
}

public function testAddColumnWithSpecificColumnType(): void
{
PostgresAdapter::addSpecificColumnType('my_custom_type');
$adapter = new PostgresAdapter([]);
$table = new Table('ntable', [], $adapter);
$table->addColumn('email', 'my_custom_type');

$actions = $this->getPendingActions($table);
$this->assertInstanceOf(AddColumn::class, $actions[0]);
$this->assertEquals('my_custom_type', $actions[0]->getColumn()->getType());
}

public function testAddComment(): void
{
$adapter = new MysqlAdapter([]);
Expand Down
Loading