Browse Source

Overwrite the schemaName property if it is not defined in the class.

If a model class does not define a schemaName we should use the
datasource's schemaName. We can assume that people using schemaName want
to lock the model onto a specific schema given the changes in #3210

Fixes #3720
mark_story 11 years ago
parent
commit
765be87d88
1 changed files with 6 additions and 1 deletions
  1. 6 1
      lib/Cake/Model/Model.php

+ 6 - 1
lib/Cake/Model/Model.php

@@ -3490,7 +3490,12 @@ class Model extends Object implements CakeEventListener {
 			$this->tablePrefix = $db->config['prefix'];
 		}
 
-		$this->schemaName = (empty($this->schemaName) ? $db->getSchemaName() : $this->schemaName);
+		$schema = $db->getSchemaName();
+		$defaultProperties = get_class_vars(get_class($this));
+		if (isset($defaultProperties['schemaName'])) {
+			$schema = $defaultProperties['schemaName'];
+		}
+		$this->schemaName = $schema;
 	}
 
 /**