From 926d70a6464c927b05a15f5aac353e0f07a48ec0 Mon Sep 17 00:00:00 2001 From: Charles SANQUER Date: Mon, 8 Apr 2013 10:57:56 +0200 Subject: [PATCH 1/4] add locale length option for i18n behavior --- generator/lib/behavior/i18n/I18nBehavior.php | 3 +- .../behavior/i18n/I18nBehaviorTest.php | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/generator/lib/behavior/i18n/I18nBehavior.php b/generator/lib/behavior/i18n/I18nBehavior.php index a749422ea..4a0167ef4 100644 --- a/generator/lib/behavior/i18n/I18nBehavior.php +++ b/generator/lib/behavior/i18n/I18nBehavior.php @@ -30,6 +30,7 @@ class I18nBehavior extends Behavior 'i18n_columns' => '', 'i18n_pk_name' => null, 'locale_column' => 'locale', + 'locale_length' => 5, 'default_locale' => null, 'locale_alias' => '', ); @@ -128,7 +129,7 @@ protected function addLocaleColumnToI18n() $this->i18nTable->addColumn(array( 'name' => $localeColumnName, 'type' => PropelTypes::VARCHAR, - 'size' => 5, + 'size' => $this->getParameter('locale_length') ? (int) $this->getParameter('locale_length') : 5, 'default' => $this->getDefaultLocale(), 'primaryKey' => 'true', )); diff --git a/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php b/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php index 9b85db041..47755e089 100644 --- a/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php +++ b/test/testsuite/generator/behavior/i18n/I18nBehaviorTest.php @@ -401,7 +401,37 @@ public function testModifyTableUseCustomPkName() $this->assertContains($expected, $builder->getSQL()); } + public function testModiFyTableUsesCustomI18nLocaleLength() + { + $schema = << + + + + + +
+ +EOF; + $builder = new PropelQuickBuilder(); + $builder->setSchema($schema); + $expected = <<assertContains($expected, $builder->getSQL()); + } + public function testTableWithPrefix() { $schema = << Date: Fri, 19 Apr 2013 02:25:07 +0200 Subject: [PATCH 2/4] Fixed #651. Stupid typo. --- generator/lib/model/Table.php | 2 +- test/testsuite/misc/Issue651Test.php | 129 +++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 test/testsuite/misc/Issue651Test.php diff --git a/generator/lib/model/Table.php b/generator/lib/model/Table.php index a9ed2dc2e..af68968a2 100644 --- a/generator/lib/model/Table.php +++ b/generator/lib/model/Table.php @@ -490,7 +490,7 @@ public function addExtraIndices() foreach ($this->getReferrers() as $foreignKey) { $referencedColumns = $foreignKey->getForeignColumnObjects(); $referencedColumnsHash = $this->getColumnList($referencedColumns); - if (!empty($localColumnsHash) && !array_key_exists($referencedColumnsHash, $_indices)) { + if (!empty($referencedColumns) && !array_key_exists($referencedColumnsHash, $_indices)) { // no matching index defined in the schema, so we have to create one $name = sprintf('I_referenced_%s_%s', $foreignKey->getName(), ++$counter); diff --git a/test/testsuite/misc/Issue651Test.php b/test/testsuite/misc/Issue651Test.php new file mode 100644 index 000000000..819b6f512 --- /dev/null +++ b/test/testsuite/misc/Issue651Test.php @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + +
+ +'; + +$actual = " +# This is a fix for InnoDB in MySQL >= 4.1.x +# It \"suspends judgement\" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- notification +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `notification`; + +CREATE TABLE `notification` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `target_user_id` INTEGER NOT NULL, + `notification_type_unique_name` VARCHAR(255) NOT NULL, + `group_id` INTEGER, + `date` DATETIME NOT NULL, + `objects` TEXT, + `is_new` TINYINT(1) DEFAULT 1 NOT NULL, + PRIMARY KEY (`id`), + INDEX `FK_NOTIFICATION_TARGET_USER` (`target_user_id`), + INDEX `FK_NOTIFICATION_TYPENOTIFICATION` (`notification_type_unique_name`), + CONSTRAINT `FK_NOTIFICATION_TYPENOTIFICATION0` + FOREIGN KEY (`notification_type_unique_name`) + REFERENCES `notification_type` (`unique_name`) +) ENGINE=InnoDb; + +-- --------------------------------------------------------------------- +-- notification_type +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `notification_type`; + +CREATE TABLE `notification_type` +( + `module_unique_name` VARCHAR(255) NOT NULL, + `unique_name` VARCHAR(255) NOT NULL, + `is_correction` TINYINT(1) DEFAULT 0 NOT NULL, + `disabled_engine` VARCHAR(255), + PRIMARY KEY (`module_unique_name`,`unique_name`), + INDEX `FK_TYPENOTIFICATION_MODULE` (`module_unique_name`), + INDEX `I_referenced_FK_NOTIFICATION_TYPENOTIFICATION0_1` (`unique_name`), + CONSTRAINT `FK_TYPENOTIFICATION_MODULE0` + FOREIGN KEY (`module_unique_name`) + REFERENCES `module` (`unique_name`) + ON UPDATE CASCADE + ON DELETE CASCADE +) ENGINE=InnoDb; + +-- --------------------------------------------------------------------- +-- module +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `module`; + +CREATE TABLE `module` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `unique_name` VARCHAR(255) NOT NULL, + `label` VARCHAR(255) NOT NULL, + `description` VARCHAR(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDb; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; +"; + + + $platform = new MysqlPlatform(); + $platform->setDefaultTableEngine('InnoDb'); + $updatedBuilder = new PropelQuickBuilder(); + $updatedBuilder->setPlatform($platform); + $updatedBuilder->setSchema($updatedSchema); + + $sql = $updatedBuilder->getSQL(); + $this->assertEquals($actual, $sql); + } + +} From 044636fb5ec6f104c2daecf74311b759df1aa0c0 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Tue, 22 Oct 2013 00:25:53 +0200 Subject: [PATCH 3/4] Fix travis-ci status --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e93759503..dd15add88 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ Propel is an open-source Object-Relational Mapping (ORM) for PHP5. -[![Build Status](https://secure.travis-ci.org/propelorm/Propel.png?branch=master)](http://travis-ci.org/propelorm/Propel) +[![Build +Status](https://travis-ci.org/propelorm/Propel.png?branch=1.6)](https://travis-ci.org/propelorm/Propel) ## A quick tour of the features ## From 778a498bfc647935e8cd4c28a11abff9311306ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C3=B3jcik?= Date: Wed, 13 Nov 2013 18:23:45 +0100 Subject: [PATCH 4/4] Added code insight in migration classes in IDEs --- generator/lib/util/PropelMigrationManager.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/generator/lib/util/PropelMigrationManager.php b/generator/lib/util/PropelMigrationManager.php index f31ccd3b2..07682e180 100644 --- a/generator/lib/util/PropelMigrationManager.php +++ b/generator/lib/util/PropelMigrationManager.php @@ -308,21 +308,37 @@ public function getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp class $migrationClassName { + /** + * @param PropelMigrationManager \$manager + * + * @return bool|void + */ public function preUp(\$manager) { // add the pre-migration code here } + /** + * @param PropelMigrationManager \$manager + */ public function postUp(\$manager) { // add the post-migration code here } + /** + * @param PropelMigrationManager \$manager + * + * @return bool|void + */ public function preDown(\$manager) { // add the pre-migration code here } + /** + * @param PropelMigrationManager \$manager + */ public function postDown(\$manager) { // add the post-migration code here