Commit ff50f150 by Qiang Xue

proper quoting of sequence name.

parent bc5028eb
......@@ -7,6 +7,7 @@
namespace yii\db\oci;
use yii\base\InvalidCallException;
use yii\db\TableSchema;
use yii\db\ColumnSchema;
......
......@@ -99,12 +99,8 @@ class QueryBuilder extends \yii\db\QueryBuilder
{
$table = $this->db->getTableSchema($tableName);
if ($table !== null && $table->sequenceName !== null) {
$sequence = '"' . $table->sequenceName . '"';
if (strpos($sequence, '.') !== false) {
$sequence = str_replace('.', '"."', $sequence);
}
// c.f. http://www.postgresql.org/docs/8.1/static/functions-sequence.html
$sequence = $this->db->quoteTableName($table->sequenceName);
$tableName = $this->db->quoteTableName($tableName);
if ($value === null) {
$key = reset($table->primaryKey);
......
......@@ -405,7 +405,7 @@ SQL;
if ($column->isPrimaryKey) {
$table->primaryKey[] = $column->name;
if ($table->sequenceName === null && preg_match("/nextval\\('\"?\\w+\"?\.?\"?\\w+\"?'(::regclass)?\\)/", $column->defaultValue) === 1) {
$table->sequenceName = trim(preg_replace(['/nextval/', '/::/', '/regclass/', '/\'\)/', '/\(\'/'], '', $column->defaultValue), '"');
$table->sequenceName = preg_replace(['/nextval/', '/::/', '/regclass/', '/\'\)/', '/\(\'/'], '', $column->defaultValue);
}
$column->defaultValue = null;
} elseif ($column->defaultValue) {
......
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