Permalink
Browse files

Updating CakeSchema to pass a Model object into DboSource::fullTableN…

…ame(); Fixes schema's not correctly reading tablePrefixes.


Fixes #290
  • Loading branch information...
markstory committed Nov 13, 2009
1 parent 61d56cd commit 2c5fa171e0aced91a2e47378507ad46ef981f790
Showing with 11 additions and 2 deletions.
  1. +1 −1 cake/libs/model/cake_schema.php
  2. +10 −1 cake/tests/cases/libs/model/cake_schema.test.php
@@ -245,7 +245,7 @@ function read($options = array()) {
if (is_object($Object) && $Object->useTable !== false) {
$Object->setDataSource($connection);
- $table = $db->fullTableName($Object->useTable, false);
+ $table = $db->fullTableName($Object, false);
if (in_array($table, $currentTables)) {
$key = array_search($table, $currentTables);
@@ -457,8 +457,17 @@ function testSchemaRead() {
ConnectionManager::create('schema_prefix', $config);
$read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false));
$this->assertTrue(empty($read['tables']));
- }
+ $SchemaPost =& ClassRegistry::init('SchemaPost');
+ $SchemaPost->table = 'sts';
+ $SchemaPost->tablePrefix = 'po';
+ $read = $this->Schema->read(array(
+ 'connection' => 'test_suite',
+ 'name' => 'TestApp',
+ 'models' => array('SchemaPost')
+ ));
+ $this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s');
+ }
/**
* test reading schema from plugins.
*

0 comments on commit 2c5fa17

Please sign in to comment.