Final Class Yiisoft\Db\Sqlite\Column\ColumnDefinitionBuilder
| Inheritance | Yiisoft\Db\Sqlite\Column\ColumnDefinitionBuilder » Yiisoft\Db\QueryBuilder\AbstractColumnDefinitionBuilder |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| build() | Yiisoft\Db\Sqlite\Column\ColumnDefinitionBuilder |
Protected Methods
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| AUTO_INCREMENT_KEYWORD | 'AUTOINCREMENT' | Yiisoft\Db\Sqlite\Column\ColumnDefinitionBuilder | |
| TYPES_WITH_SCALE | [ 'float', 'real', 'double', 'decimal', 'numeric', ] | Yiisoft\Db\Sqlite\Column\ColumnDefinitionBuilder | |
| TYPES_WITH_SIZE | [ 'bit', 'tinyint', 'smallint', 'mediumint', 'int', 'integer', 'bigint', 'float', 'real', 'double', 'decimal', 'numeric', 'char', 'varchar', 'text', 'blob', 'timestamp', 'datetime', 'datetimetz', 'time', 'timetz', ] | Yiisoft\Db\Sqlite\Column\ColumnDefinitionBuilder |
Method Details
| public string build ( \Yiisoft\Db\Schema\Column\ColumnInterface $column ) | ||
| $column | \Yiisoft\Db\Schema\Column\ColumnInterface | |
public function build(ColumnInterface $column): string
{
if ($column->isUnsigned()) {
throw new NotSupportedException('The "unsigned" attribute is not supported by SQLite.');
}
return $this->buildType($column)
. $this->buildPrimaryKey($column)
. $this->buildAutoIncrement($column)
. $this->buildUnique($column)
. $this->buildNotNull($column)
. $this->buildDefault($column)
. $this->buildCheck($column)
. $this->buildCollate($column)
. $this->buildReferences($column)
. $this->buildExtra($column)
. $this->buildComment($column);
}
| protected string buildComment ( \Yiisoft\Db\Schema\Column\ColumnInterface $column ) | ||
| $column | \Yiisoft\Db\Schema\Column\ColumnInterface | |
protected function buildComment(ColumnInterface $column): string
{
$comment = $column->getComment();
return $comment === null || $comment === '' ? '' : ' /* ' . str_replace('*/', '*\/', $comment) . ' */';
}
| protected string buildNotNull ( \Yiisoft\Db\Schema\Column\ColumnInterface $column ) | ||
| $column | \Yiisoft\Db\Schema\Column\ColumnInterface | |
protected function buildNotNull(ColumnInterface $column): string
{
return $column->isPrimaryKey() ? ' NOT NULL' : parent::buildNotNull($column);
}
| protected string getDbType ( \Yiisoft\Db\Schema\Column\ColumnInterface $column ) | ||
| $column | \Yiisoft\Db\Schema\Column\ColumnInterface | |
protected function getDbType(ColumnInterface $column): string
{
/** @psalm-suppress DocblockTypeContradiction */
return $column->getDbType() ?? match ($column->getType()) {
ColumnType::BOOLEAN => 'boolean',
ColumnType::BIT => 'bit',
ColumnType::TINYINT => $column->isAutoIncrement() ? 'integer' : 'tinyint',
ColumnType::SMALLINT => $column->isAutoIncrement() ? 'integer' : 'smallint',
ColumnType::INTEGER => 'integer',
ColumnType::BIGINT => $column->isAutoIncrement() ? 'integer' : 'bigint',
ColumnType::FLOAT => 'float',
ColumnType::DOUBLE => 'double',
ColumnType::DECIMAL => 'decimal',
ColumnType::MONEY => 'decimal',
ColumnType::CHAR => 'char',
ColumnType::STRING => 'varchar(' . ($column->getSize() ?? 255) . ')',
ColumnType::TEXT => 'text',
ColumnType::BINARY => 'blob',
ColumnType::UUID => 'blob(16)',
ColumnType::TIMESTAMP => 'timestamp',
ColumnType::DATETIME => 'datetime',
ColumnType::DATETIMETZ => 'datetimetz',
ColumnType::TIME => 'time',
ColumnType::TIMETZ => 'timetz',
ColumnType::DATE => 'date',
ColumnType::ARRAY => 'json',
ColumnType::STRUCTURED => 'json',
ColumnType::JSON => 'json',
ColumnType::ENUM => 'varchar',
default => 'varchar',
};
}
| protected string getDefaultUuidExpression ( ) |
protected function getDefaultUuidExpression(): string
{
return '(randomblob(16))';
}
Signup or Login in order to comment.