Commit 26c7f6d6 by Qiang Xue

Fixed sqlite column type detection bug.

parent fff1db78
...@@ -303,7 +303,7 @@ SQL; ...@@ -303,7 +303,7 @@ SQL;
$column->dbType = $info['data_type']; $column->dbType = $info['data_type'];
$column->defaultValue = $info['column_default']; $column->defaultValue = $info['column_default'];
$column->enumValues = explode(',', str_replace(["''"], ["'"], $info['enum_values'])); $column->enumValues = explode(',', str_replace(["''"], ["'"], $info['enum_values']));
$column->unsigned = false; // has no meanining in PG $column->unsigned = false; // has no meaning in PG
$column->isPrimaryKey = $info['is_pkey']; $column->isPrimaryKey = $info['is_pkey'];
$column->name = $info['column_name']; $column->name = $info['column_name'];
$column->precision = $info['numeric_precision']; $column->precision = $info['numeric_precision'];
......
...@@ -153,7 +153,7 @@ class Schema extends \yii\db\Schema ...@@ -153,7 +153,7 @@ class Schema extends \yii\db\Schema
$column->type = self::TYPE_STRING; $column->type = self::TYPE_STRING;
if (preg_match('/^(\w+)(?:\(([^\)]+)\))?/', $column->dbType, $matches)) { if (preg_match('/^(\w+)(?:\(([^\)]+)\))?/', $column->dbType, $matches)) {
$type = $matches[1]; $type = strtolower($matches[1]);
if (isset($this->typeMap[$type])) { if (isset($this->typeMap[$type])) {
$column->type = $this->typeMap[$type]; $column->type = $this->typeMap[$type];
} }
......
...@@ -36,10 +36,10 @@ class SqliteActiveRecordTest extends ActiveRecordTest ...@@ -36,10 +36,10 @@ class SqliteActiveRecordTest extends ActiveRecordTest
$this->assertTrue(0 == $customer->status); $this->assertTrue(0 == $customer->status);
// select with boolean values does not seem to work in sqlite // select with boolean values does not seem to work in sqlite
// $customers = Customer::find()->where(['status' => true])->all(); $customers = Customer::find()->where(['status' => true])->all();
// $this->assertEquals(2, count($customers)); $this->assertEquals(2, count($customers));
//
// $customers = Customer::find()->where(['status' => false])->all(); $customers = Customer::find()->where(['status' => false])->all();
// $this->assertEquals(1, count($customers)); $this->assertEquals(1, count($customers));
} }
} }
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