Skip to content

Commit

Permalink
Overwrite the schemaName property if it is not defined in the class.
Browse files Browse the repository at this point in the history
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 4, 2014
1 parent fb15fb6 commit 765be87
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Cake/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 765be87

Please sign in to comment.