Commit 75dbc8c8 authored by romanb's avatar romanb

Several bugfixes for the export module (expecially pgsql).

parent 6348e5f7
This diff is collapsed.
This diff is collapsed.
...@@ -283,5 +283,68 @@ class Doctrine_Export_Pgsql extends Doctrine_Export ...@@ -283,5 +283,68 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
return 'DROP SEQUENCE ' . $sequenceName; return 'DROP SEQUENCE ' . $sequenceName;
} }
/**
* Creates a table.
*
* @param unknown_type $name
* @param array $fields
* @param array $options
* @return unknown
*/
public function createTableSql($name, array $fields, array $options = array())
{
if ( ! $name) {
throw new Doctrine_Export_Exception('no valid table name specified');
}
if (empty($fields)) {
throw new Doctrine_Export_Exception('no fields specified for table ' . $name);
}
$queryFields = $this->getFieldDeclarationList($fields);
if (isset($options['primary']) && ! empty($options['primary'])) {
$queryFields .= ', PRIMARY KEY(' . implode(', ', array_values($options['primary'])) . ')';
}
$name = $this->conn->quoteIdentifier($name, true);
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
$sql[] = $query;
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach($options['indexes'] as $index => $definition) {
$sql[] = $this->createIndexSql($name, $index, $definition);
}
}
if (isset($options['foreignKeys'])) {
foreach ((array) $options['foreignKeys'] as $k => $definition) {
if (is_array($definition)) {
$sql[] = $this->createForeignKeySql($name, $definition);
}
}
}
return $sql;
}
/**
* createForeignKeySql
*
* @param string $table name of the table on which the foreign key is to be created
* @param array $definition associative array that defines properties of the foreign key to be created.
* @return string
*/
public function createForeignKeySql($table, array $definition)
{
$table = $this->conn->quoteIdentifier($table);
$query = 'ALTER TABLE ' . $table . ' ADD ' . $this->getForeignKeyDeclaration($definition);
return $query;
}
} }
This diff is collapsed.
...@@ -49,6 +49,14 @@ class Doctrine_NestedSet_SingleRoot_TestCase extends Doctrine_UnitTestCase ...@@ -49,6 +49,14 @@ class Doctrine_NestedSet_SingleRoot_TestCase extends Doctrine_UnitTestCase
$node2->name = 'node2'; $node2->name = 'node2';
$node2->getNode()->insertAsLastChildOf($node); $node2->getNode()->insertAsLastChildOf($node);
} }
public function testLftRgtValues()
{
$treeMngr = $this->conn->getTable('NestedSetTest_SingleRootNode')->getTree();
$root = $treeMngr->fetchRoot();
$this->assertEqual(1, $root['lft']);
$this->assertEqual(4, $root['rgt']);
}
public function testGetDescendants() public function testGetDescendants()
{ {
......
...@@ -336,7 +336,7 @@ $test->addTestCase(new Doctrine_Search_TestCase()); ...@@ -336,7 +336,7 @@ $test->addTestCase(new Doctrine_Search_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase()); //$test->addTestCase(new Doctrine_AuditLog_TestCase());
//$test->addTestCase(new Doctrine_NestedSet_SingleRoot_TestCase()); $test->addTestCase(new Doctrine_NestedSet_SingleRoot_TestCase());
// Cache tests // Cache tests
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase()); //$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment