From 6b52b03523dd88a35ed59ff6e8b84c80ec2d4036 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 15 Nov 2014 08:38:24 -0500 Subject: [PATCH] Fixes #6049: `yii\db\Connection::getSchema()` for Oracle should return false when the table does not exist. Oracle does not support `ON UPDATE` clause. --- framework/CHANGELOG.md | 1 + framework/db/oci/QueryBuilder.php | 43 +++---------------------------- 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index d5a2f06f86..18c5ab3dbc 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -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) diff --git a/framework/db/oci/QueryBuilder.php b/framework/db/oci/QueryBuilder.php index f48ff496c1..8091b8c820 100644 --- a/framework/db/oci/QueryBuilder.php +++ b/framework/db/oci/QueryBuilder.php @@ -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); - } }