浏览代码

Merge pull request #1683 from andydhobbs/ticket-4108

Fix fields cache to depend on the schemaName as well.

Fixes #4108
Mark Story 12 年之前
父节点
当前提交
ad1b80645d
共有 2 个文件被更改,包括 23 次插入0 次删除
  1. 1 0
      lib/Cake/Model/Datasource/DboSource.php
  2. 22 0
      lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php

+ 1 - 0
lib/Cake/Model/Datasource/DboSource.php

@@ -2281,6 +2281,7 @@ class DboSource extends DataSource {
 			$fields,
 			$fields,
 			$quote,
 			$quote,
 			ConnectionManager::getSourceName($this),
 			ConnectionManager::getSourceName($this),
+			$model->schemaName,
 			$model->table
 			$model->table
 		);
 		);
 		$cacheKey = md5(serialize($cacheKey));
 		$cacheKey = md5(serialize($cacheKey));

+ 22 - 0
lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php

@@ -946,6 +946,28 @@ class DboSourceTest extends CakeTestCase {
 	}
 	}
 
 
 /**
 /**
+ * test that fields() method cache detects schema name changes
+ *
+ * @return void
+ */
+	public function testFieldsCacheKeyWithSchemanameChange() {
+		Cache::delete('method_cache', '_cake_core_');
+		DboSource::$methodCache = array();
+		$Article = ClassRegistry::init('Article');
+
+		$ds = $Article->getDataSource();
+		$ds->cacheMethods = true;
+		$first = $ds->fields($Article);
+
+		$Article->schemaName = 'secondSchema';
+		$ds = $Article->getDataSource();
+		$ds->cacheMethods = true;
+		$second = $ds->fields($Article);
+
+		$this->assertEquals(2, count(DboSource::$methodCache['fields']));
+	}
+
+/**
  * Test that group works without a model
  * Test that group works without a model
  *
  *
  * @return void
  * @return void