Commit 20774165 by mcd.php Committed by Alexander Makarov

Fixes #4644: Added `\yii\db\Schema::createColumnSchema()` to be able to…

Fixes #4644: Added `\yii\db\Schema::createColumnSchema()` to be able to customize column schema used
parent a4e4c1e0
...@@ -173,6 +173,7 @@ Yii Framework 2 Change Log ...@@ -173,6 +173,7 @@ Yii Framework 2 Change Log
- Enh #4566: Added client validation support for image validator (Skysplit, qiangxue) - Enh #4566: Added client validation support for image validator (Skysplit, qiangxue)
- Enh #4581: Added ability to disable url encoding in `UrlRule` (tadaszelvys) - Enh #4581: Added ability to disable url encoding in `UrlRule` (tadaszelvys)
- Enh #4602: Added $key param in ActionColumn buttons Closure call (disem) - Enh #4602: Added $key param in ActionColumn buttons Closure call (disem)
- Enh #4644: Added `\yii\db\Schema::createColumnSchema()` to be able to customize column schema used (mcd-php)
- Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue) - Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue)
- Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue) - Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue)
- Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue) - Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
......
...@@ -84,6 +84,13 @@ abstract class Schema extends Object ...@@ -84,6 +84,13 @@ abstract class Schema extends Object
*/ */
private $_builder; private $_builder;
/**
* @return \yii\db\ColumnSchema
* @throws \yii\base\InvalidConfigException
*/
protected function createColumnSchema() {
return Yii::createObject('yii\db\ColumnSchema');
}
/** /**
* Loads the metadata for the specified table. * Loads the metadata for the specified table.
......
...@@ -195,7 +195,7 @@ class Schema extends \yii\db\Schema ...@@ -195,7 +195,7 @@ class Schema extends \yii\db\Schema
*/ */
protected function loadColumnSchema($info) protected function loadColumnSchema($info)
{ {
$column = new ColumnSchema(); $column = $this->createColumnSchema();
$column->name = $info['Field']; $column->name = $info['Field'];
$column->allowNull = $info['Null'] === 'YES'; $column->allowNull = $info['Null'] === 'YES';
......
...@@ -176,7 +176,7 @@ class Schema extends \yii\db\Schema ...@@ -176,7 +176,7 @@ class Schema extends \yii\db\Schema
*/ */
protected function loadColumnSchema($info) protected function loadColumnSchema($info)
{ {
$column = new ColumnSchema(); $column = $this->createColumnSchema();
$column->name = $info['column_name']; $column->name = $info['column_name'];
$column->allowNull = $info['is_nullable'] == 'YES'; $column->allowNull = $info['is_nullable'] == 'YES';
......
...@@ -127,7 +127,7 @@ class Schema extends \yii\db\Schema ...@@ -127,7 +127,7 @@ class Schema extends \yii\db\Schema
*/ */
protected function loadColumnSchema($info) protected function loadColumnSchema($info)
{ {
$column = new ColumnSchema; $column = $this->createColumnSchema();
$column->name = $info['Field']; $column->name = $info['Field'];
$column->allowNull = $info['Null'] === 'YES'; $column->allowNull = $info['Null'] === 'YES';
......
...@@ -200,7 +200,7 @@ EOD; ...@@ -200,7 +200,7 @@ EOD;
*/ */
protected function createColumn($column) protected function createColumn($column)
{ {
$c = new ColumnSchema(); $c = $this->createColumnSchema();
$c->name = $column['COLUMN_NAME']; $c->name = $column['COLUMN_NAME'];
$c->allowNull = $column['NULLABLE'] === 'Y'; $c->allowNull = $column['NULLABLE'] === 'Y';
$c->isPrimaryKey = strpos($column['KEY'], 'P') !== false; $c->isPrimaryKey = strpos($column['KEY'], 'P') !== false;
......
...@@ -434,7 +434,7 @@ SQL; ...@@ -434,7 +434,7 @@ SQL;
*/ */
protected function loadColumnSchema($info) protected function loadColumnSchema($info)
{ {
$column = new ColumnSchema(); $column = $this->createColumnSchema();
$column->allowNull = $info['is_nullable']; $column->allowNull = $info['is_nullable'];
$column->autoIncrement = $info['is_autoinc']; $column->autoIncrement = $info['is_autoinc'];
$column->comment = $info['column_comment']; $column->comment = $info['column_comment'];
......
...@@ -212,7 +212,7 @@ class Schema extends \yii\db\Schema ...@@ -212,7 +212,7 @@ class Schema extends \yii\db\Schema
*/ */
protected function loadColumnSchema($info) protected function loadColumnSchema($info)
{ {
$column = new ColumnSchema; $column = $this->createColumnSchema();
$column->name = $info['name']; $column->name = $info['name'];
$column->allowNull = !$info['notnull']; $column->allowNull = !$info['notnull'];
$column->isPrimaryKey = $info['pk'] != 0; $column->isPrimaryKey = $info['pk'] != 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment