mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-04 06:24:36 +01:00
Fixes #8293: yii\db\Query can be passed to insert method in yii\db\QueryBuilder
This commit is contained in:
committed by
Alexander Makarov
parent
240bca515a
commit
25f08afc96
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user