diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 5594bb8096..ff648de065 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 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 #10020: Fixed quoting of column names with dots in MSSQL (alexkart) - Bug #17424: Subdomain support for `User::loginRequired` (alex-code) diff --git a/framework/db/mssql/ColumnSchema.php b/framework/db/mssql/ColumnSchema.php index 5b39a3eaaf..8ccd69f13f 100644 --- a/framework/db/mssql/ColumnSchema.php +++ b/framework/db/mssql/ColumnSchema.php @@ -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); diff --git a/framework/db/mssql/Schema.php b/framework/db/mssql/Schema.php index 2ede258c8a..6e86cfb8aa 100644 --- a/framework/db/mssql/Schema.php +++ b/framework/db/mssql/Schema.php @@ -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;