From 26c7f6d62f004fc4caec1185a627069931e9f10d Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 3 Nov 2013 09:02:17 -0500 Subject: [PATCH] Fixed sqlite column type detection bug. --- framework/yii/db/pgsql/Schema.php | 2 +- framework/yii/db/sqlite/Schema.php | 2 +- tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework/yii/db/pgsql/Schema.php b/framework/yii/db/pgsql/Schema.php index 20c6fb6..2dbe111 100644 --- a/framework/yii/db/pgsql/Schema.php +++ b/framework/yii/db/pgsql/Schema.php @@ -303,7 +303,7 @@ SQL; $column->dbType = $info['data_type']; $column->defaultValue = $info['column_default']; $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->name = $info['column_name']; $column->precision = $info['numeric_precision']; diff --git a/framework/yii/db/sqlite/Schema.php b/framework/yii/db/sqlite/Schema.php index 294c97e..38fbf3a 100644 --- a/framework/yii/db/sqlite/Schema.php +++ b/framework/yii/db/sqlite/Schema.php @@ -153,7 +153,7 @@ class Schema extends \yii\db\Schema $column->type = self::TYPE_STRING; if (preg_match('/^(\w+)(?:\(([^\)]+)\))?/', $column->dbType, $matches)) { - $type = $matches[1]; + $type = strtolower($matches[1]); if (isset($this->typeMap[$type])) { $column->type = $this->typeMap[$type]; } diff --git a/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php b/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php index 659908e..6f499bb 100644 --- a/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php +++ b/tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php @@ -36,10 +36,10 @@ class SqliteActiveRecordTest extends ActiveRecordTest $this->assertTrue(0 == $customer->status); // select with boolean values does not seem to work in sqlite -// $customers = Customer::find()->where(['status' => true])->all(); -// $this->assertEquals(2, count($customers)); -// -// $customers = Customer::find()->where(['status' => false])->all(); -// $this->assertEquals(1, count($customers)); + $customers = Customer::find()->where(['status' => true])->all(); + $this->assertEquals(2, count($customers)); + + $customers = Customer::find()->where(['status' => false])->all(); + $this->assertEquals(1, count($customers)); } }