Fixes #8293: yii\db\Query can be passed to insert method in yii\db\QueryBuilder

This commit is contained in:
voroks
2017-01-28 23:45:18 +03:00
committed by Alexander Makarov
parent 240bca515a
commit 25f08afc96
7 changed files with 237 additions and 50 deletions

View File

@@ -245,12 +245,18 @@ class QueryBuilder extends \yii\db\QueryBuilder
/**
* Normalizes data to be saved into the table, performing extra preparations and type converting, if necessary.
* @param string $table the table that data will be saved into.
* @param array $columns the column data (name => value) to be saved into the table.
* @param array|\yii\db\Query $columns the column data (name => value) to be saved into the table or instance
* of [[yii\db\Query|Query]] to perform INSERT INTO ... SELECT SQL statement.
* Passing of [[yii\db\Query|Query]] is available since version 2.0.11.
* @return array normalized columns
* @since 2.0.9
*/
private function normalizeTableRowData($table, $columns)
{
if ($columns instanceof \yii\db\Query) {
return $columns;
}
if (($tableSchema = $this->db->getSchema()->getTableSchema($table)) !== null) {
$columnSchemas = $tableSchema->columns;
foreach ($columns as $name => $value) {
@@ -259,6 +265,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
}
}
}
return $columns;
}