mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fix #17457: Fixed phpTypecast() for MSSQL
This commit is contained in:
committed by
Alexander Makarov
parent
9988efc04f
commit
c2eae6cb0e
@ -15,13 +15,16 @@ namespace yii\db\mssql;
|
||||
class ColumnSchema extends \yii\db\ColumnSchema
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Prepares default value and converts it according to [[phpType]]
|
||||
* @param mixed $value default value
|
||||
* @return mixed converted value
|
||||
* @since 2.0.24
|
||||
*/
|
||||
public function phpTypecast($value)
|
||||
public function defaultPhpTypecast($value)
|
||||
{
|
||||
if ($value !== null) {
|
||||
// convert from MSSQL column_default format, e.g. ('1') -> 1, ('string') -> string
|
||||
$value = trim($value, "'()");
|
||||
$value = substr(substr($value, 2), 0, -2);
|
||||
}
|
||||
|
||||
return parent::phpTypecast($value);
|
||||
|
||||
@ -397,7 +397,7 @@ SQL;
|
||||
$info['column_default'] = null;
|
||||
}
|
||||
if (!$column->isPrimaryKey && ($column->type !== 'timestamp' || $info['column_default'] !== 'CURRENT_TIMESTAMP')) {
|
||||
$column->defaultValue = $column->phpTypecast($info['column_default']);
|
||||
$column->defaultValue = $column->defaultPhpTypecast($info['column_default']);
|
||||
}
|
||||
|
||||
return $column;
|
||||
|
||||
Reference in New Issue
Block a user