mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fixes #6049: yii\db\Connection::getSchema() for Oracle should return false when the table does not exist. Oracle does not support ON UPDATE clause.
This commit is contained in:
@ -26,6 +26,7 @@ Yii Framework 2 Change Log
|
||||
- Bug #5925: `ArrayHelper::htmlEncode()` does not work properly when the value being encoded is a nested array (tebazil)
|
||||
- Bug #5997: The same message may be exported twice to log targets (klimov-paul)
|
||||
- Bug #6018: When setting the `encode` option via `yii\widgets\ActiveRecord::errorOptions`, it works the other way around (stanishevsky, qiangxue)
|
||||
- Bug #6049: `yii\db\Connection::getSchema()` for Oracle should return false when the table does not exist. Oracle does not support `ON UPDATE` clause. (wenbin1989)
|
||||
- Bug: Gii console command help information does not contain global options (qiangxue)
|
||||
- Bug: `yii\web\UrlRule` was unable to create URLs for rules containing unicode characters (samdark)
|
||||
- Enh #4181: Added `yii\bootstrap\Modal::$headerOptions` and `yii\bootstrap\Modal::$footerOptions` (tuxoff, samdark)
|
||||
|
||||
@ -9,6 +9,7 @@ namespace yii\db\oci;
|
||||
|
||||
use yii\base\InvalidParamException;
|
||||
use yii\db\Connection;
|
||||
use yii\db\Exception;
|
||||
|
||||
/**
|
||||
* QueryBuilder is the query builder for Oracle databases.
|
||||
@ -152,46 +153,10 @@ EOD;
|
||||
if ($delete !== null) {
|
||||
$sql .= ' ON DELETE ' . $delete;
|
||||
}
|
||||
if ($update !== null) {
|
||||
throw new Exception('Oracle does not support ON UPDATE clause.');
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function batchInsert($table, $columns, $rows)
|
||||
{
|
||||
$schema = $this->db->getSchema();
|
||||
if (($tableSchema = $schema->getTableSchema($table)) !== null) {
|
||||
$columnSchemas = $tableSchema->columns;
|
||||
} else {
|
||||
$columnSchemas = [];
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($rows as $row) {
|
||||
$vs = [];
|
||||
foreach ($row as $i => $value) {
|
||||
if (!is_array($value) && isset($columns[$i]) && isset($columnSchemas[$columns[$i]])) {
|
||||
$value = $columnSchemas[$columns[$i]]->dbTypecast($value);
|
||||
}
|
||||
if (is_string($value)) {
|
||||
$value = $schema->quoteValue($value);
|
||||
} elseif ($value === false) {
|
||||
$value = 0;
|
||||
} elseif ($value === null) {
|
||||
$value = 'NULL';
|
||||
}
|
||||
$vs[] = $value;
|
||||
}
|
||||
$values[] = 'SELECT ' . implode(', ', $vs) . ' FROM DUAL';
|
||||
}
|
||||
|
||||
foreach ($columns as $i => $name) {
|
||||
$columns[$i] = $schema->quoteColumnName($name);
|
||||
}
|
||||
|
||||
return 'INSERT INTO ' . $schema->quoteTableName($table)
|
||||
. ' (' . implode(', ', $columns) . ') ' . implode(' UNION ', $values);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user