Skip to content
Permalink
Browse files

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
  • Loading branch information...
markstory committed Jul 2, 2014
1 parent fb15fb6 commit 765be87d886399993613cf75dc49402093822116
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/Cake/Model/Model.php
@@ -3490,7 +3490,12 @@ public function setDataSource($dataSource = null) {
$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;
}
/**

0 comments on commit 765be87

Please sign in to comment.
You can’t perform that action at this time.