From 56b230a1f0be394266a3bb3a0fbff07c97519a98 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 1 Dec 2012 19:41:51 +0100 Subject: [PATCH 1/3] Fixed typo --- tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php index 0ca1bf4cc..d434e47eb 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php @@ -44,8 +44,8 @@ class SchemaToolTest extends \Doctrine\Tests\OrmTestCase $schema = $schemaTool->getSchemaFromMetadata($classes); $expected = array('foo' => 'bar', 'baz' => array('key' => 'val')); - - $this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getOptions(), "options annotation are passed to the tables optionss"); + + $this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getOptions(), "options annotation are passed to the tables options"); $this->assertEquals($expected, $schema->getTable('TestEntityWithAnnotationOptionsAttribute')->getColumn('test')->getCustomSchemaOptions(), "options annotation are passed to the columns customSchemaOptions"); } From df2bfbb6368f50ca59bf6aaa36f3f854c800a25e Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 1 Dec 2012 21:12:55 +0100 Subject: [PATCH 2/3] Fixed trailing spaces on SchemaTool --- lib/Doctrine/ORM/Tools/SchemaTool.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index 3eb60e87c..d5fb8a768 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -399,13 +399,13 @@ class SchemaTool unset($mapping['options']['unsigned']); } - + if (isset($mapping['options']['fixed'])) { $options['fixed'] = $mapping['options']['fixed']; - + unset($mapping['options']['fixed']); } - + $options['customSchemaOptions'] = $mapping['options']; } @@ -609,7 +609,7 @@ class SchemaTool break; } } - $blacklistedFks[$compositeName] = true; + $blacklistedFks[$compositeName] = true; } elseif (!isset($blacklistedFks[$compositeName])) { $addedFks[$compositeName] = array('foreignTableName' => $foreignTableName, 'foreignColumns' => $foreignColumns); $theJoinTable->addUnnamedForeignKeyConstraint( From 657a54da84765858e7e825c97faf54cfe8ff0039 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 1 Dec 2012 21:14:08 +0100 Subject: [PATCH 3/3] Passed column options to the join column --- lib/Doctrine/ORM/Tools/SchemaTool.php | 4 ++ .../ORM/Functional/Ticket/DDC2182Test.php | 52 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index d5fb8a768..6a5319b1c 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -576,6 +576,10 @@ class SchemaTool $columnOptions['notnull'] = !$joinColumn['nullable']; } + if (isset($fieldMapping['options'])) { + $columnOptions['options'] = $fieldMapping['options']; + } + if ($fieldMapping['type'] == "string" && isset($fieldMapping['length'])) { $columnOptions['length'] = $fieldMapping['length']; } elseif ($fieldMapping['type'] == "decimal") { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php new file mode 100644 index 000000000..129e9dac3 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2182Test.php @@ -0,0 +1,52 @@ +_em->getConnection()->getDatabasePlatform()->getName() != 'mysql') { + $this->markTestSkipped("This test is useful for all databases, but designed only for mysql."); + } + + $sql = $this->_schemaTool->getCreateSchemaSql(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2182OptionParent'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2182OptionChild'), + )); + + $this->assertEquals("CREATE TABLE DDC2182OptionParent (id INT UNSIGNED NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[0]); + $this->assertEquals("CREATE TABLE DDC2182OptionChild (id VARCHAR(255) NOT NULL, parent_id INT UNSIGNED DEFAULT NULL, INDEX IDX_B314D4AD727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDB", $sql[1]); + $this->assertEquals("ALTER TABLE DDC2182OptionChild ADD CONSTRAINT FK_B314D4AD727ACA70 FOREIGN KEY (parent_id) REFERENCES DDC2182OptionParent (id)", $sql[2]); + } +} + +/** + * @Entity + * @Table + */ +class DDC2182OptionParent +{ + /** @Id @Column(type="integer", options={"unsigned": true}) */ + private $id; +} + +/** + * @Entity + * @Table + */ +class DDC2182OptionChild +{ + /** @Id @Column */ + private $id; + + /** + * @ManyToOne(targetEntity="DDC2182OptionParent") + * @JoinColumn(referencedColumnName="id") + */ + private $parent; +}