mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-06 07:58:12 +08:00
Fix #17457: Fixed phpTypecast() for MSSQL
This commit is contained in:
committed by
Alexander Makarov
parent
9988efc04f
commit
c2eae6cb0e
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
|||||||
2.0.24 under development
|
2.0.24 under development
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
- Bug #17457: Fixed `phpTypecast()` for MSSQL (alexkart)
|
||||||
- Bug #17219: Fixed quoting of table names with spaces in MSSQL (alexkart)
|
- Bug #17219: Fixed quoting of table names with spaces in MSSQL (alexkart)
|
||||||
- Bug #10020: Fixed quoting of column names with dots in MSSQL (alexkart)
|
- Bug #10020: Fixed quoting of column names with dots in MSSQL (alexkart)
|
||||||
- Bug #17424: Subdomain support for `User::loginRequired` (alex-code)
|
- Bug #17424: Subdomain support for `User::loginRequired` (alex-code)
|
||||||
|
|||||||
@ -15,13 +15,16 @@ namespace yii\db\mssql;
|
|||||||
class ColumnSchema extends \yii\db\ColumnSchema
|
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) {
|
if ($value !== null) {
|
||||||
// convert from MSSQL column_default format, e.g. ('1') -> 1, ('string') -> string
|
// 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);
|
return parent::phpTypecast($value);
|
||||||
|
|||||||
@ -397,7 +397,7 @@ SQL;
|
|||||||
$info['column_default'] = null;
|
$info['column_default'] = null;
|
||||||
}
|
}
|
||||||
if (!$column->isPrimaryKey && ($column->type !== 'timestamp' || $info['column_default'] !== 'CURRENT_TIMESTAMP')) {
|
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;
|
return $column;
|
||||||
|
|||||||
Reference in New Issue
Block a user