Commit 54e5f45c authored by zYne's avatar zYne

--no commit message

--no commit message
parent 591cbe40
......@@ -179,15 +179,14 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
$queryFields.= ', PRIMARY KEY('.implode(', ', array_values($options['primary'])).')';
}
$name = $this->conn->quoteIdentifier($name, true);
$query[] = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach ($options['indexes'] as $index => $definition) {
$queryFields .= ', ' . $this->getIndexDeclaration($index, $definition);
$query[] = $this->createIndexSql($name, $index, $definition);
}
}
$name = $this->conn->quoteIdentifier($name, true);
$query = 'CREATE TABLE ' . $name . ' (' . $queryFields . ')';
return $query;
......
......@@ -34,7 +34,12 @@ class Doctrine_Relation_OneToMany_TestCase extends Doctrine_UnitTestCase
{
public function prepareData()
{ }
public function prepareTables()
{
$this->tables = array('Entity', 'Phonenumber', 'Email', 'Policy', 'PolicyAsset');
parent::prepareTables();
}
public function testRelationParsing()
{
$table = $this->conn->getTable('Entity');
......@@ -47,7 +52,7 @@ class Doctrine_Relation_OneToMany_TestCase extends Doctrine_UnitTestCase
$this->assertTrue($rel instanceof Doctrine_Relation_LocalKey);
}
public function testRelationParsing2()
{
$table = $this->conn->getTable('Phonenumber');
......@@ -66,6 +71,19 @@ class Doctrine_Relation_OneToMany_TestCase extends Doctrine_UnitTestCase
$this->assertTrue($rel instanceof Doctrine_Relation_ForeignKey);
}
public function testRelationSaving()
{
$p = new Policy();
$p->policy_number = '123';
$a = new PolicyAsset();
$a->value = '123.13';
$p->PolicyAssets[] = $a;
$p->save();
$this->assertEqual($a->policy_number, '123');
}
public function testRelationSaving2()
{
$e = new Entity();
$e->name = 'test';
......@@ -79,8 +97,8 @@ class Doctrine_Relation_OneToMany_TestCase extends Doctrine_UnitTestCase
}
class Policy extends Doctrine_Record
{
public function setTableDefinition(){
$this->setTableName('policies');
public function setTableDefinition()
{
$this->hasColumn('policy_number', 'integer', 11, array('unique' => true));
}
......@@ -88,22 +106,21 @@ class Policy extends Doctrine_Record
{
$this->hasMany('PolicyAsset as PolicyAssets', array('local' => 'policy_number',
'foreign' => 'policy_number'));
$this->index('policy_number_index', array('fields' => 'policy_number'));
$this->index('policy_number_index', array('fields' => array('policy_number')));
}
}
class PolicyAsset extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('policy_assets');
$this->hasColumn('policy_number', 'integer', 11);
$this->hasColumn('value', 'float', 10, array ('notblank' => true,));
}
public function setUp(){
public function setUp()
{
$this->hasOne('Policy', array('foreign' => 'policy_number',
'local' => 'policy_number'));
$this->index('policy_number_index', array('fields' => 'policy_number'));
$this->index('vehicle_code_index', array('fields' => 'vehicle_code'));
$this->index('policy_number_index', array('fields' => array('policy_number')));
}
}
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