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
This commit is contained in:
mark_story 2014-07-02 17:55:07 -04:00
parent fb15fb6001
commit 765be87d88

View file

@ -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;
}
/**