diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index b7a30e6b54d..591eeba3e3a 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -184,18 +184,15 @@ function describe(&$model) { 'default' => $default, 'length' => $this->length($column['type']) ); - if($column['pk'] == 1) { - $fields[$column['name']] = array( - 'type' => $fields[$column['name']]['type'], - 'null' => false, - 'default' => $default, - 'key' => $this->index['PRI'], - 'length' => 11 - ); + if ($column['pk'] == 1) { + $fields[$column['name']]['key'] = $this->index['PRI']; + $fields[$column['name']]['null'] = false; + if (empty($fields[$column['name']]['length'])) { + $fields[$column['name']]['length'] = 11; + } } } - $result->closeCursor(); $this->__cacheDescription($model->tablePrefix . $model->table, $fields); return $fields; diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index aca0f684bf1..c24051675a0 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -550,7 +550,7 @@ public function fetchAll($sql, $params = array(), $options = array()) { if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) { return $cached; } - if ($this->execute($sql, array(), $params)) { + if ($result = $this->execute($sql, array(), $params)) { $out = array(); $first = $this->fetchRow(); @@ -562,7 +562,7 @@ public function fetchAll($sql, $params = array(), $options = array()) { $out[] = $item; } - if ($cache) { + if (!is_bool($result) && $cache) { $this->_writeQueryCache($sql, $out, $params); } diff --git a/cake/tests/cases/console/shells/bake.test.php b/cake/tests/cases/console/shells/bake.test.php index cb254a8b372..6f68e8bb3c4 100644 --- a/cake/tests/cases/console/shells/bake.test.php +++ b/cake/tests/cases/console/shells/bake.test.php @@ -98,6 +98,7 @@ public function testAllWithModelName() { $this->Shell->expects($this->at(3))->method('out')->with('User Model was baked.'); $this->Shell->expects($this->at(5))->method('out')->with('Bake All complete'); $this->Shell->expects($this->at(7))->method('out')->with('User Views were baked.'); + $this->Shell->expects($this->at(8))->method('out')->with('Bake All complete'); $this->Shell->params = array(); $this->Shell->args = array('User'); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php index 4cffa8e4a82..e253b1a2614 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php @@ -90,14 +90,6 @@ class DboSqliteTest extends CakeTestCase { */ public $Dbo = null; -/** - * Simulated DB connection used in testing - * - * @var DboSource - * @access public - */ - public $Dbo2 = null; - /** * Sets up a Dbo class instance for testing * @@ -108,7 +100,6 @@ public function setUp() { if ($this->Dbo->config['driver'] !== 'sqlite') { $this->markTestSkipped('The Sqlite extension is not available.'); } - $this->Dbo2 = new DboSqliteTestDb($this->Dbo->config, false); } /** @@ -117,7 +108,6 @@ public function setUp() { */ public function tearDown() { Configure::write('Cache.disable', false); - unset($this->Dbo2); } /** @@ -127,10 +117,11 @@ public function tearDown() { public function testTableListCacheDisabling() { $this->assertFalse(in_array('foo_test', $this->Dbo->listSources())); - $this->Dbo->query('CREATE TABLE foo_test (test VARCHAR(255));'); + $this->Dbo->query('CREATE TABLE foo_test (test VARCHAR(255))'); $this->assertTrue(in_array('foo_test', $this->Dbo->listSources())); - $this->Dbo->query('DROP TABLE foo_test;'); + $this->Dbo->cacheSources = false; + $this->Dbo->query('DROP TABLE foo_test'); $this->assertFalse(in_array('foo_test', $this->Dbo->listSources())); } @@ -207,7 +198,7 @@ function testBuildColumn() { 'null' => false, ); $result = $this->Dbo->buildColumn($data); - $expected = '"int_field" integer(11) NOT NULL'; + $expected = '"int_field" integer NOT NULL'; $this->assertEqual($result, $expected); $data = array( @@ -251,7 +242,7 @@ function testBuildColumn() { 'null' => false, ); $result = $this->Dbo->buildColumn($data); - $expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL'; + $expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $this->assertEqual($result, $expected); $data = array( @@ -263,7 +254,7 @@ function testBuildColumn() { 'collate' => 'BADVALUE' ); $result = $this->Dbo->buildColumn($data); - $expected = '"testName" integer(10) DEFAULT \'10\' NOT NULL'; + $expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $this->assertEqual($result, $expected); }