mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Correcting table index formatting for schema generation in DboPostgres, fixes #5471, docblock formatting fixes in ClassRegistry.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7682 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1ae8cda6c2
commit
8758f36915
3 changed files with 33 additions and 8 deletions
|
@ -74,15 +74,17 @@ class ClassRegistry {
|
|||
/**
|
||||
* Loads a class, registers the object in the registry and returns instance of the object.
|
||||
*
|
||||
*
|
||||
* @param mixed $class as a string or a single key => value array instance will be created, stored in the registry and returned.
|
||||
* @param mixed $class as a string or a single key => value array instance will be created,
|
||||
* stored in the registry and returned.
|
||||
* Required: array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass');
|
||||
* Model Classes can accept optional array('id' => $id, 'table' => $table, 'ds' => $ds, 'alias' => $alias);
|
||||
* When $class is a numeric keyed array, multiple class instances will be stored in the registry, no instance of the object will be returned
|
||||
* When $class is a numeric keyed array, multiple class instances will be stored in the registry,
|
||||
* no instance of the object will be returned
|
||||
* array(
|
||||
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
|
||||
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
|
||||
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'));
|
||||
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
|
||||
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
|
||||
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass')
|
||||
* );
|
||||
*
|
||||
* @param string $type TypeOfClass
|
||||
* @return object intance of ClassName
|
||||
|
|
|
@ -690,13 +690,14 @@ class DboPostgres extends DboSource {
|
|||
break;
|
||||
}
|
||||
}
|
||||
$join = array('columns' => ",\n\t", 'indexes' => "\n");
|
||||
|
||||
foreach (array('columns', 'indexes') as $var) {
|
||||
if (is_array(${$var})) {
|
||||
${$var} = "\t" . join(",\n\t", array_filter(${$var}));
|
||||
${$var} = join($join[$var], array_filter(${$var}));
|
||||
}
|
||||
}
|
||||
return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}";
|
||||
return "CREATE TABLE {$table} (\n\t{$columns}\n);\n{$indexes}";
|
||||
break;
|
||||
default:
|
||||
return parent::renderStatement($type, $data);
|
||||
|
|
|
@ -421,6 +421,28 @@ class DboPostgresTest extends CakeTestCase {
|
|||
$result = $model->find('first');
|
||||
$this->assertEqual($result['BinaryTest']['data'], $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the syntax of generated schema indexes
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testSchemaIndexSyntax() {
|
||||
$schema = new CakeSchema();
|
||||
$schema->tables = array('i18n' => array(
|
||||
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
|
||||
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
|
||||
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||
'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
|
||||
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
|
||||
'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
|
||||
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
|
||||
));
|
||||
|
||||
$result = $this->db->createSchema($schema);
|
||||
$this->assertNoPattern('/^CREATE INDEX(.+);,$/', $result);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue